/* hg-select — select customizado com progressive enhancement.
   O <select> nativo continua no DOM como fonte de verdade (visualmente oculto);
   o gatilho + listbox usam os tokens do design-system v2 (theme-aware). */

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

/* Native oculto acessivelmente (continua sendo a fonte de .value / change) */
.hg-select__native {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Gatilho — espelha o visual do .input do design-system */
.hg-select__trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; text-align: left;
  font-family: var(--font-ui); font-size: 15px; color: var(--fg);
  background: var(--surface-2); border: 1.5px solid var(--mark);
  border-radius: var(--radius-md); padding: 14px 16px; cursor: pointer;
  transition: border-color var(--dur-fast, .15s) var(--ease-out, ease),
              box-shadow var(--dur-base, .2s) var(--ease-out, ease),
              background var(--dur-fast, .15s) var(--ease-out, ease);
}
.hg-select__trigger:hover { background: var(--surface-hover); }
.hg-select__trigger:focus-visible,
.hg-select.is-open .hg-select__trigger {
  outline: none; border-color: var(--primary-text);
  box-shadow: 0 0 0 4px rgba(123,127,232,0.18);
  background: var(--surface);
}

.hg-select__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hg-select__value.is-placeholder { color: var(--fg-3); }

.hg-select__chevron {
  width: 16px; height: 16px; flex-shrink: 0; color: var(--fg-2);
  transition: transform var(--dur-fast, .15s) var(--ease-out, ease);
}
.hg-select.is-open .hg-select__chevron { transform: rotate(180deg); }

/* Listbox — superfície elevada acima do card, com sombra e borda */
.hg-select__listbox {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  max-height: 280px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--mark-subtle);
  border-radius: var(--radius-lg); padding: 6px; margin: 0; list-style: none;
  z-index: 60; box-shadow: var(--shadow-xl, 0 20px 50px rgba(0,0,0,0.5));
}
.hg-select__option {
  padding: 11px 12px; border-radius: var(--radius-sm); font-size: 14.5px;
  color: var(--fg); cursor: pointer;
}
.hg-select__option.is-active { background: rgba(123,127,232,0.16); }
.hg-select__option.is-selected { color: var(--periwinkle-200, #C0C4FF); font-weight: 700; }

/* Variante compacta — selects inline (versão bíblica, filtros, unidades) */
.hg-select--compact { width: auto; display: inline-block; }
.hg-select--compact .hg-select__trigger {
  width: auto; padding: 7px 12px; font-size: 13px; gap: 8px;
  border: 1px solid var(--mark); border-radius: var(--radius-pill);
}
.hg-select--compact .hg-select__chevron { width: 14px; height: 14px; }
.hg-select--compact .hg-select__listbox { left: auto; right: 0; min-width: 168px; }

/* Native controls (date picker, e selects não-melhorados) seguem o tema:
   resolve o ícone preto do calendário e o dropdown branco no modo escuro,
   sem forçar dark no modo claro. */
input[type="date"],
input[type="time"],
select:not(.hg-select__native) { color-scheme: light; }
.theme-dark input[type="date"],
.theme-dark input[type="time"],
.theme-dark select:not(.hg-select__native) { color-scheme: dark; }
