/* ============================================================================
   Events Filter Bar — "Hybrid (2 + 4)"
   Unified bar: segmented status buckets + sort popover, a distribution
   proportion bar, and underline sub-filter tabs.

   Drop-in CSS for the Events page. Scoped under .events-filterbar-scope so it
   can't leak into the rest of the app. All theming runs off CSS variables that
   flip on [data-theme="dark"] — wire it to whatever theme attribute the app
   already sets on <html>/<body>.
   ============================================================================ */

/* ---- Tokens (light) ---- */
.events-filterbar-scope {
  --fb-tray:        #f5f6f7;
  --fb-tray-border: rgba(0,0,0,.05);
  --fb-elevate:     #ffffff;                 /* active segment / sort chip */
  --fb-elevate-sh:  0 1px 3px rgba(0,0,0,.12);
  --fb-border:      rgba(0,0,0,.13);
  --fb-border-soft: rgba(0,0,0,.08);
  --fb-t1:          #1f2329;                 /* primary text */
  --fb-t2:          #5c636a;                 /* secondary text */
  --fb-t3:          #9298a0;                 /* muted text */
  --fb-ink:         #1f2329;                 /* neutral underline / strong */
  --fb-menu-bg:     #ffffff;
  --fb-menu-hover:  rgba(0,0,0,.045);
  --fb-menu-sh:     0 12px 34px rgba(0,0,0,.2);

  /* status solids (theme-stable) */
  --st-green:  #1a7f37;  --st-blue:   #0d6efd;  --st-red:    #dc3545;
  --st-amber:  #d97706;  --st-purple: #6f42c1;  --st-gray:   #6c757d;
  /* status text (light) */
  --st-green-t:  #157347;  --st-blue-t:   #0a58ca;  --st-red-t:    #b02a37;
  --st-amber-t:  #b36b00;  --st-purple-t: #59359a;  --st-gray-t:   #5c636a;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--fb-t1);
}

/* ---- Tokens (dark) — adjust the selector to your app's dark hook ---- */
[data-theme="dark"] .events-filterbar-scope {
  --fb-tray:        rgba(255,255,255,.045);
  --fb-tray-border: rgba(255,255,255,.07);
  --fb-elevate:     #34383d;
  --fb-elevate-sh:  0 1px 2px rgba(0,0,0,.4);
  --fb-border:      rgba(255,255,255,.16);
  --fb-border-soft: rgba(255,255,255,.10);
  --fb-t1:          #e6e8eb;
  --fb-t2:          #9aa3ab;
  --fb-t3:          #6b727a;
  --fb-ink:         #e6e8eb;
  --fb-menu-bg:     #26292d;
  --fb-menu-hover:  rgba(255,255,255,.07);

  --st-green-t:  #5fd58a;  --st-blue-t:   #6ea8fe;  --st-red-t:    #f17a85;
  --st-amber-t:  #f0b860;  --st-purple-t: #c4a5f5;  --st-gray-t:   #aab1b8;
}

/* status modifier classes — set the local color pair used by active states.
   Apply ONE of these to each .fb-seg and each .fb-subtab. */
.fb--green  { --c: var(--st-green);  --ct: var(--st-green-t);  }
.fb--blue   { --c: var(--st-blue);   --ct: var(--st-blue-t);   }
.fb--red    { --c: var(--st-red);    --ct: var(--st-red-t);    }
.fb--amber  { --c: var(--st-amber);  --ct: var(--st-amber-t);  }
.fb--purple { --c: var(--st-purple); --ct: var(--st-purple-t); }
.fb--gray   { --c: var(--st-gray);   --ct: var(--st-gray-t);   }

.events-filterbar-scope *,
.events-filterbar-scope *::before { box-sizing: border-box; }
.events-filterbar-scope button { font-family: inherit; white-space: nowrap; }

/* ============================ 1 · THE BAR ============================ */
.events-filterbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 13px;
  background: var(--fb-tray);
  border: 1px solid var(--fb-tray-border);
}
/* Narrow screens: let the bar wrap rather than clip (clipping would cut off
   the sort popover). The sort control drops to its own full-width row. */
@media (max-width: 640px) {
  .events-filterbar { flex-wrap: wrap; }
  .fb-sort-wrap { margin-left: 0; width: 100%; }
  .fb-sort { width: 100%; justify-content: center; }
  .fb-subtabs { gap: 14px; }
}

/* segmented status bucket */
.fb-seg {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--fb-t2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -.1px;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.fb-seg:hover:not(.is-active) { color: var(--fb-t1); }
.fb-seg.is-active {
  background: var(--fb-elevate);
  box-shadow: var(--fb-elevate-sh);
  color: var(--ct);
}
.fb-seg__dot {
  width: 7px; height: 7px; border-radius: 4px;
  background: var(--c);
  opacity: .5;
  transition: opacity .16s ease;
}
.fb-seg.is-active .fb-seg__dot { opacity: 1; }
.fb-seg__count {
  font-size: 10px; font-weight: 700;
  position: relative; top: -.5em;
  color: var(--fb-t3);
  font-variant-numeric: tabular-nums;
}
.fb-seg.is-active .fb-seg__count { color: var(--ct); }

/* ---- sort control (pushed to the right of the bar) ---- */
.fb-sort-wrap { margin-left: auto; position: relative; padding-left: 6px; }
.fb-sort {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--fb-border-soft);
  border-radius: 9px;
  background: var(--fb-elevate);
  color: var(--fb-t1);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.fb-sort__label { color: var(--fb-t3); font-weight: 500; }
.fb-sort .fb-ico { color: var(--fb-t2); }

/* sort popover */
.fb-sortmenu {
  position: absolute;
  top: 100%; right: 0;
  margin-top: 6px;
  z-index: 30;
  min-width: 204px;
  padding: 5px;
  border-radius: 11px;
  background: var(--fb-menu-bg);
  border: 1px solid var(--fb-border);
  box-shadow: var(--fb-menu-sh);
}
.fb-sortmenu[hidden] { display: none; }
.fb-sortmenu__dir {
  display: flex; gap: 4px;
  padding: 3px; margin-bottom: 5px;
  border-radius: 8px;
  background: var(--fb-tray);
}
.fb-sortmenu__dirbtn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 5px;
  border: none; border-radius: 6px;
  background: transparent;
  color: var(--fb-t2);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.fb-sortmenu__dirbtn.is-active {
  background: var(--fb-elevate);
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  color: var(--fb-t1);
}
.fb-sortmenu__opt {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border: none; border-radius: 6px;
  background: transparent;
  color: var(--fb-t1);
  font-size: 12.5px; font-weight: 500;
  text-align: left; cursor: pointer;
}
.fb-sortmenu__opt:hover { background: var(--fb-menu-hover); }
.fb-sortmenu__opt.is-active { background: var(--fb-menu-hover); font-weight: 600; }

/* ====================== 2 · PROPORTION BAR ====================== */
.fb-proportion { display: flex; gap: 3px; height: 6px; margin-top: 10px; }
.fb-proportion__seg {
  border-radius: 3px;
  background: var(--c);
  opacity: .3;
  cursor: pointer;
  transition: opacity .16s ease;
  /* flex-grow is set inline per segment = its count, e.g. style="flex:12" */
}
[data-theme="dark"] .fb-proportion__seg { opacity: .42; }
.fb-proportion__seg.is-active { opacity: 1; }
.fb-meta {
  margin-top: 5px;
  font-size: 11px; font-weight: 500;
  color: var(--fb-t3);
  font-variant-numeric: tabular-nums;
}

/* ====================== 3 · SUB-FILTER TABS ====================== */
.fb-subtabs {
  display: flex; align-items: flex-end; flex-wrap: wrap;
  gap: 18px;
  margin-top: 13px;
  border-bottom: 1px solid var(--fb-border-soft);
}
.fb-subtabs__corner { color: var(--fb-t3); margin-bottom: 9px; }
.fb-subtab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 1px 9px;
  border: none; background: transparent;
  color: var(--fb-t2);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  box-shadow: inset 0 -2px 0 transparent;
  transition: color .15s ease;
}
.fb-subtab:hover:not(.is-active) { color: var(--fb-t1); }
.fb-subtab.is-active        { color: var(--fb-ink);  font-weight: 700; box-shadow: inset 0 -2px 0 var(--fb-ink); }
.fb-subtab.fb-subtab--warn.is-active { color: var(--ct); box-shadow: inset 0 -2px 0 var(--c); }
.fb-subtab__count {
  font-size: 11px; font-weight: 700;
  color: var(--fb-t3);
  font-variant-numeric: tabular-nums;
}
.fb-subtab.is-active .fb-subtab__count        { color: var(--fb-t2); }
.fb-subtab.fb-subtab--warn.is-active .fb-subtab__count { color: var(--ct); }
.fb-subtab--warn .fb-ico { color: var(--ct); }

/* shared icon sizing */
.fb-ico { display: inline-block; vertical-align: -.125em; flex-shrink: 0; }
