/* ══════════════════════════════════════════════════════════════════════
   SELECT-POP — native <select> açılır listesinin yerine geçen tema uyumlu
   liste.

   NEDEN: Chromium açılır listeyi ayrı bir pencerede çizer; o pencere sayfa
   CSS'inin ulaşamadığı bir katmanda oluşturulup birkaç kare siyah bir yüzey
   olarak görünüyor, ardından satırlar boyanınca düzeliyor. `color-scheme`
   ve opak zemin düzeltmeleri bu boyama sırasını değiştirmediği için tek
   kesin çözüm native popup'ı hiç açtırmamak.

   YAKLAŞIM: <select> öğesinin KENDİSİ olduğu gibi kalır — tetikleyici odur,
   dolayısıyla sayfaların mevcut alan stilleri (.uk-select, .gd-form select,
   .dash-input, .form-control …) hiç değişmez. select-pop.js yalnızca
   native popup'ı açan olayları engelleyip aşağıdaki paneli <body>'ye
   portal olarak basar.

   Panel <body> altında position:fixed durur; böylece kartlardaki
   overflow:hidden / transform / backdrop-filter kırpmalarından etkilenmez
   (ipucu motorundaki .uk-tip ile aynı mantık).
   ══════════════════════════════════════════════════════════════════════ */

.selpop {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147482900;              /* .uk-tip (…3000) hemen altı */
  box-sizing: border-box;
  min-width: 120px;
  max-width: min(92vw, 520px);
  padding: 5px;
  margin: 0;
  border-radius: 12px;
  /* OPAK zemin şart: yarı saydam olsaydı aynı "altı boş yüzey" sorunu
     bu sefer bizim panelimizde olurdu. */
  background: #1c1a30;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 18px 44px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.35);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.22) transparent;
  font-family: inherit;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease;
}
.selpop.visible { opacity: 1; transform: none; }
.selpop::-webkit-scrollbar { width: 9px; }
.selpop::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }
.selpop::-webkit-scrollbar-track { background: transparent; }

.selpop-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: rgba(255,255,255,0.88);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selpop-opt + .selpop-opt { margin-top: 1px; }
/* .active = klavye/fare ile üzerinde gezinilen satır */
.selpop-opt.active { background: rgba(255,255,255,0.10); }
/* .selected = <select>'in mevcut değeri */
.selpop-opt.selected { background: rgba(147,104,233,0.24); color: #fff; font-weight: 700; }
.selpop-opt.selected.active { background: rgba(147,104,233,0.34); }
.selpop-opt.disabled { opacity: .45; cursor: not-allowed; }
.selpop-opt .selpop-check { margin-left: auto; flex-shrink: 0; opacity: 0; font-size: 11px; }
.selpop-opt.selected .selpop-check { opacity: 1; }

.selpop-group {
  padding: 8px 10px 4px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
}
.selpop-group + .selpop-opt { margin-top: 0; }

.selpop-empty {
  padding: 14px 10px;
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
}

/* Arama kutusu — yalnızca uzun listelerde gösterilir */
.selpop-search {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: -5px -5px 5px;
  padding: 8px 10px;
  background: inherit;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px 12px 0 0;
}
.selpop-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
}
.selpop-search input::placeholder { color: rgba(255,255,255,0.4); }
.selpop-search input:focus { border-color: rgba(147,104,233,0.6); }

/* ── AÇIK TEMA ─────────────────────────────────────────────────────────
   Sınıf <body>'de olduğu için panel <body> altında kaldığı sürece
   `body.light-theme .selpop` eşleşir. */
body.light-theme .selpop {
  background: #ffffff;
  border-color: rgba(0,0,0,0.10);
  box-shadow: 0 18px 44px rgba(30,27,51,0.16), 0 2px 8px rgba(30,27,51,0.10);
  scrollbar-color: rgba(0,0,0,0.22) transparent;
}
body.light-theme .selpop::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border: 2px solid transparent; background-clip: content-box; }
body.light-theme .selpop-opt { color: #1e293b; }
body.light-theme .selpop-opt.active { background: rgba(0,0,0,0.06); }
body.light-theme .selpop-opt.selected { background: rgba(109,77,196,0.14); color: #3b2a80; }
body.light-theme .selpop-opt.selected.active { background: rgba(109,77,196,0.22); }
body.light-theme .selpop-group { color: rgba(30,41,59,0.5); }
body.light-theme .selpop-empty { color: rgba(30,41,59,0.5); }
body.light-theme .selpop-search { border-bottom-color: rgba(0,0,0,0.08); }
body.light-theme .selpop-search input { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.12); color: #1e293b; }
body.light-theme .selpop-search input::placeholder { color: rgba(30,41,59,0.4); }
body.light-theme .selpop-search input:focus { border-color: rgba(109,77,196,0.55); }

/* Panel açıkken tetikleyici select'in odak halkasını koru */
select.selpop-open { outline: none; }

@media (prefers-reduced-motion: reduce) {
  .selpop { transition: none; transform: none; }
}
