/**
 * Autolevo Unified Dropdown System (CSS)
 *
 * Monochrome + Mobility Blue (#276EF1) glassmorphic dropdown system replacing
 * native OS <select> menus and unifying custom dropdown popovers across both
 * Dark Mode (default) and Light Mode with full RTL logical-property support.
 *
 * Scope: Frontend only (#wpadminbar and /wp-admin/ are excluded).
 *
 * @package Autolevo\Core
 */

/* ==========================================================================
   1. DESIGN TOKENS — DARK MODE DEFAULT & LIGHT MODE OVERRIDES
   ========================================================================== */
:root,
html[data-theme="dark"] {
	--al-dd-trigger-bg: #18181A;
	--al-dd-trigger-hover-bg: #202024;
	--al-dd-trigger-border: rgba(255, 255, 255, 0.14);
	--al-dd-trigger-border-hover: rgba(255, 255, 255, 0.28);
	--al-dd-trigger-text: #FFFFFF;
	--al-dd-trigger-placeholder: #8C8C8C;
	--al-dd-chevron-color: #A6A6A6;

	--al-dd-popover-bg: rgba(20, 20, 22, 0.88);
	--al-dd-popover-fallback: #141416;
	--al-dd-popover-border: rgba(255, 255, 255, 0.13);
	--al-dd-popover-shadow: 0 20px 44px rgba(0, 0, 0, 0.56), 0 4px 12px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);

	--al-dd-search-border: rgba(255, 255, 255, 0.10);
	--al-dd-group-color: #8C8C8C;
	--al-dd-group-text: #FFFFFF;
	--al-dd-group-hover-bg: rgba(255, 255, 255, 0.08);
	--al-dd-group-active-bg: rgba(39, 110, 241, 0.12);
	--al-dd-group-border: rgba(255, 255, 255, 0.08);
	--al-dd-count-bg: rgba(255, 255, 255, 0.09);
	--al-dd-count-text: #B8B8B8;
	--al-dd-guide-line: rgba(255, 255, 255, 0.12);
	--al-dd-option-text: #F2F2F2;
	--al-dd-option-hover-bg: rgba(255, 255, 255, 0.08);
	--al-dd-option-selected-bg: rgba(39, 110, 241, 0.16);
	--al-dd-option-selected-text: #FFFFFF;
	--al-dd-check-color: #6096FA;
	--al-dd-scrollbar-thumb: rgba(255, 255, 255, 0.22);
	--al-dd-scrollbar-hover: rgba(255, 255, 255, 0.36);
}

html[data-theme="light"] {
	--al-dd-trigger-bg: #FFFFFF;
	--al-dd-trigger-hover-bg: #FAFAFA;
	--al-dd-trigger-border: rgba(0, 0, 0, 0.14);
	--al-dd-trigger-border-hover: rgba(0, 0, 0, 0.30);
	--al-dd-trigger-text: #0A0A0A;
	--al-dd-trigger-placeholder: #6B6B6B;
	--al-dd-chevron-color: #545454;

	--al-dd-popover-bg: rgba(255, 255, 255, 0.90);
	--al-dd-popover-fallback: #FFFFFF;
	--al-dd-popover-border: rgba(0, 0, 0, 0.10);
	--al-dd-popover-shadow: 0 20px 42px rgba(0, 0, 0, 0.14), 0 4px 12px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);

	--al-dd-search-border: rgba(0, 0, 0, 0.08);
	--al-dd-group-color: #6B6B6B;
	--al-dd-group-text: #0A0A0A;
	--al-dd-group-hover-bg: rgba(0, 0, 0, 0.055);
	--al-dd-group-active-bg: rgba(39, 110, 241, 0.08);
	--al-dd-group-border: rgba(0, 0, 0, 0.07);
	--al-dd-count-bg: rgba(0, 0, 0, 0.07);
	--al-dd-count-text: #545454;
	--al-dd-guide-line: rgba(0, 0, 0, 0.10);
	--al-dd-option-text: #111111;
	--al-dd-option-hover-bg: rgba(0, 0, 0, 0.05);
	--al-dd-option-selected-bg: rgba(39, 110, 241, 0.10);
	--al-dd-option-selected-text: #0A0A0A;
	--al-dd-check-color: #276EF1;
	--al-dd-scrollbar-thumb: rgba(0, 0, 0, 0.18);
	--al-dd-scrollbar-hover: rgba(0, 0, 0, 0.32);
}

/* ==========================================================================
   2. NATIVE <select> BASELINE POLISH (PRE-ENHANCEMENT / NO-JS FALLBACK)
   ========================================================================== */
body:not(.wp-admin) select:not([multiple]):not([size]):not([data-al-native-select]):not(#rfq_vertical):not(.autolevo-header-target-select),
body:not(.wp-admin) select[size="1"]:not([multiple]):not([data-al-native-select]):not(#rfq_vertical):not(.autolevo-header-target-select) {
	-webkit-appearance: none;
	appearance: none;
	font-family: var(--al-font-multilingual, 'Roboto', sans-serif);
	border-radius: 10px;
	transition: border-color 150ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Never leak into WordPress admin bar */
#wpadminbar select {
	-webkit-appearance: auto !important;
	appearance: auto !important;
	border-radius: 0 !important;
	box-shadow: none !important;
}

/* ==========================================================================
   3. CUSTOM PROGRESSIVE WRAPPER (.al-select) & NATIVE CONTROL OVERLAY
   ========================================================================== */
.al-select {
	position: relative;
	display: inline-flex;
	align-items: stretch;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	vertical-align: middle;
	font-family: var(--al-font-multilingual, 'Roboto', sans-serif);
	box-sizing: border-box;
}

.al-select.is-compact {
	width: auto;
}

.al-select[hidden] {
	display: none !important;
}

/* Visually hidden native <select> retained in place for form submission, label[for], & validation */
.al-select > select.al-select__native {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	opacity: 0 !important;
	pointer-events: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	min-height: 0 !important;
	min-width: 0 !important;
	z-index: 0 !important;
	background: transparent !important;
	-webkit-appearance: none !important;
	appearance: none !important;
}

/* ==========================================================================
   4. TRIGGER BUTTON (.al-select__trigger)
   ========================================================================== */
.al-select__trigger {
	position: relative;
	z-index: 1;
	width: 100%;
	min-width: 0;
	min-height: 42px;
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding-block: 10px;
	padding-inline-start: 14px;
	padding-inline-end: 12px;
	border-radius: 10px;
	border: 1px solid var(--al-dd-trigger-border);
	background: var(--al-dd-trigger-bg);
	color: var(--al-dd-trigger-text);
	font-family: var(--al-font-multilingual, 'Roboto', sans-serif);
	font-size: 0.9375rem;
	font-weight: 400;
	line-height: 1.35;
	text-align: start;
	cursor: pointer;
	user-select: none;
	box-sizing: border-box;
	box-shadow: none;
	transition:
		border-color 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
		background-color 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
		box-shadow 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
		color 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.al-select__trigger:hover {
	border-color: var(--al-dd-trigger-border-hover);
	background: var(--al-dd-trigger-hover-bg);
}

.al-select__trigger:focus {
	outline: none;
}

.al-select__trigger:focus-visible,
.al-select.is-open .al-select__trigger {
	outline: none;
	border-color: #276EF1;
	box-shadow: 0 0 0 3px rgba(39, 110, 241, 0.35);
}

.al-select.is-invalid .al-select__trigger {
	border-color: var(--al-status-danger, #EF4444);
}

.al-select.is-invalid .al-select__trigger:focus-visible,
.al-select.is-invalid.is-open .al-select__trigger {
	border-color: var(--al-status-danger, #EF4444);
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.28);
}

.al-select__value {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: inherit;
}

.al-select__value.is-placeholder {
	color: var(--al-dd-trigger-placeholder);
}

.al-select__chevron {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--al-dd-chevron-color);
	transition:
		transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
		color 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.al-select__chevron svg {
	width: 14px;
	height: 14px;
	display: block;
}

.al-select.is-open .al-select__chevron {
	transform: rotate(180deg);
	color: #276EF1;
}

.al-select.is-disabled .al-select__trigger {
	opacity: 0.52;
	cursor: not-allowed;
	pointer-events: none;
}

/* ==========================================================================
   5. CONTEXT & DENSITY VARIANTS
   ========================================================================== */

/* Compact inline bar selects (radius, sort, store filters, inline currency) */
.al-select.is-compact .al-select__trigger {
	min-height: 36px;
	padding-block: 6px;
	padding-inline-start: 12px;
	padding-inline-end: 10px;
	font-size: 0.84rem;
	font-weight: 500;
	gap: 7px;
	border-radius: 10px;
}

.al-select.is-compact .al-select__chevron {
	width: 14px;
	height: 14px;
}

.al-select.is-compact .al-select__chevron svg {
	width: 12px;
	height: 12px;
}

/* Directory hero filter bar cells (seamless recessed bar integration) */
.autolevo-hero-filter-cell > .al-select,
.al-select.is-hero-cell {
	width: 100%;
	height: 100%;
}

.al-select.is-hero-cell .al-select__trigger {
	min-height: 44px;
	height: 100%;
	padding-block: 10px;
	padding-inline-start: 12px;
	padding-inline-end: 10px;
	background: transparent;
	border-color: transparent;
	border-radius: 8px;
	font-size: 0.9rem;
	font-weight: 500;
	box-shadow: none;
}

.al-select.is-hero-cell .al-select__trigger:hover {
	background: rgba(255, 255, 255, 0.06);
	border-color: transparent;
}

html[data-theme="light"] .al-select.is-hero-cell .al-select__trigger:hover {
	background: rgba(0, 0, 0, 0.04);
}

.al-select.is-hero-cell.is-open .al-select__trigger,
.al-select.is-hero-cell .al-select__trigger:focus-visible {
	background: rgba(255, 255, 255, 0.07);
	border-color: rgba(39, 110, 241, 0.55);
	box-shadow: 0 0 0 2px rgba(39, 110, 241, 0.25);
}

html[data-theme="light"] .al-select.is-hero-cell.is-open .al-select__trigger,
html[data-theme="light"] .al-select.is-hero-cell .al-select__trigger:focus-visible {
	background: rgba(39, 110, 241, 0.06);
}

.autolevo-hero-filter-cell--sort .al-select.is-hero-cell .al-select__trigger {
	font-weight: 600;
}

/* Request Hub leading search icon spacing */
.autolevo-hub-search-field .al-select .al-select__trigger {
	min-height: 46px;
	padding-inline-start: 40px;
}

/* ==========================================================================
   6. FLOATING GLASSMORPHIC POPOVER MENU (.al-select__popover)
   ========================================================================== */
.al-select__popover {
	position: fixed;
	z-index: 100050;
	margin: 0;
	padding: 6px;
	border-radius: 12px;
	border: 1px solid var(--al-dd-popover-border);
	background: var(--al-dd-popover-bg);
	-webkit-backdrop-filter: blur(16px) saturate(180%);
	backdrop-filter: blur(16px) saturate(180%);
	box-shadow: var(--al-dd-popover-shadow);
	color: var(--al-dd-option-text);
	font-family: var(--al-font-multilingual, 'Roboto', sans-serif);
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	opacity: 0;
	transform: translateY(-4px) scale(0.985);
	transform-origin: top center;
	pointer-events: none;
	transition:
		opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
		transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
	.al-select__popover {
		background: var(--al-dd-popover-fallback);
	}
}

.al-select__popover.is-placement-top {
	transform: translateY(4px) scale(0.985);
	transform-origin: bottom center;
}

.al-select__popover.is-visible {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* Top borderless search filter inside long dropdowns (> 10 options) */
.al-select__search-wrap {
	position: relative;
	flex: 0 0 auto;
	border-bottom: 1px solid var(--al-dd-search-border);
	margin-bottom: 4px;
	padding-bottom: 4px;
}

.al-select__search-icon {
	position: absolute;
	top: 50%;
	inset-inline-start: 10px;
	transform: translateY(-58%);
	width: 14px;
	height: 14px;
	color: var(--al-dd-chevron-color);
	pointer-events: none;
}

.al-select__search {
	width: 100%;
	min-height: 36px;
	padding-block: 6px;
	padding-inline-start: 32px;
	padding-inline-end: 10px;
	border: 1.5px solid transparent !important;
	border-radius: 8px !important;
	background: transparent !important;
	color: var(--al-dd-option-text) !important;
	font-family: inherit;
	font-size: 0.875rem;
	line-height: 1.35;
	box-shadow: none !important;
	outline: none !important;
	box-sizing: border-box;
	transition: border-color 140ms ease, background-color 140ms ease;
}

.al-select__search::placeholder {
	color: var(--al-dd-trigger-placeholder);
}

.al-select__popover .al-select__search:focus {
	border: 1.5px solid #276EF1 !important;
	background: var(--al-dd-option-hover-bg) !important;
	box-shadow: none !important;
	outline: none !important;
}

/* Scrollable options container */
.al-select__list {
	flex: 1 1 auto;
	max-height: 292px;
	overflow-y: auto;
	overflow-x: hidden;
	overscroll-behavior: contain;
	padding: 0;
	margin: 0;
	list-style: none;
}

@supports not selector(::-webkit-scrollbar) {
	.al-select__list {
		scrollbar-width: thin;
		scrollbar-color: var(--al-dd-scrollbar-thumb) transparent;
	}
}

.al-select__list::-webkit-scrollbar {
	width: 6px;
}

.al-select__list::-webkit-scrollbar-button,
.al-select__list::-webkit-scrollbar-button:single-button,
.al-select__list::-webkit-scrollbar-button:vertical:increment,
.al-select__list::-webkit-scrollbar-button:vertical:decrement {
	display: none;
	width: 0;
	height: 0;
}

.al-select__list::-webkit-scrollbar-track {
	background: transparent;
}

.al-select__list::-webkit-scrollbar-thumb {
	background: var(--al-dd-scrollbar-thumb);
	border-radius: 9999px;
}

.al-select__list::-webkit-scrollbar-thumb:hover {
	background: var(--al-dd-scrollbar-hover);
}

/* Collapsible accordion group headings (<optgroup>) */
.al-select__group {
	list-style: none;
	margin: 2px 0;
	padding: 0;
}

.al-select__option + .al-select__group,
.al-select__group + .al-select__group {
	border-top: 1px solid var(--al-dd-group-border);
	padding-top: 3px;
}

.al-select__group-trigger {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	min-height: 40px;
	padding-block: 8px;
	padding-inline: 10px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--al-dd-group-text);
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.3;
	text-align: start;
	cursor: pointer;
	user-select: none;
	transition: background-color 120ms ease, color 120ms ease;
}

.al-select__group-trigger:hover,
.al-select__group-trigger.is-active {
	background: var(--al-dd-group-hover-bg);
}

.al-select__group-trigger:focus {
	outline: none;
}

.al-select__group-trigger:focus-visible {
	outline: none;
	box-shadow: inset 0 0 0 1.5px #276EF1;
}

.al-select__group.is-expanded > .al-select__group-trigger {
	background: var(--al-dd-group-active-bg);
}

.al-select__group-title-wrap {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	flex: 1 1 auto;
	min-width: 0;
}

.al-select__group-title {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.al-select__group-count {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 20px;
	padding: 0 7px;
	border-radius: 9999px;
	background: var(--al-dd-count-bg);
	color: var(--al-dd-count-text);
	font-size: 0.72rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.al-select__group-chevron {
	flex: 0 0 auto;
	width: 15px;
	height: 15px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--al-dd-chevron-color);
	transition: transform 160ms ease, color 160ms ease;
}

.al-select__group-chevron svg {
	width: 13px;
	height: 13px;
	display: block;
}

.al-select__group.is-expanded > .al-select__group-trigger .al-select__group-chevron {
	transform: rotate(180deg);
	color: #276EF1;
}

/* Smooth accordion expand/collapse via grid-template-rows */
.al-select__group-panel {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows 180ms cubic-bezier(0.2, 0.8, 0.2, 1), padding-top 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.al-select__group.is-expanded > .al-select__group-panel {
	grid-template-rows: 1fr;
	padding-top: 3px;
}

.al-select__group-inner {
	overflow: hidden;
	position: relative;
	padding-inline-start: 14px;
}

.al-select__group-inner::before {
	content: "";
	position: absolute;
	inset-inline-start: 6px;
	top: 4px;
	bottom: 4px;
	width: 1px;
	background: var(--al-dd-guide-line);
	pointer-events: none;
}

.al-select__group-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.al-select__option.is-group-all {
	font-weight: 500;
}

.al-select__group-divider {
	height: 1px;
	margin: 4px 6px;
	background: var(--al-dd-group-border);
	list-style: none;
}

/* Option row (38px-42px) */
.al-select__option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	min-height: 38px;
	padding: 8px 10px;
	border-radius: 8px;
	font-size: 0.9rem;
	font-weight: 400;
	line-height: 1.35;
	color: var(--al-dd-option-text);
	cursor: pointer;
	user-select: none;
	text-align: start;
	transition:
		background-color 110ms ease,
		color 110ms ease;
}

.al-select__option + .al-select__option {
	margin-top: 1px;
}

.al-select__option-label {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
}

.al-select__option.is-active,
.al-select__option:hover {
	background: var(--al-dd-option-hover-bg);
}

.al-select__option.is-selected {
	background: var(--al-dd-option-selected-bg);
	color: var(--al-dd-option-selected-text);
	font-weight: 600;
}

.al-select__option.is-disabled {
	opacity: 0.42;
	cursor: not-allowed;
	pointer-events: none;
}

.al-select__option-check {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--al-dd-check-color);
	opacity: 0;
	transform: scale(0.85);
	transition: opacity 120ms ease, transform 120ms ease;
}

.al-select__option.is-selected .al-select__option-check {
	opacity: 1;
	transform: scale(1);
}

.al-select__option-check svg {
	width: 14px;
	height: 14px;
	display: block;
}

.al-select__empty {
	padding: 16px 12px;
	text-align: center;
	font-size: 0.85rem;
	color: var(--al-dd-group-color);
}

/* ==========================================================================
   7. UNIFIED CUSTOM POPOVER MENUS (.dropdown-menu OUTSIDE HEADER)
   ========================================================================== */
body:not(.wp-admin) .dropdown-menu:not(.autolevo-lang-menu):not(.autolevo-dropdown-menu) {
	border-radius: 12px !important;
	padding: 6px !important;
	border: 1px solid var(--al-dd-popover-border) !important;
	background: var(--al-dd-popover-bg) !important;
	-webkit-backdrop-filter: blur(16px) saturate(180%);
	backdrop-filter: blur(16px) saturate(180%);
	box-shadow: var(--al-dd-popover-shadow) !important;
	color: var(--al-dd-option-text) !important;
}

body:not(.wp-admin) .dropdown-menu:not(.autolevo-lang-menu):not(.autolevo-dropdown-menu) .dropdown-item {
	border-radius: 8px !important;
	min-height: 38px;
	padding: 8px 10px !important;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--al-dd-option-text) !important;
	transition: background-color 120ms ease, color 120ms ease;
}

body:not(.wp-admin) .dropdown-menu:not(.autolevo-lang-menu):not(.autolevo-dropdown-menu) .dropdown-item:hover,
body:not(.wp-admin) .dropdown-menu:not(.autolevo-lang-menu):not(.autolevo-dropdown-menu) .dropdown-item:focus {
	background: var(--al-dd-option-hover-bg) !important;
	color: var(--al-dd-option-selected-text) !important;
}

body:not(.wp-admin) .dropdown-menu:not(.autolevo-lang-menu):not(.autolevo-dropdown-menu) .dropdown-item.active,
body:not(.wp-admin) .dropdown-menu:not(.autolevo-lang-menu):not(.autolevo-dropdown-menu) .dropdown-item:active {
	background: var(--al-dd-option-selected-bg) !important;
	color: var(--al-dd-option-selected-text) !important;
	font-weight: 600;
}

/* ==========================================================================
   8. REDUCED MOTION SUPPORT
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	.al-select__trigger,
	.al-select__chevron,
	.al-select__popover,
	.al-select__option,
	.al-select__option-check,
	.al-select__group-trigger,
	.al-select__group-chevron,
	.al-select__group-panel {
		transition: none !important;
		animation: none !important;
	}
	.al-select__popover {
		transform: none !important;
	}
}

html[data-a11y-motion="reduce"] .al-select__trigger,
html[data-a11y-motion="reduce"] .al-select__chevron,
html[data-a11y-motion="reduce"] .al-select__popover,
html[data-a11y-motion="reduce"] .al-select__option,
html[data-a11y-motion="reduce"] .al-select__option-check,
html[data-a11y-motion="reduce"] .al-select__group-trigger,
html[data-a11y-motion="reduce"] .al-select__group-chevron,
html[data-a11y-motion="reduce"] .al-select__group-panel {
	transition: none !important;
	animation: none !important;
	transform: none !important;
}
