/* Dropdown Menu Component — UI Comprehensive Refactor v2
 * Requires: tokens.css, spacing.css
 * Replaces native <select> for cases needing icons + descriptions.
 *
 * Usage:
 *   <div class="dropdown-menu">
 *     <button class="dropdown-menu__trigger" aria-expanded="false" aria-haspopup="listbox">
 *       <span class="dropdown-menu__trigger-label">Select model…</span>
 *       <svg class="icon dropdown-menu__chevron"><use href="#i-chevron-down"/></svg>
 *     </button>
 *     <ul class="dropdown-menu__panel" role="listbox" hidden>
 *       <li class="dropdown-menu__option" role="option">
 *         <svg class="icon dropdown-menu__option-icon"><use href="#i-cpu"/></svg>
 *         <span class="dropdown-menu__option-label">GPT-4o</span>
 *         <svg class="icon dropdown-menu__check is-hidden"><use href="#i-check"/></svg>
 *       </li>
 *     </ul>
 *   </div>
 *
 * JS toggles: [hidden] on panel, aria-expanded on trigger, .is-active on option.
 */

/* ── Wrapper ── */
.dropdown-menu {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* ── Trigger (looks like form-input + chevron-down) ── */
.dropdown-menu__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-3); /* 10px 12px */
  background: var(--surface-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-base);
  font-size: var(--font-base);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s ease;
  text-align: left;
  line-height: var(--line-base);
}

.dropdown-menu__trigger:hover {
  border-color: var(--border-strong);
}

.dropdown-menu__trigger:focus-visible {
  outline: none;
  border-color: var(--color-brand-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dropdown-menu__trigger[aria-expanded="true"] {
  border-color: var(--color-brand-500);
}

/* ── Trigger label text (truncates if long) ── */
.dropdown-menu__trigger-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Chevron icon (rotates when open) ── */
.dropdown-menu__chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.dropdown-menu__trigger[aria-expanded="true"] .dropdown-menu__chevron {
  transform: rotate(180deg);
}

/* ── Panel (absolute dropdown) ── */
.dropdown-menu__panel {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  list-style: none;
  margin: 0;
  padding: var(--space-1) 0;
  max-height: 280px;
  overflow-y: auto;
}

.dropdown-menu__panel[hidden] {
  display: none;
}

/* ── Option row ── */
.dropdown-menu__option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-sm);          /* 13px — was var(--font-base) 14px; §1 row 15 */
  font-weight: var(--weight-medium);  /* 500 — was unset (400); menu-item role */
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s ease;
  border-radius: 0;
}

.dropdown-menu__option:hover {
  background: var(--surface-hover);
}

.dropdown-menu__option.is-active {
  background: var(--surface-active);
  color: var(--color-brand-500);
}

/* ── Option icon (left of label) ── */
.dropdown-menu__option-icon {
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── Option label (flex-grows) ── */
.dropdown-menu__option-label {
  flex: 1;
}

/* ── Option description (secondary line under label) ── */
.dropdown-menu__option-desc {
  display: block;
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Checkmark (shown when option is selected) ── */
.dropdown-menu__check {
  color: var(--color-brand-500);
  flex-shrink: 0;
}

.dropdown-menu__check.is-hidden {
  visibility: hidden;
}
