/* Custom dropdown component — renders via custom_select() helper,
   wired by assets/js/components/custom-select.js.
   Auto-inits any .custom-select on the page. */

.custom-select {
	position: relative;
	width: 100%;
}

.custom-select-trigger {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.875rem 1rem;
	background: var(--bg-field);
	border: 0.0625rem solid var(--border-field);
	border-radius: 0.75rem;
	color: #fff;
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	cursor: pointer;
	transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

[data-theme="light"] .custom-select-trigger {
	color: var(--text-primary);
}

.custom-select-trigger:hover {
	border-color: rgba(var(--gold-rgb), 0.55);
}

.custom-select.is-open .custom-select-trigger {
	border-color: var(--gold);
	box-shadow: 0 0 0 0.1875rem rgba(var(--gold-rgb), 0.18);
}

.custom-select.is-invalid .custom-select-trigger {
	border-color: #e35b5b;
	box-shadow: 0 0 0 0.1875rem rgba(227, 91, 91, 0.2);
}

.custom-select-value {
	flex: 1;
	text-align: left;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.custom-select-value.is-placeholder {
	color: var(--text-label);
	font-weight: 500;
}

.custom-select-caret {
	color: var(--gold-text);
	font-size: 1.25rem;
	transition: transform 0.2s;
	flex-shrink: 0;
}

/* Light theme: brand gold is too faint on the field fill */
[data-theme="light"] .custom-select-caret {
	color: #8a6508;
}

.custom-select.is-open .custom-select-caret {
	transform: rotate(180deg);
}

/* The panel sits on cards that share its colour, so it's lifted a step (a faint
   white wash over the card colour), outlined with the input border and given a
   deeper shadow — otherwise the open list blends into the card behind it. */
.custom-select-panel {
	position: absolute;
	top: calc(100% + 0.375rem);
	left: 0;
	right: 0;
	background-color: var(--bg-card);
	background-image: linear-gradient(rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.035));
	border: 0.0625rem solid var(--border-input);
	border-radius: 0.75rem;
	box-shadow: 0 0.875rem 2.25rem rgba(0, 0, 0, 0.6), 0 0 0 0.0625rem rgba(0, 0, 0, 0.35);
	padding: 0.375rem;
	display: none;
	z-index: 50;
	overflow-y: auto;
	/* Space reserved for the scrollbar, so rows don't shift when it appears. */
	scrollbar-gutter: stable;
	/* scrollbar-color is inherited: a scrolling ancestor that sets it (modal body,
	   drawer) would otherwise hand it down, and any non-auto value makes Chromium
	   drop the ::-webkit-scrollbar styling below. Reset so every dropdown matches. */
	scrollbar-color: auto;
	scrollbar-width: auto;
}

/* Thin gold scrollbar. Chromium/Safari use the ::-webkit-* rules below (which
   also hide the arrow buttons); the standard properties are scoped to browsers
   without them, because setting them makes Chromium ignore ::-webkit-scrollbar. */
@supports not selector(::-webkit-scrollbar) {
	.custom-select-panel {
		scrollbar-width: thin;
		scrollbar-color: rgba(var(--gold-rgb), 0.45) transparent;
	}
}

.custom-select-panel::-webkit-scrollbar-button {
	display: none;
}

.custom-select-panel::-webkit-scrollbar {
	width: 0.375rem;
}

.custom-select-panel::-webkit-scrollbar-track {
	background: transparent;
	margin: 0.625rem 0; /* keep the thumb clear of the rounded corners */
}

.custom-select-panel::-webkit-scrollbar-thumb {
	background: rgba(var(--gold-rgb), 0.45);
	border-radius: 62.4375rem;
}

.custom-select-panel::-webkit-scrollbar-thumb:hover {
	background: rgba(var(--gold-rgb), 0.7);
}

.custom-select.open-up .custom-select-panel {
	top: auto;
	bottom: calc(100% + 0.375rem);
}

[data-theme="light"] .custom-select-panel {
	background-color: var(--bg-card);
	background-image: none;
	box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.14), 0 0 0 0.0625rem rgba(0, 0, 0, 0.02);
}

.custom-select.is-open .custom-select-panel {
	display: block;
	animation: custom-select-pop 0.15s ease-out;
}

@keyframes custom-select-pop {
	from { opacity: 0; transform: translateY(-0.25rem); }
	to   { opacity: 1; transform: translateY(0); }
}

.custom-select-search {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 0.625rem;
	margin: 0 0 0.25rem;
	border-bottom: 0.0625rem solid var(--border-subtle);
	color: var(--text-secondary);
}

.custom-select-search iconify-icon {
	font-size: 1rem;
	flex-shrink: 0;
}

.custom-select-search-input {
	flex: 1;
	background: none;
	border: none;
	outline: none;
	color: var(--text-primary);
	font-family: inherit;
	font-size: 0.875rem;
	padding: 0.25rem 0;
}

.custom-select-option {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	width: 100%;
	text-align: left;
	padding: 0.625rem 0.875rem;
	background-color: transparent;
	border: none;
	border-radius: 0.5rem;
	color: #fff;
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.12s, color 0.12s;
}

/* Inset divider between options, drawn as a background line (not a border) so
   the rounded hover/selected fill isn't cut by it. A highlighted row drops its
   own line so the fill reads as one clean block. */
.custom-select-option + .custom-select-option {
	background-image: linear-gradient(var(--border-subtle), var(--border-subtle));
	background-size: calc(100% - 1.75rem) 0.0625rem;
	background-position: center top;
	background-repeat: no-repeat;
}

.custom-select-option:hover,
.custom-select-option.is-active,
.custom-select-option.is-selected,
.custom-select-option:hover + .custom-select-option,
.custom-select-option.is-active + .custom-select-option,
.custom-select-option.is-selected + .custom-select-option {
	background-image: none;
}

[data-theme="light"] .custom-select-option {
	color: var(--text-primary);
}

.custom-select-option[hidden] { display: none; }

.custom-select-option-icon {
	font-size: 1.125rem;
	flex-shrink: 0;
}

.custom-select-option-img {
	width: 1.375rem;
	height: 1.375rem;
	flex-shrink: 0;
	object-fit: contain;
	border-radius: 0.25rem;
	background: #fff;
	padding: 0.0625rem;
}

.custom-select-option-label {
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Hover / keyboard focus: neutral tint. Gold is reserved for the selected option,
   so the two states are never confused. */
.custom-select-option:hover,
.custom-select-option.is-active {
	background-color: rgba(255, 255, 255, 0.07);
}

[data-theme="light"] .custom-select-option:hover,
[data-theme="light"] .custom-select-option.is-active {
	background-color: rgba(0, 0, 0, 0.05);
}

.custom-select-option.is-selected {
	background-color: rgba(var(--gold-rgb), 0.12);
	color: var(--gold-text);
	padding-right: 2.25rem; /* room for the check mark */
}

.custom-select-option.is-selected:hover,
.custom-select-option.is-selected.is-active {
	background-color: rgba(var(--gold-rgb), 0.18);
}

/* Light theme: brand gold on a pale tint is unreadable (~1.6:1), so the selected
   text, bar and check use a deep gold (~5:1 on the tint). */
[data-theme="light"] .custom-select-option.is-selected {
	background-color: rgba(var(--gold-rgb), 0.16);
	color: #8a6508;
}

[data-theme="light"] .custom-select-option.is-selected:hover,
[data-theme="light"] .custom-select-option.is-selected.is-active {
	background-color: rgba(var(--gold-rgb), 0.24);
}

/* Check mark on the selected option (drawn with borders — no icon dependency). */
.custom-select-option.is-selected::after {
	content: '';
	position: absolute;
	right: 0.9375rem;
	top: 50%;
	width: 0.3125rem;
	height: 0.625rem;
	border: solid currentColor;
	border-width: 0 0.125rem 0.125rem 0;
	transform: translateY(-65%) rotate(45deg);
}

.custom-select-option.is-selected::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0.375rem;
	bottom: 0.375rem;
	width: 0.1875rem;
	border-radius: 0 0.125rem 0.125rem 0;
	background: var(--gold);
}

/* Size variants */
.custom-select--sm .custom-select-trigger {
	padding: 0.625rem 0.875rem;
	font-size: 0.8125rem;
}

.custom-select--lg .custom-select-trigger {
	padding: 1rem 1.125rem;
	font-size: 1rem;
}
