/*!
 * Copyright 2024 Adobe. All rights reserved.
 *
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at <http://www.apache.org/licenses/LICENSE-2.0>
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

.spectrum-Form {
	--spectrum-form-item-block-spacing: var(--spectrum-spacing-300);
	--spectrum-form-item-block-spacing-labels-above: var(--spectrum-spacing-200);

	--spectrum-form-grid-template-columns: auto auto;
	--spectrum-form-grid-template-columns-labels-above: auto;

	--spectrum-form-item-disabled-content-color: var(--spectrum-disabled-content-color);

	margin: 0;
	display: grid;
	grid-template-columns: var(--mod-form-grid-template-columns, var(--spectrum-form-grid-template-columns));
	inline-size: var(--mod-form-inline-size, fit-content);
	justify-content: start;
	row-gap: var(--mod-form-item-block-spacing, var(--spectrum-form-item-block-spacing));
}

/* Row */
.spectrum-Form-item {
	display: contents;
}

@supports (grid-template-columns: subgrid) {
	.spectrum-Form-item {
		display: grid;
		grid-column: span 2;
		grid-template-columns: subgrid;
	}
}

.spectrum-Form-itemLabel,
.spectrum-Form-itemField {
	display: block;
}

/* Fix extra space after inline-flex elements such as stepper. */
.spectrum-Form-itemField > * {
	vertical-align: top;
}

/* Rows with stacked alignment */
.spectrum-Form--labelsAbove {
	--mod-form-item-block-spacing: var(--mod-form-item-block-spacing-labels-above, var(--spectrum-form-item-block-spacing-labels-above));
	--mod-form-grid-template-columns: var(--mod-form-grid-template-columns-labels-above, var(--spectrum-form-grid-template-columns-labels-above));

	.spectrum-Form-item {
		display: block;
	}
}

/********* Disabled state *********/
.spectrum-Form-itemLabel {
	&.is-disabled {
		color: var(--highcontrast-form-item-disabled-content-color, var(--mod-disabled-content-color, var(--spectrum-form-item-disabled-content-color)));

		.spectrum-FieldLabel-requiredIcon {
			color: var(--highcontrast-form-item-disabled-content-color, var(--mod-disabled-content-color, var(--spectrum-form-item-disabled-content-color)));
		}
	}
}

/********* WHCM *********/
@media (forced-colors: active) {
	.spectrum-Form {
		--highcontrast-form-item-disabled-content-color: GrayText;
	}
}
