/* ──────────────────────────────────────────────────────────────────
 *  searchable-select.css
 *  Self-contained Tom Select stylesheet.
 *
 *  Design contract — visually IDENTICAL to the project's original
 *  `.company-filter-select` so the dropdown blends with every other
 *  control inside `.filter-bar` and other card containers.
 *
 *  Uses the project's real variable names (the previous version
 *  used `--card`, `--text-1`, `--accent` which DON'T exist here,
 *  so it was always rendering with the hardcoded fallbacks).
 *
 *  Real project tokens:
 *      --surface-2:  #101525   ← input / card background
 *      --surface-3:  #161d2e   ← raised
 *      --border:     #1e2a40   ← faint border (outer card)
 *      --border-2:   #263554   ← subtle visible border (controls)
 *      --blue:       #4f8eff   ← accent
 *      --text:       #c8d8f0
 *      --text-2:     #7a95b8
 *      --text-3:     #3d5570
 *      --r:          10px
 *      --font:       Plus Jakarta Sans
 * ──────────────────────────────────────────────────────────────── */


/* ══════════════════════════════════════════════════════════════════
 *  1. STRUCTURAL — minimum CSS Tom Select needs to function
 * ══════════════════════════════════════════════════════════════════ */

select.tomselected,
select.ts-hidden-accessible {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.ts-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  font: inherit;
  min-width: 180px;
  max-width: 100%;
}

/* Tom Select copies the original <select>'s className onto the
   wrap element. Any styling rules the page applies to those
   classes (e.g. .company-filter-select adds its own border,
   padding, background-image chevron, etc.) bleed through onto
   the wrap and render as a SECOND border outside our .ts-control,
   with a "floating chevron" in the padding gap.

   Defeat the most common patterns. !important is necessary because
   the page's class selectors are usually compound and have
   identical or higher specificity than .ts-wrapper alone. */
.ts-wrapper {
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  padding: 0 !important;
  appearance: auto !important;
  -webkit-appearance: auto !important;
  box-shadow: none !important;
}

.ts-wrapper.full { display: block; }

.ts-control {
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.ts-control .item {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* In single-select mode the inline input would duplicate the
   placeholder next to the selected item. The dropdown_input plugin
   provides search inside the menu instead — so we hide the inline
   input completely. */
.ts-wrapper.single .ts-control > input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Dropdown menu */
.ts-dropdown {
  position: absolute;
  z-index: 2147483647;
  box-sizing: border-box;
  width: 100%;
}
.ts-dropdown .ts-dropdown-content {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.ts-dropdown .option {
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
}
.ts-dropdown [data-disabled],
.ts-dropdown [data-disabled] [data-selectable].option {
  cursor: default;
}
.ts-dropdown .dropdown-input-wrap { position: relative; }
.ts-dropdown .dropdown-input {
  box-sizing: border-box;
  width: 100%;
  font: inherit;
}


/* ══════════════════════════════════════════════════════════════════
 *  2. THEME — clones the project's `.company-filter-select` look
 *           so it blends into `.filter-bar` and other card containers
 * ══════════════════════════════════════════════════════════════════ */

.ts-wrapper .ts-control {
  background: var(--surface-2, #101525);
  color: var(--text, #c8d8f0);
  border: 1px solid var(--border-2, #263554);
  border-radius: 8px;
  padding: 7px 28px 7px 12px;        /* matches .company-filter-select */
  min-height: 36px;
  font-family: var(--font, 'Plus Jakarta Sans', sans-serif);
  font-size: .84rem;
  font-weight: 500;
  transition: border-color .12s, box-shadow .12s;
}

.ts-wrapper .ts-control:hover {
  border-color: var(--blue, #4f8eff);
}

.ts-wrapper.focus .ts-control,
.ts-wrapper.dropdown-active .ts-control {
  border-color: var(--blue, #4f8eff);
  box-shadow: 0 0 0 2px rgba(79, 142, 255, .12);
  outline: none;
}

.ts-wrapper.disabled .ts-control {
  opacity: .55;
  cursor: not-allowed;
}

/* Selected item — no own background/border, just text styling */
.ts-wrapper .ts-control .item {
  color: var(--text, #c8d8f0);
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font-weight: 500;
}

/* Inline input (for the rare case a multi-select sneaks through) */
.ts-wrapper .ts-control > input {
  color: var(--text, #c8d8f0);
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  padding: 0;
  margin: 0;
}
.ts-wrapper .ts-control > input::placeholder {
  color: var(--text-3, #3d5570);
  opacity: 1;
}

/* Chevron — pure CSS triangle. Down by default; switches to up by
   swapping border-top for border-bottom (no rotation = no subpixel
   wobble). Positioned at right of the wrap, lands inside the
   control's right padding. */
.ts-wrapper::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 0;
  height: 0;
  margin-top: -2px;
  border-left:  4px solid transparent;
  border-right: 4px solid transparent;
  border-top:   5px solid var(--text-2, #7a95b8);
  border-bottom: 0 solid transparent;
  pointer-events: none;
  transition: border-top-color .12s, border-bottom-color .12s;
}
.ts-wrapper.dropdown-active::after {
  margin-top: -3px;
  border-top: 0 solid transparent;
  border-bottom: 5px solid var(--blue, #4f8eff);
}

/* Dropdown menu */
.ts-dropdown {
  background: var(--surface-2, #101525);
  color: var(--text, #c8d8f0);
  border: 1px solid var(--border-2, #263554);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,.55), 0 4px 10px rgba(0,0,0,.3);
  margin-top: 6px;
  overflow: hidden;
  font-family: var(--font, 'Plus Jakarta Sans', sans-serif);
}

.ts-dropdown .dropdown-input-wrap {
  padding: 10px;
  background: var(--surface-1, #0b0f1a);
  border-bottom: 1px solid var(--border, #1e2a40);
}

.ts-dropdown .dropdown-input {
  padding: 8px 12px;
  background: var(--surface-2, #101525);
  color: var(--text, #c8d8f0);
  border: 1px solid var(--border-2, #263554);
  border-radius: 6px;
  font-size: .83rem;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.ts-dropdown .dropdown-input::placeholder {
  color: var(--text-3, #3d5570);
  opacity: 1;
}
.ts-dropdown .dropdown-input:focus {
  border-color: var(--blue, #4f8eff);
  box-shadow: 0 0 0 2px rgba(79, 142, 255, .12);
}

.ts-dropdown .ts-dropdown-content {
  padding: 6px 0;
  max-height: min(360px, 60vh);
}

.ts-dropdown .option {
  padding: 9px 14px;
  color: var(--text, #c8d8f0);
  font-size: .85rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid transparent;
  transition: background-color .08s, color .08s;
}
.ts-dropdown .option.active,
.ts-dropdown .option:hover {
  background: var(--blue, #4f8eff);
  color: #fff;
}
.ts-dropdown .option.selected {
  background: rgba(79, 142, 255, .12);
  color: var(--text, #c8d8f0);
  border-left-color: var(--blue, #4f8eff);
  font-weight: 600;
}
.ts-dropdown .option.selected.active {
  background: var(--blue, #4f8eff);
  color: #fff;
}
.ts-dropdown .option[data-disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.ts-dropdown .optgroup-header {
  padding: 8px 14px 4px;
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-3, #3d5570);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.ts-dropdown .no-results {
  padding: 16px 14px;
  text-align: center;
  color: var(--text-3, #3d5570);
  font-size: .85rem;
  font-style: italic;
}


/* ══════════════════════════════════════════════════════════════════
 *  3. LIGHT THEME
 * ══════════════════════════════════════════════════════════════════ */

[data-theme="light"] .ts-wrapper .ts-control {
  background: #fff;
  color: var(--text, #1e2d42);
  border-color: var(--border, #d0daea);
}
[data-theme="light"] .ts-wrapper .ts-control .item {
  color: var(--text, #1e2d42);
}
[data-theme="light"] .ts-wrapper::after {
  border-top-color: #555;
}
[data-theme="light"] .ts-wrapper.dropdown-active::after {
  border-bottom-color: var(--blue, #2563eb);
}

[data-theme="light"] .ts-dropdown {
  background: #fff;
  color: var(--text, #1e2d42);
  border-color: var(--border, #d0daea);
}
[data-theme="light"] .ts-dropdown .option {
  color: var(--text, #1e2d42);
}
[data-theme="light"] .ts-dropdown .dropdown-input-wrap {
  background: #f6f7fa;
  border-color: var(--border, #d0daea);
}
[data-theme="light"] .ts-dropdown .dropdown-input {
  background: #fff;
  color: var(--text, #1e2d42);
  border-color: var(--border, #d0daea);
}


/* ══════════════════════════════════════════════════════════════════
 *  4. MOBILE
 * ══════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .ts-dropdown .ts-dropdown-content { max-height: 50vh; }
  .ts-dropdown .option { padding: 11px 14px; font-size: .92rem; }
  .ts-dropdown .dropdown-input { padding: 10px 12px; font-size: .95rem; }
}
