/**
 * Shared bordered cards for inspector Fields / Styles groups.
 * Used by Gutenberg, frontend editor, admin Design panel, and ElementToolbar.
 */

.bm-inspector-stack {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-width: 0;
	max-width: 100%;
}

.bm-inspector-card {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin: 0;
	padding: 10px;
	border: 1px solid #e2e4e7;
	border-radius: 2px;
	background: #fff;
	box-sizing: border-box;
	box-shadow: 0 1px 2px rgba(19, 27, 46, 0.04);
	min-width: 0;
	max-width: 100%;
	overflow-x: hidden;
	/* Menus portal/fixed outside — card itself must not scroll from dropdowns. */
	overflow-y: visible;
}

.bm-inspector-card--nested {
	padding: 10px;
	background: #f6f7f9;
	border-color: #dcdcde;
	box-shadow: none;
}

.bm-inspector-card__title {
	display: block;
	margin: 0 0 2px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #464555;
}

.bm-inspector-card__title-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	min-width: 0;
}

.bm-inspector-card__title-row .bm-inspector-card__title {
	margin: 0;
	flex: 1 1 auto;
	min-width: 0;
}

.bm-inspector-card__title-action {
	flex: 0 0 auto;
}

.bm-inspector-card__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	box-shadow: none;
	cursor: pointer;
	text-align: left;
	color: inherit;
}

.bm-inspector-card__toggle .bm-inspector-card__title {
	margin: 0;
	flex: 1 1 auto;
	min-width: 0;
}

.bm-inspector-card__chevron {
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	font-size: 16px;
	line-height: 1;
	color: #777587;
	transition: transform 0.15s ease;
}

.bm-inspector-card.is-open > .bm-inspector-card__toggle .bm-inspector-card__chevron {
	transform: rotate(180deg);
}

.bm-inspector-card__toggle:hover .bm-inspector-card__chevron,
.bm-inspector-card__toggle:focus-visible .bm-inspector-card__chevron {
	color: #3525cd;
}

.bm-inspector-card__toggle:focus-visible {
	outline: 2px solid #3525cd;
	outline-offset: 2px;
	border-radius: 2px;
}

.bm-inspector-card > .bm-inspector-card__title + *,
.bm-inspector-card > .bm-inspector-card__toggle + * {
	margin-top: 0;
}

/* Dense fields inside cards — gap owns spacing. */
.bm-inspector-card .bm-style-field,
.bm-inspector-card .bm-style-field--fill,
.bm-inspector-card .bm-style-field--overlay,
.bm-inspector-card .bm-style-field--spacing,
.bm-inspector-card .bm-style-field--box-spacing,
.bm-inspector-card .bm-field,
.bm-inspector-card .bm-field-wrap--visibility,
.bm-inspector-card .bm-searchable-select,
.bm-inspector-card .bm-element-toolbar__field,
.bm-inspector-card .components-base-control,
.bm-inspector-card .components-base-control__field {
	margin-top: 0 !important;
	margin-bottom: 0 !important;
}

.bm-inspector-card .bm-style-field__spacing-row {
	margin-bottom: 0;
	padding-bottom: 14px;
}

.bm-inspector-card .bm-flexible-unit,
.bm-inspector-card .bm-flexible-unit-wrap {
	margin-bottom: 0 !important;
}

.bm-inspector-card .bm-gutenberg-elements__list {
	display: flex;
	flex-direction: column;
	flex-wrap: nowrap;
	align-items: stretch;
	gap: 4px;
	margin: 0;
	width: 100%;
}

.bm-inspector-card .bm-gutenberg-elements__list-static,
.bm-inspector-card .bm-gutenberg-elements__sortable {
	width: 100%;
}

.bm-inspector-card .bm-gutenberg-elements__list-static .bm-gutenberg-element-btn,
.bm-inspector-card .bm-gutenberg-elements__sortable .bm-gutenberg-element-btn,
.bm-inspector-card .bm-gutenberg-elements__list > .bm-gutenberg-element-btn {
	width: 100%;
	flex: 0 0 auto;
	max-width: 100%;
}

/*
 * BaseControl help under the label (above the control).
 * Toggle/checkbox keep default help placement.
 */
.bm-inspector-card .components-base-control:not(.components-toggle-control):not(.components-checkbox-control),
.bm-element-toolbar .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) {
	display: flex;
	flex-direction: column;
}

.bm-inspector-card .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) > .components-base-control__field,
.bm-element-toolbar .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) > .components-base-control__field {
	display: contents;
}

.bm-inspector-card .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) .components-base-control__label,
.bm-element-toolbar .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) .components-base-control__label,
.bm-inspector-card .components-input-control__label,
.bm-element-toolbar .components-input-control__label {
	order: 0;
	display: inline-block;
	margin-bottom: 0.35rem;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	line-height: 1.4;
	text-transform: uppercase;
	color: var(--bm-f-on-surface-variant, var(--bm-color-on-surface-variant, #464555));
}

.bm-inspector-card .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) > .components-base-control__help,
.bm-element-toolbar .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) > .components-base-control__help {
	order: 1;
	margin-top: 4px;
	margin-bottom: 8px;
}

.bm-inspector-card .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) > .components-base-control__field > *:not(.components-base-control__label):not(label),
.bm-element-toolbar .components-base-control:not(.components-toggle-control):not(.components-checkbox-control) > .components-base-control__field > *:not(.components-base-control__label):not(label) {
	order: 2;
}
