@use "@wordpress/base-styles/colors" as *;
@use "@wordpress/base-styles/variables" as *;
@use "../utils/theme-variables" as *;

.tools-panel {
	border-top: $border-width solid $gray-300;
	margin-top: -$border-width;
	padding: $grid-unit-20;
}

.tools-panel-with-inner-wrapper {
	> div:not(:first-of-type) {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: var(--wpds-dimension-gap-lg);
		row-gap: var(--wpds-dimension-gap-lg);
		grid-column: 1 / -1;
	}
}

.tools-panel-hidden-inner-wrapper {
	> div:not(:first-of-type) {
		display: none;
	}
}

.tools-panel-header {
	grid-column: 1 / -1;
	gap: $grid-unit-10;

	// Targeting DropdownMenu's legacy classes is temporary until it exposes a
	// supported styling hook for these overrides.
	:global(.components-dropdown-menu) {
		margin: (-1 * $grid-unit-05) 0;
		line-height: 0;
	}
}

// Preserve the established specificity so these styles continue to
// override the DropdownMenu toggle defaults.
.tools-panel-header.tools-panel-header.tools-panel-header.tools-panel-header {
	:global(.components-dropdown-menu__toggle) {
		padding: 0;
		min-width: $grid-unit-30;
	}
}

// Outrank Heading's base typography regardless of stylesheet insertion order.
.tools-panel-heading.tools-panel-heading {
	font-size: inherit;
	line-height: normal;
	margin: 0;
}

.tools-panel-item {
	grid-column: 1 / -1;

	// Clear spacing in and around controls added as panel items. Remove these
	// overrides when the spacing can be addressed via the context system.
	& > div,
	& > fieldset {
		padding-bottom: 0;
		margin-bottom: 0;
		max-width: 100%;
	}
}

// Preserve the established specificity and target BaseControl's public classes.
.tools-panel-item.tools-panel-item :global(.components-base-control) {
	margin-bottom: 0;

	// Keep the field spacing when help text follows it.
	:global(.components-base-control__field):last-child {
		margin-bottom: 0;
	}
}

.tools-panel-item :global(.components-base-control__help) {
	margin-bottom: 0;
}

.tools-panel-item-placeholder {
	display: none;
}

.dropdown-menu {
	min-width: 200px;
}

.reset-label {
	color: $components-color-accent-darker-10;
	font-size: var(--wpds-typography-font-size-xs);
	font-weight: var(--wpds-typography-font-weight-emphasis);
	line-height: 1.4;
	margin-inline-start: $grid-unit-15;
	text-transform: uppercase;
}

.default-controls-item {
	color: $gray-900;

	// Match the foreground of the highlighted item's brand fill.
	&:focus .reset-label {
		color: inherit;
	}
}

// Preserve the established specificity so disabled MenuItem styles
// continue to override its defaults.
.default-controls-item.default-controls-item[aria-disabled="true"] {
	color: $gray-700;
	opacity: 1;

	&:hover {
		color: $gray-700;
	}

	.reset-label {
		opacity: 0.3;
	}
}
