/* ── Shared filter-system CSS (db-filters.js engine + saved views) ──────────
   Extracted from templates/database.html's inline <style> (2026-07-14,
   pipeline-filter rebuild) so /pipeline can reuse the same engine UI.
   Loaded globally from base.html after app-shell.css. Every selector here is
   namespaced under the engine's own class vocabulary (.db-filterbar, .fcat,
   .facet, .views-bar, …) — the one exception, the wDate preset chips, is
   scoped under .facet so it can't shadow app-shell.css's global .chip. */

/* Top filter bar layout. overflow:visible so category popovers can escape the
   panel's rounded clip. */
.db-filterbar { padding: 12px 14px; margin-bottom: 16px; overflow: visible; }
.db-filterbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.db-namesearch { flex: 0 0 200px; }
.db-catbar { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.db-pillbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.db-pillbar:empty { display: none; }
@media (max-width: 720px) {
  .db-filterbar-row { align-items: stretch; }
  .db-namesearch { flex-basis: 100%; }
}

/* Category button + its dropdown popover (reuses the shared .tbpop base). */
.fcat { position: relative; }
.fcat-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 99px;
  background: var(--glass-bg, var(--bg-2)); border: 1px solid var(--glass-border, var(--line-2));
  -webkit-backdrop-backdrop-color: var(--ink-2); cursor: pointer;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px; font-weight: 600;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.fcat-btn:hover { color: var(--ink); border-color: var(--ink-4); }
.fcat-btn[aria-expanded="true"] { color: var(--ink); border-color: var(--green); }
.fcat-btn.has-active { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.fcat-btn .fcat-caret { font-size: 8px; opacity: 0.6; }
.fcat-btn .fcat-badge {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; background: var(--green); color: #fff;
  font-size: 9px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.fcat-btn.search-hit { border-color: var(--green); color: var(--green); }
.fcat-btn.search-dim { opacity: 0.4; }
.fcat-pop {
  left: 0; right: auto; top: calc(100% + 6px);
  /* width:auto overrides the shared .tbpop fixed 340px so it can't overflow a
     narrow viewport; clamped to the viewport as a hard ceiling. */
  width: auto; min-width: 280px; max-width: min(420px, calc(100vw - 24px));
}
.fcat-pop.fcat-pop--right { left: auto; right: 0; }
.fcat-pop .tbpop-body { max-height: min(60vh, 480px); overflow-y: auto; }
/* Facets read tighter inside a popover than they did in the old rail. */
.fcat-pop .facet { padding: 12px 14px; }
.fcat-pop .facet:first-child { padding-top: 4px; }

.facet { padding: 14px; }
.facet h4 {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); margin-bottom: 10px;
}
.facet + .facet { border-top: 1px solid var(--line); }
.facet-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 3px 0;
  font-size: 12px; color: var(--ink-2);
  cursor: pointer;
  line-height: 1.25;
}
.facet-row:hover { color: var(--ink); }
.facet-row .l {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.facet-row input[type=checkbox] {
  accent-color: var(--green);
  width: 14px; height: 14px; margin: 0;
  flex-shrink: 0;
}
/* Reserve a fixed right gutter on every facet row so checkboxes line up
   vertically even on rows that don't have a count (seniority / function /
   headcount / revenue). The .ct (when present) overlays this gutter and
   right-aligns the number. */
.facet-row .ct {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 10px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  flex-shrink: 0;
  min-width: 22px;
  text-align: right;
}

/* === Filter inputs (extend the .facet language) === */
.filter-search {
  margin-bottom: 12px;
}
.filter-search input {
  width: 100%;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px;
  outline: none; transition: border 0.12s, box-shadow 0.12s;
}
.filter-search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(39,217,124,0.10); }
.filter-search input::placeholder { color: var(--ink-4); }

.filter-input {
  width: 100%;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 6px 8px; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px;
  outline: none; transition: border 0.12s;
}
.filter-input:focus { border-color: var(--green); }
.filter-input::placeholder { color: var(--ink-4); }

.filter-row { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
.filter-row label {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 10px;
  color: var(--ink-3); letter-spacing: 0.04em;
}

.filter-clear {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto; padding: 2px 8px;
  background: transparent; border: 1px solid var(--line-2); border-radius: 4px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 9px; color: var(--ink-3);
  cursor: pointer; transition: all 0.12s;
}
.filter-clear:hover { border-color: var(--accent); color: var(--accent); }

.facet h4 .clear-btn {
  float: right;
  font-size: 9px; color: var(--ink-4);
  background: none; border: 0; cursor: pointer; padding: 0;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.facet h4 .clear-btn:hover { color: var(--accent); }

.facet-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.facet-toggle .nm { display: flex; align-items: center; gap: 8px; }
.facet-toggle .switch {
  width: 28px; height: 16px; border-radius: 99px;
  background: var(--bg-3); position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}
.facet-toggle .switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink-3); transition: transform 0.15s, background 0.15s;
}
.facet-toggle.on .switch { background: var(--green-soft); }
.facet-toggle.on .switch::after { transform: translateX(12px); background: var(--green); }

/* === Industry/source typeahead (matches the dark/mono Claude Design language) === */
.ind-typeahead { position: relative; }
.ind-pills {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 6px;
}
.ind-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px 2px 8px;
  background: var(--green-soft); border: 1px solid var(--green); border-radius: 99px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 10px; color: var(--green);
  font-weight: 600;
}
.ind-pill .x {
  cursor: pointer; padding: 0 2px;
  color: var(--green); opacity: 0.6;
}
.ind-pill .x:hover { opacity: 1; }

.ind-dropdown {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 8px;
  max-height: 240px; overflow-y: auto; z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.ind-dropdown.show { display: block; }
.ind-option {
  padding: 7px 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px;
  color: var(--ink-2); cursor: pointer;
  transition: background 0.08s, color 0.08s;
}
.ind-option:hover, .ind-option.active { background: var(--bg-2); color: var(--ink); }
.ind-option.selected { color: var(--green); }
.ind-option.selected::after { content: ' ✓'; color: var(--green); }
.ind-empty {
  padding: 10px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px;
  color: var(--ink-4); text-align: center;
}

/* Facet section visibility for filter-search */
.facet.hidden-by-search { display: none; }

/* ── Engine widgets (static/js/db-filters.js) ── */
.views-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.view-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink-2); cursor: pointer;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px; }
.view-chip:hover { color: var(--ink); border-color: var(--ink-4); }
.view-chip.active { background: var(--green-soft, rgba(80,200,120,.14)); color: var(--green); border-color: var(--green); }
.view-chip.modified { border-style: dashed; }
.view-chip .vc-menu { opacity: .6; padding: 0 2px; }
.view-chip .vc-menu:hover { opacity: 1; }
.view-save { color: var(--green); border-style: dashed; }
.vc-dropdown { z-index: 60; background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.28); padding: 4px; min-width: 190px; }
.vc-dropdown button { display: block; width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 7px 10px; border-radius: 6px; color: var(--ink-2); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px; }
.vc-dropdown button:hover { background: var(--bg-2); color: var(--ink); }
.vc-dropdown button.danger:hover { color: var(--red, #e34d4d); }

.tri { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tri-btn { background: var(--bg-2); border: 0; border-left: 1px solid var(--line); cursor: pointer;
  padding: 4px 9px; color: var(--ink-3); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 10px; }
.tri-btn:first-child { border-left: 0; }
.tri-btn.on { background: var(--green-soft, rgba(80,200,120,.14)); color: var(--green); }

/* wDate preset chips — scoped under .facet: the bare .chip name belongs to
   app-shell.css's global chip (pipeline Expand-all etc.) and must not be
   shadowed by a global rule from this file. The :hover rule re-states
   app-shell's chip hover, which this scoped selector out-specifies. */
.facet .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.facet .chips .chip { background: var(--bg-2); border: 1px solid var(--line); border-radius: 99px; cursor: pointer;
  padding: 3px 9px; color: var(--ink-3); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 10px; }
.facet .chips .chip:hover { color: var(--ink); border-color: var(--line-2); }
.facet .chips .chip.on { background: var(--green-soft, rgba(80,200,120,.14)); color: var(--green); border-color: var(--green); }

.filter-row.ms { position: relative; }
.labeled-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; }
.lr-label { color: var(--ink-3); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px; }
.cf-filter { margin: 8px 0; }
.cf-label { color: var(--ink-3); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 11px; margin-bottom: 3px; }
.sub-label { color: var(--ink-3); }
