/* ── Faceted Filter Select ────────────────────────────────────────────────── */

/* ── Trigger button — matches .pill aesthetic ─────────────────────────────── */
.fsel-wrap {
  display: inline-flex;
  align-items: center;
}

.fsel-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .14s ease;
  white-space: nowrap;
  user-select: none;
  line-height: 1.4;
}

.fsel-btn:hover,
.fsel-btn[aria-expanded="true"] {
  border-color: var(--teal);
  color: var(--teal);
}

.fsel-btn.fsel-btn--active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

/* Count badge inside the trigger button */
.fsel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 15px;
  padding: 0 4px;
  border-radius: 100px;
  background: rgba(255,255,255,.3);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* Badge when button is NOT active (border-only state, e.g. open but no selection) */
.fsel-btn:not(.fsel-btn--active) .fsel-badge {
  background: var(--teal);
  color: #fff;
}

/* ── Popover — position:fixed, appended to body ───────────────────────────── */
/* Escapes ancestors with overflow:hidden. top/left set by JS on open.        */
.fsel-popover {
  position: fixed;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md), 0 8px 24px rgba(13,33,64,.14);
  z-index: 150;
  display: flex;
  flex-direction: column;
  max-height: 380px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .13s ease, transform .13s ease;
}

.fsel-popover--open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Search input ─────────────────────────────────────────────────────────── */
.fsel-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fsel-search {
  width: 100%;
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .12s;
}

.fsel-search:focus { border-color: var(--teal); }

/* ── Option list ──────────────────────────────────────────────────────────── */
.fsel-body {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 4px 0;
  margin: 0;
  min-height: 0;
}

.fsel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background .1s;
  user-select: none;
  outline: none;
}

.fsel-item:hover { background: var(--teal-muted); }

.fsel-item:focus-visible {
  background: var(--teal-muted);
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

/* "All" item has a slightly heavier separator below it */
.fsel-item--all {
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

/* Custom checkbox */
.fsel-check {
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  flex-shrink: 0;
  position: relative;
  transition: border-color .12s, background .12s;
}

.fsel-item[aria-checked="true"] .fsel-check {
  background: var(--teal);
  border-color: var(--teal);
}

.fsel-item[aria-checked="true"] .fsel-check::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 7px;
  border: 1.5px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* Option label */
.fsel-opt-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Facet count */
.fsel-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Empty / no-match state */
.fsel-empty {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  list-style: none;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.fsel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.fsel-clear {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  padding: 0;
  transition: color .12s;
  line-height: 1;
}

.fsel-clear:hover:not(:disabled) { color: var(--teal-light); }

.fsel-clear:disabled {
  color: var(--border);
  cursor: default;
}

.fsel-done {
  padding: 4px 14px;
  border: 1.5px solid var(--teal);
  border-radius: 5px;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  line-height: 1.4;
}

.fsel-done:hover {
  background: var(--teal-light);
  border-color: var(--teal-light);
}

/* ── Filter chips (createFilterChips) ────────────────────────────────────── */
.fsel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.fsel-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 10px;
  background: var(--teal-muted);
  border: 1px solid var(--teal);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  color: var(--teal);
  white-space: nowrap;
}

.fsel-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--teal);
  padding: 0;
  display: flex;
  align-items: center;
  opacity: .7;
  transition: opacity .12s;
}

.fsel-chip-remove:hover { opacity: 1; }
