/* FILE: css/select-ui.css — themed dropdowns (loaded last). Pairs with js/select-ui.js */

/* ---------- The real <select> stays in the DOM, invisible ---------- */
html select.su-native {
  position: absolute !important;
  width: 1px !important; height: 1px !important; min-height: 0 !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important;
  opacity: 0 !important; pointer-events: none !important;
  overflow: hidden !important; clip: rect(0 0 0 0) !important;
  background-image: none !important;
}

/* ---------- Trigger button (takes the select's own Tailwind classes) ---------- */
.su-trigger {
  display: inline-flex; align-items: center; justify-content: space-between; gap: .5rem;
  min-width: 0; text-align: left; cursor: pointer;
  color: #0f172a;
  border-radius: 12px !important;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .18s ease, box-shadow .22s var(--pm-ease, ease), background-color .18s ease;
}
.su-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.su-chev { flex: none; width: 16px; height: 16px; color: #64748b; transition: transform .2s var(--pm-ease, ease); }
.su-trigger[aria-expanded="true"] .su-chev { transform: rotate(180deg); color: #0d9488; }
.su-trigger.su-placeholder .su-label { color: #94a3b8; }
.su-trigger:hover:not(:disabled) { border-color: #94a3b8; }
.su-trigger:focus-visible,
.su-trigger[aria-expanded="true"] {
  outline: none !important; border-color: #14b8a6 !important;
  box-shadow: var(--pm-ring, 0 0 0 4px rgba(20, 184, 166, .16)) !important;
}
.su-trigger:disabled { opacity: .55; cursor: not-allowed; }
.su-trigger.su-invalid { border-color: #f43f5e !important; box-shadow: 0 0 0 3px rgba(244, 63, 94, .12); }
@media (max-width: 639px) {
  .app-modal .su-trigger { font-size: 16px !important; min-height: 46px; }
}
html.dark .su-trigger { color: #e2e8f0; background-color: #0f1729; }
html.dark .su-trigger:hover:not(:disabled) { border-color: #475569 !important; }
html.dark .su-chev { color: #93a1b8; }
html.dark .su-trigger.su-placeholder .su-label { color: #5b6b85; }

/* ---------- Overlay root ---------- */
.su-root { position: fixed; inset: 0; z-index: 200; display: none; }
.su-root.su-on { display: block; }
.su-backdrop {
  position: absolute; inset: 0; touch-action: none;
  background: rgba(11, 27, 58, .5); opacity: 0; transition: opacity .2s ease;
}
.su-root.su-open .su-backdrop { opacity: 1; }

.su-panel {
  position: absolute; display: flex; flex-direction: column; outline: none;
  background: #fff; color: #0f172a;
  font-family: Inter, system-ui, -apple-system, sans-serif;
}
.su-list { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* ---------- Phone / touch: bottom sheet ---------- */
.su-sheet .su-panel {
  left: 0; right: 0; bottom: 0; margin: 0 auto; width: 100%; max-width: 520px;
  max-height: min(76vh, calc(var(--app-vh, 100dvh) - 40px));
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px -20px rgba(11, 27, 58, .45);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%);
  transition: transform .28s var(--pm-ease, cubic-bezier(.16, 1, .3, 1));
}
.su-sheet.su-open .su-panel { transform: none; }
.su-grab { flex: none; width: 38px; height: 4px; margin: 10px auto 0; border-radius: 4px; background: #cbd5e1; touch-action: none; }
.su-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 8px 20px; touch-action: none; }
.su-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.005em; color: #0f172a; }
.su-x {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; background: transparent; color: #94a3b8; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.su-x svg { width: 18px; height: 18px; }
.su-x:hover { background: #f1f5f9; color: #475569; }

.su-search { position: relative; flex: none; margin: 0 16px 8px; }
.su-search-ico { position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: #94a3b8; pointer-events: none; }
.su-input {
  width: 100%; height: 44px; padding: 0 12px 0 38px; border-radius: 12px !important;
  border: 1px solid #e2e8f0; background: #f8fafc; color: #0f172a; font-size: 16px;
}
.su-input:focus { outline: none; background: #fff; border-color: #14b8a6; box-shadow: var(--pm-ring, 0 0 0 4px rgba(20, 184, 166, .16)); }

.su-list { padding: 4px 10px 14px; }

.su-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 0 14px;
  border: 0; border-radius: 12px; background: transparent; color: inherit;
  font: inherit; font-size: 15.5px; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .12s ease;
}
.su-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.su-tick { flex: none; width: 18px; height: 18px; color: #0d9488; opacity: 0; transform: scale(.6); transition: opacity .15s ease, transform .2s var(--pm-ease, ease); }
.su-row.su-active { background: #f1f5f9; }
.su-row[aria-selected="true"] { background: rgba(20, 184, 166, .11); color: #0f766e; font-weight: 600; }
.su-row[aria-selected="true"] .su-tick { opacity: 1; transform: none; }
.su-row:active:not(:disabled) { background: rgba(20, 184, 166, .16); }
.su-row:disabled { opacity: .4; cursor: not-allowed; }
.su-group { padding: 12px 14px 4px; font-size: 12px; font-weight: 600; color: #64748b; letter-spacing: .01em; }
.su-empty { padding: 26px 14px; text-align: center; font-size: 14px; color: #94a3b8; }

/* ---------- Desktop / mouse: popover under the field ---------- */
.su-pop .su-backdrop { background: transparent; }
.su-pop .su-panel {
  border-radius: 14px; border: 1px solid #e2e8f0;
  box-shadow: 0 24px 60px -20px rgba(11, 27, 58, .38), 0 4px 14px -6px rgba(11, 27, 58, .12);
  opacity: 0; transform: translateY(-4px) scale(.98);
  transition: opacity .14s ease, transform .18s var(--pm-ease, ease);
}
.su-pop.su-open .su-panel { opacity: 1; transform: none; }
.su-pop .su-grab, .su-pop .su-head { display: none; }
.su-pop .su-search { margin: 8px 8px 4px; }
.su-pop .su-input { height: 38px; font-size: 14px; }
.su-pop .su-list { padding: 6px; }
.su-pop .su-row { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.su-pop .su-group { padding: 10px 12px 3px; font-size: 11.5px; }

/* ---------- Dark ---------- */
html.dark .su-panel { background: #131b2c; color: #e2e8f0; }
html.dark .su-sheet .su-panel { box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, .7); border-top: 1px solid #232d42; }
html.dark .su-pop .su-panel { border-color: #232d42; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .7); }
html.dark .su-backdrop { background: rgba(3, 6, 14, .62); }
html.dark .su-grab { background: #2e3a52; }
html.dark .su-title { color: #eef2f7; }
html.dark .su-x { color: #74839c; }
html.dark .su-x:hover { background: #1f2a3f; color: #cbd5e1; }
html.dark .su-search-ico { color: #74839c; }
html.dark .su-input { background: #0f1729; border-color: #2e3a52; color: #e2e8f0; }
html.dark .su-input:focus { background: #0f1729; border-color: #14b8a6; }
html.dark .su-row.su-active { background: #182234; }
html.dark .su-row[aria-selected="true"] { background: rgba(20, 184, 166, .16); color: #5eead4; }
html.dark .su-row:active:not(:disabled) { background: rgba(20, 184, 166, .22); }
html.dark .su-tick { color: #5eead4; }
html.dark .su-group { color: #93a1b8; }
html.dark .su-empty { color: #74839c; }

@media (prefers-reduced-motion: reduce) {
  .su-panel, .su-backdrop, .su-chev, .su-tick { transition: none !important; }
}
