/* Go Capitals — Searchable Select enhancement (vanilla, self-contained, CSP-safe).
   Wraps every native <select> with a type-to-filter combobox UI. The native <select>
   stays in the DOM as the form value source (visually hidden); we only mirror its
   value and re-fire its `change` event so all existing JS keeps working. RTL + LTR. */

.ss-root {
  position: relative;
  width: 100%;
  font: inherit;
}

/* The native <select> is kept for form submission + existing JS, hidden visually
   but still focusable-by-script. We do NOT use display:none so labels' `for=` and
   validation focus still resolve to a real element. */
.ss-root > select.ss-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The visible control — mirrors the look of .field select / .form-select. */
.ss-control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: .9em 1.1em;
  border: 1.5px solid var(--line, #e2e2e2);
  border-radius: var(--radius-sm, 12px);
  background: var(--cream, #faf7f2);
  color: var(--ink, #222);
  cursor: pointer;
  transition: .25s var(--ease, ease);
  -webkit-user-select: none;
  user-select: none;
  text-align: start;
  min-height: 1em;
}
/* Compact variant when the original select used the dashboard .form-select / .filters look */
.ss-root.ss-compact .ss-control { padding: .7em 1em; font-size: .88rem; }

.ss-control:hover { border-color: var(--gold, #b57639); }
.ss-root.ss-open .ss-control,
.ss-control:focus {
  outline: none;
  border-color: var(--gold, #b57639);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(181, 118, 57, .12);
}

.ss-value {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ss-value.ss-placeholder { color: var(--muted, #8a8a8a); }

.ss-arrow {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  pointer-events: none;
  transition: transform .2s var(--ease, ease);
  opacity: .65;
}
.ss-root.ss-open .ss-arrow { transform: rotate(180deg); }

/* Disabled native select -> non-interactive control */
.ss-root.ss-disabled .ss-control {
  cursor: not-allowed;
  opacity: .6;
  background: var(--line, #eee);
}

/* Dropdown panel */
.ss-panel {
  position: absolute;
  z-index: 1200;
  inset-inline-start: 0;
  inset-inline-end: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1.5px solid var(--line, #e2e2e2);
  border-radius: var(--radius-sm, 12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .14);
  overflow: hidden;
  display: none;
}
.ss-root.ss-open .ss-panel { display: block; }
/* Flip above when there is no room below */
.ss-root.ss-up .ss-panel { top: auto; bottom: calc(100% + 4px); }

.ss-search-wrap { padding: 8px; border-bottom: 1px solid var(--line, #eee); }
.ss-search {
  width: 100%;
  padding: .55em .9em;
  border: 1.5px solid var(--line, #e2e2e2);
  border-radius: 8px;
  background: var(--cream, #faf7f2);
  font: inherit;
  color: var(--ink, #222);
}
.ss-search:focus { outline: none; border-color: var(--gold, #b57639); background: #fff; }

.ss-list {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  list-style: none;
  margin: 0;
}

.ss-opt {
  padding: .55em .8em;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink, #222);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .92rem;
}
.ss-opt:hover,
.ss-opt.ss-active { background: rgba(181, 118, 57, .12); }
.ss-opt.ss-selected { font-weight: 700; color: var(--gold, #b57639); }
.ss-opt.ss-disabled { color: var(--muted, #9a9a9a); cursor: not-allowed; opacity: .6; }
.ss-opt.ss-disabled:hover { background: transparent; }

/* <optgroup> heading */
.ss-group {
  padding: .5em .8em .25em;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted, #8a8a8a);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.ss-empty {
  padding: .8em;
  text-align: center;
  color: var(--muted, #8a8a8a);
  font-size: .88rem;
}

/* The matched substring inside an option, highlighted while filtering. */
.ss-opt mark {
  background: rgba(181, 118, 57, .28);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
