/* =============================================================
   GK-SELECT  ·  closed-select look + the searchable panel
   -------------------------------------------------------------
   Pairs with dist/js/gk-select.js. The <select> stays a native
   element; this sheet only restyles its box (a drawn chevron in
   place of the browser arrow) and styles the panel that replaces
   its popup. Tokens come from variables.css / theme.css, so the
   dark theme follows without extra rules except the chevron,
   which is an image and cannot read a CSS variable.
   ============================================================= */

/* ---------------------------------------------------------------
   CLOSED SELECT  ·  .form-control selects only (1006 of 1041).
   Bare selects keep the browser's look — their layouts were
   never designed around a drawn arrow.
   --------------------------------------------------------------- */
select.form-control:not([multiple]):not([size]),
select.form-control[size="1"]:not([multiple]) {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 14px 14px;
  background-position: left .7rem center;      /* RTL: arrow on the left */
  padding-left: 2rem;
  cursor: pointer;
  text-overflow: ellipsis;
}
/* LTR selects (baseLTR pages, or dir="ltr" on the control) */
select.form-control[dir="ltr"]:not([multiple]),
[dir="ltr"] select.form-control:not([dir="rtl"]):not([multiple]) {
  background-position: right .7rem center;
  padding-left: .75rem;
  padding-right: 2rem;
}

select.form-control:not([multiple]):hover:not(:disabled) {
  border-color: #c3cad6;
}

/* open: the chevron flips and the box keeps its focus ring while the
   focus itself sits in the panel's search field */
select.form-control.gk-select-open,
select.form-control.gk-select-open:hover {
  border-color: var(--primary, #007bff);
  box-shadow: var(--shadow-focus, 0 0 0 3px rgba(0, 123, 255, .2));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23007bff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 15l6-6 6 6'/%3E%3C/svg%3E");
}

select.form-control:disabled {
  cursor: not-allowed;
  opacity: .8;
}

/* the dropdown's own option styling for the (rare) native popup that
   still appears — multiple/size lists — keeps its readable size */
select.form-control option { color: var(--text-primary, #2b3445); }

:root[data-theme="dark"] select.form-control:not([multiple]) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a7b0be' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] select.form-control:not([multiple]):hover:not(:disabled) {
  border-color: #3a4254;
}
:root[data-theme="dark"] select.form-control option {
  background: var(--surface, #1b1f29);
}

/* ---------------------------------------------------------------
   PANEL
   --------------------------------------------------------------- */
.gk-sel-panel {
  position: fixed;
  z-index: 2050;                       /* over navbar, modals (1050), SweetAlert (1060) */
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--surface, #fff);
  color: var(--text-primary, #2b3445);
  border: 1px solid var(--border-color, #e6e9ef);
  border-radius: var(--radius-medium, 10px);
  box-shadow: var(--shadow-large, 0 12px 32px rgba(16, 24, 40, .12));
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  text-align: start;
  animation: gk-sel-in 120ms var(--ease-out, cubic-bezier(.16, 1, .3, 1));
  transform-origin: top center;
}
.gk-sel-panel.is-above { transform-origin: bottom center; }
.gk-sel-panel *,
.gk-sel-panel *::before,
.gk-sel-panel *::after { box-sizing: border-box; }

/* search box */
.gk-sel-search {
  position: relative;
  flex: none;
  padding: 10px;
  border-bottom: 1px solid var(--border-color, #e6e9ef);
}
.gk-sel-search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 22px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--text-muted, #9aa4b2);
  stroke-width: 2.2;
  stroke-linecap: round;
  pointer-events: none;
}
.gk-sel-panel .gk-sel-input {
  display: block;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 12px;
  padding-inline-start: 38px;
  border: 1px solid var(--border-color, #e6e9ef);
  border-radius: var(--radius-small, 6px);
  background: var(--surface, #fff);
  color: var(--text-primary, #2b3445);
  font: inherit;
  font-size: 16px;                     /* 16px+ keeps iOS from zooming in */
  box-shadow: none;
  outline: 0;
  transition: border-color var(--speed-fast, 120ms) var(--ease, ease),
              box-shadow var(--speed-fast, 120ms) var(--ease, ease);
}
.gk-sel-panel .gk-sel-input:focus {
  border-color: var(--primary, #007bff);
  box-shadow: var(--shadow-focus, 0 0 0 3px rgba(0, 123, 255, .2));
}
.gk-sel-panel .gk-sel-input::placeholder { color: var(--text-muted, #9aa4b2); }

/* options */
.gk-sel-list {
  position: relative;                  /* offsetTop of options is measured from here */
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color, #cfd6e0) transparent;
}
.gk-sel-list::-webkit-scrollbar { width: 8px; }
.gk-sel-list::-webkit-scrollbar-thumb {
  background: var(--border-color, #cfd6e0);
  border-radius: 8px;
}
.gk-sel-list[hidden] { display: none; }

.gk-sel-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-small, 6px);
  cursor: pointer;
  user-select: none;
}
.gk-sel-opt + .gk-sel-opt { margin-top: 1px; }
.gk-sel-opt[hidden],
.gk-sel-group[hidden] { display: none; }

.gk-sel-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.gk-sel-blank .gk-sel-text { color: var(--text-muted, #9aa4b2); }

.gk-sel-check {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  visibility: hidden;
}

.gk-sel-opt.is-active {
  background: var(--surface-hover, #eef4ff);
}
.gk-sel-opt[aria-selected="true"] {
  color: var(--primary, #007bff);
  font-weight: 600;
}
.gk-sel-opt[aria-selected="true"] .gk-sel-check { visibility: visible; }
.gk-sel-opt[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
}
.gk-sel-opt[aria-disabled="true"].is-active { background: transparent; }

.gk-sel-group {
  padding: 10px 12px 4px;
  color: var(--text-muted, #9aa4b2);
  font-size: 13px;
  font-weight: 700;
  cursor: default;
}

.gk-sel-empty {
  padding: 18px 12px;
  color: var(--text-muted, #9aa4b2);
  font-size: 15px;
  text-align: center;
}
.gk-sel-empty[hidden] { display: none; }

/* touch screens get finger-sized rows */
@media (pointer: coarse) {
  .gk-sel-opt { min-height: 46px; }
}

/* ---------------------------------------------------------------
   PHONE  ·  bottom sheet instead of an anchored dropdown
   --------------------------------------------------------------- */
.gk-sel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2049;
  background: rgba(15, 23, 42, .45);
  animation: gk-sel-fade 160ms ease;
}
.gk-sel-panel.is-sheet {
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  max-height: 75vh;
  border-radius: 16px 16px 0 0;
  border-bottom: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: gk-sel-up 200ms var(--ease-out, cubic-bezier(.16, 1, .3, 1));
}
.gk-sel-panel.is-sheet::before {           /* grab handle */
  content: "";
  display: block;
  flex: none;
  width: 40px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 4px;
  background: var(--border-color, #cfd6e0);
}
.gk-sel-panel.is-sheet .gk-sel-opt { min-height: 48px; }

@keyframes gk-sel-in   { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes gk-sel-up   { from { transform: translateY(100%); } to { transform: none; } }
@keyframes gk-sel-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .gk-sel-panel,
  .gk-sel-panel.is-sheet,
  .gk-sel-backdrop { animation: none; }
}

@media print {
  .gk-sel-panel,
  .gk-sel-backdrop { display: none !important; }
  select.form-control:not([multiple]) { background-image: none !important; }
}
