/**
 * themed-select.css — the look for /js/gen-dropdown.js.
 *
 * The OS renders a native <select> popup that CSS cannot restyle, so every
 * eligible <select> gets an inert twin (kept in the DOM so `.value`,
 * `.selectedOptions` and `change` listeners keep working) plus a visible
 * trigger button and a floating option list that is entirely ours.
 *
 * Colours come from the `--sched-*` tokens when the page defines them and fall
 * back to the Aurora Glass violet so this file is safe to load on any page.
 * `views/dashboard/generation.hbs` ships its own copy of these rules inline —
 * do not load both on one page.
 */

/* The real <select>: visually hidden, still focusable by code, never clickable. */
.gv-dd-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ── Trigger ──────────────────────────────────────────────────────────────── */
/* The trigger copies the <select>'s classes (usually .form-select), so it
   inherits the page's control styling; these rules only fix what that brings. */
.gv-dd-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  /* Kill the browser's own caret image — we draw our own chevron. */
  background-image: none !important;
  padding-right: 30px !important;
}

.gv-dd-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.gv-dd-trigger:focus-visible {
  outline: none;
  border-color: var(--sched-primary, #777777);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

/* The trigger's leading lane — mirrors whichever of icon/dot/emoji the selected
   option carries, so the closed control looks like the row that produced it. */
.gv-dd-trigger-emoji {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  font-size: 1.05em;
  line-height: 1;
}

.gv-dd-trigger-emoji .gv-dd-option-icon {
  flex: 0 0 auto;
  color: inherit;
}

.gv-dd-trigger-emoji .gv-dd-option-dot {
  margin-inline: 2px 0;
}

.gv-dd-trigger-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gv-dd-trigger::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--sched-text-muted, rgba(0, 0, 0, 0.6));
  border-bottom: 1.5px solid var(--sched-text-muted, rgba(0, 0, 0, 0.6));
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
  transition: transform 0.15s ease;
}

.gv-dd-trigger.gv-dd-open::after {
  transform: translateY(-30%) rotate(-135deg);
}

/* ── Floating panel ───────────────────────────────────────────────────────── */
/* Fixed-position and appended to <body> so it escapes modal overflow clipping;
   the JS positions it against the trigger on every open. */
.gv-dd-panel {
  position: fixed;
  display: none;
  z-index: 20000;
  min-width: 200px;
  max-width: min(420px, calc(100vw - 16px));
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface-overlay);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--sched-border, rgba(119, 119, 119, 0.25));
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
}

.gv-dd-panel.gv-dd-open {
  display: block;
  animation: gvDdFadeIn 0.14s ease;
}

@keyframes gvDdFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gv-dd-panel::-webkit-scrollbar { width: 8px; }
.gv-dd-panel::-webkit-scrollbar-track { background: transparent; }
.gv-dd-panel::-webkit-scrollbar-thumb {
  background: var(--scrim);
  border-radius: 4px;
}

/* ── Search box (only when the select opts in with data-dd-search) ────────── */
.gv-dd-search-wrap {
  position: sticky;
  top: -6px;
  z-index: 1;
  padding: 2px 2px 6px;
  margin: -6px -6px 4px;
  padding-inline: 8px;
  padding-top: 8px;
  background: var(--veil-strong);
  border-bottom: 1px solid var(--sched-border, rgba(119, 119, 119, 0.2));
}

.gv-dd-search {
  width: 100%;
  padding: 7px 10px;
  font-size: 0.85rem;
  color: var(--sched-text-primary, #000000);
  background: var(--glass-strong);
  border: 1px solid var(--sched-border, rgba(119, 119, 119, 0.25));
  border-radius: 9px;
}

.gv-dd-search:focus {
  outline: none;
  border-color: var(--sched-primary, #777777);
  background: var(--glass-strong);
}

.gv-dd-search::placeholder { color: var(--ink-muted); }

.gv-dd-empty {
  padding: 14px 10px;
  font-size: 0.82rem;
  text-align: center;
  color: var(--sched-text-muted, rgba(0, 0, 0, 0.55));
}

/* ── Options ──────────────────────────────────────────────────────────────── */
.gv-dd-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--sched-text-secondary, rgba(0, 0, 0, 0.85));
  transition: background 0.12s ease, color 0.12s ease;
}

.gv-dd-option:hover,
.gv-dd-option.gv-dd-active {
  background: var(--scrim-soft);
  color: var(--sched-text-primary, #000000);
}

.gv-dd-option.gv-dd-selected {
  background: var(--scrim-soft);
  color: var(--sched-text-primary, #000000);
}

.gv-dd-option[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Optgroup label — a plain heading, not selectable. */
.gv-dd-group-label {
  padding: 10px 10px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sched-text-muted, rgba(0, 0, 0, 0.5));
}

.gv-dd-option-check {
  flex: 0 0 14px;
  font-size: 0.8rem;
  line-height: 1;
  text-align: center;
  color: var(--sched-primary-light, #575757);
  opacity: 0;
}

.gv-dd-option.gv-dd-selected .gv-dd-option-check { opacity: 1; }

.gv-dd-option-emoji {
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1;
}

/* Bootstrap-icon lane (data-icon). Fixed width so labels line up down the list
   whether an icon is wide (bi-megaphone) or narrow (bi-file-text). */
.gv-dd-option-icon {
  flex: 0 0 18px;
  font-size: 0.95rem;
  line-height: 1;
  text-align: center;
  color: var(--sched-text-muted, rgba(0, 0, 0, 0.55));
}

.gv-dd-option.gv-dd-selected .gv-dd-option-icon,
.gv-dd-option:hover .gv-dd-option-icon,
.gv-dd-option.gv-dd-active .gv-dd-option-icon {
  color: var(--sched-primary-light, #575757);
}

/* Status lane (data-dot) — the colour IS the meaning, so it is set inline from
   the semantic token and never restyled on hover. */
.gv-dd-option-dot {
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  margin-inline: 4px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--glass);
}

/* A row with no second line still has to push its tally to the right edge. */
.gv-dd-option > .gv-dd-option-text {
  flex: 1 1 auto;
  min-width: 0;
}

/* Right-aligned tally (data-count). Tabular figures so the column doesn't
   shimmy as counts change width. */
.gv-dd-option-count {
  flex: 0 0 auto;
  margin-left: auto;
  padding-left: 10px;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  color: var(--sched-text-muted, rgba(0, 0, 0, 0.55));
}

/* Nothing behind this option yet — still shown, but visibly empty. */
.gv-dd-option-count-zero { opacity: 0.45; }

/* Avatar lane — for option lists that represent people/characters. */
.gv-dd-option-avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--sched-border, rgba(119, 119, 119, 0.3));
  background: var(--glass);
}

.gv-dd-option-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gv-dd-option-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

/* Second line: what this option actually does (hook guidance, style look…). */
.gv-dd-option-desc {
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--sched-text-muted, rgba(0, 0, 0, 0.55));
  /* Two lines is enough to be useful without turning the list into prose. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gv-dd-option-badge {
  align-self: flex-start;
  padding: 1px 7px;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--sched-primary-light, #575757);
  background: var(--scrim-soft);
  border: 1px solid rgba(119, 119, 119, 0.28);
  border-radius: 999px;
}

/* ── Per-option sample button (data-dd-sample-url) ────────────────────────── */
.gv-dd-sample-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 0.8rem;
  color: var(--sched-primary-light, #575757);
  background: var(--scrim-soft);
  border: 1px solid rgba(119, 119, 119, 0.3);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}

.gv-dd-sample-btn:hover {
  background: var(--scrim-soft);
  transform: scale(1.08);
}

.gv-dd-sample-btn.gv-dd-sample-loading,
.gv-dd-sample-btn.gv-dd-sample-playing {
  background: var(--sched-primary, #777777);
  color: var(--ink);
}

.gv-dd-sample-btn.gv-dd-sample-loading i {
  animation: gvDdSpin 0.9s linear infinite;
}

@keyframes gvDdSpin {
  to { transform: rotate(360deg); }
}

.gv-dd-sample-btn.gv-dd-sample-error {
  color: #f40000;
  background: rgba(214, 0, 0, 0.16);
  border-color: rgba(214, 0, 0, 0.35);
}
