/* ==========================================================================
   Historic Toolbar — FULL CSS (targets your exact Python markup)
   ========================================================================== */

/* ---------- Tokens -------------------------------------------------------- */
:root{
  --brand:        #00509e;
  --brand-600:    #004487;
  --surface:      #ffffff;

  --control-h:    32px;               /* control height */
  --radius:       8px;                /* squarish corners */
  --focus-ring:   0 0 0 3px rgba(0,80,158,.25);

  /* Off‑market knob fine‑tuning (positive pushes the switch DOWN) */
  --switch-y-offset: 0px;

  /* More‑filters badge fine‑tuning (positive pushes the badge DOWN) */
  --adv-badge-y: 2px;

  /* Shared effects */
  --hover-shadow: 0 2px 8px rgba(0,80,158,.18);
  --press-inset:  inset 0 1px 3px rgba(0,0,0,.12);
}

/* Normalize heights across the bar */
#historic-toolbar .btn,
#historic-toolbar .input-group-text{
  height: var(--control-h);
  display: inline-flex;
  align-items: center;
  line-height: calc(var(--control-h) - 2px);
}

/* ==========================================================================
   Generic pill (label + right piece)
   ========================================================================== */
.pill-control{
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  border-radius: var(--radius);
  background: var(--surface);
}

.pill-control .pill-left{
  border-radius: var(--radius) 0 0 var(--radius) !important;
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
  font-weight: 600;
  padding: 0 .70rem;
}

.pill-control .pill-right{
  border-radius: 0 var(--radius) var(--radius) 0 !important;
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-left: 0;
  padding: 0 .60rem;
  transition: background-color .12s ease, box-shadow .15s ease, transform .06s ease;
}
/* Hover/press ONLY on the right tile (wrapper stays still) */
.pill-control .pill-right:hover{
  background: var(--brand-600);
  transform: translateY(-1px);
  box-shadow: var(--hover-shadow);
}
.pill-control .pill-right:active{
  transform: translateY(0);
  box-shadow: var(--press-inset);
}
.pill-control .pill-right:focus-visible{
  outline: 0;
  box-shadow: var(--focus-ring);
}

/* ==========================================================================
   OFF‑MARKET — blue right tile + true vertical centering
   ========================================================================== */
#offmarket-background.toggle-socket{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  min-width: 3.2rem;
  padding: 0;
  border-left: 0;
  border: 1px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0 !important;
  background: var(--brand);
  color: #fff;
  overflow: visible;
}

#offmarket-background .offmarket-switch-input{ width:100%; height:100%; }
#offmarket-background .offmarket-switch-input .form-check{
  margin:0 !important; padding:0 !important;
  width:100%; height:100%;
}
#offmarket-background .offmarket-switch-input .form-switch{ padding-left:0 !important; }

#offmarket-background input.form-check-input{
  position: absolute !important;
  top: calc(50% + var(--switch-y-offset)) !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  margin: 0 !important;
  float: none !important;
  width: 2.5rem;
  height: 1.4rem;
  box-shadow: none;
}
#offmarket-background input.form-check-input:checked{
  background-color: var(--brand);
  border-color: var(--brand);
}
#offmarket-background input.form-check-input:focus{
  box-shadow: var(--focus-ring);
}

/* ==========================================================================
   PRICE TYPE — segmented control (group lifts; segments stay put)
   ========================================================================== */
.control--seg{
  display: inline-flex;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  overflow: hidden;
  height: var(--control-h);
  min-height: var(--control-h);
  box-sizing: border-box;
  transition: transform .06s ease, box-shadow .12s ease, border-color .12s ease;
}

/* Group hover/press → match Clear all */
.control--seg:hover{
  transform: translateY(-1px);
  box-shadow: var(--hover-shadow);
}
.control--seg:active{
  transform: translateY(-1px);          /* no downward jump */
  box-shadow: var(--press-inset);
}

/* Label */
.control--seg .control-label{
  display: inline-flex;
  align-items: center;
  height: var(--control-h);
  min-height: var(--control-h);
  box-sizing: border-box;
  padding: 0 .65rem;
  background: #fff;
  color: var(--brand);
  font-weight: 600;
  border: 0;
}

/* Segment wrapper (keeps the internal divider) */
.control--seg .seg-wrap{
  display: inline-flex;
  align-items: stretch;
  border-left: 1px solid var(--brand);  /* seam next to the label */
  background: #fff;
}

/* Segments (PPP / PRP) — static height, no translate on hover */
.control--seg .segmented .seg-btn{
  border: 0 !important;
  border-radius: 0 !important;
  background: #fff;
  color: var(--brand);
  font-weight: 600;
  height: var(--control-h);
  min-height: var(--control-h);
  line-height: calc(var(--control-h) - 2px);
  box-shadow: none;
  padding: 0 .70rem;
  transition: background-color .12s ease, color .12s ease, box-shadow .12s ease; /* no transform */
}

/* Divider between PPP and PRP */
.control--seg .segmented .seg-btn + .seg-btn{
  border-left: 1px solid var(--brand);
}
/* Slightly darken the divider on group hover (keeps it crisp) */
.control--seg:hover .segmented .seg-btn + .seg-btn{
  border-left-color: var(--brand-600);
}

/* Active segment */
.control--seg .segmented .seg-btn.is-active{
  background: var(--brand);
  color: #fff;
}
/* Keep a visible seam when right segment is active */
.control--seg .segmented .seg-btn.is-active:nth-child(2){
  box-shadow: -1px 0 0 var(--brand-600) inset;
}

/* No lift or glow on segment hover/press (prevents tiny wobble) */
.control--seg .segmented .seg-btn:hover,
.control--seg .segmented .seg-btn:active{
  transform: none !important;
  box-shadow: none !important;
}
.control--seg .segmented .seg-btn:focus-visible{
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ==========================================================================
   Extras: Export styles
   ========================================================================== */
.clear-filters[disabled]{ opacity:.45; cursor:not-allowed; }

#historic-controls-card .export-button.btn{
  border-color: var(--brand);
  color: var(--brand);
}
#historic-controls-card .export-button.btn:hover{
  background: var(--brand);
  color:#fff;
}

/* Export spinner only (scoped by id) */
#loading-export .dash-spinner-container{ background-color: transparent !important; pointer-events: none; }
#grid-wrapper .dash-spinner-container{ background-color: transparent !important; }

/* AG Grid visibility helpers */
.custom-ag-grid.grid-hidden .ag-root-wrapper{ visibility: hidden; }
.custom-ag-grid.grid-visible .ag-root-wrapper{ visibility: visible; }

/* Brand spinner on export (unique id from Dash) */
#pi-cs__loading_export__8b2a3 .dash-spinner-container{
  background-color: transparent !important;
  pointer-events: none !important;
  z-index: 2000 !important;
}

/* ==========================================================================
   32‑px tall action buttons & switches
   ========================================================================== */
[id$="-aip-btn"],
[id$="-aup-btn"],
[id$="-offcanvas-open"],
[id$="-advanced-date-offcanvas-open"],
.clear-filters,
.metric-label-btn,
#adv-toggle-btn,
[id$="-label"],
[id$="-background"]{
  height: var(--control-h) !important;
  min-height: var(--control-h) !important;
  line-height: 30px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
.offmarket-toggle-container,
.filter-switch,
.input-group[style*="height: 39px"]{ height: var(--control-h) !important; }

/* ==========================================================================
   Icon‑only filter triggers
   ========================================================================== */
.pill-right[id$="-offcanvas-open"]{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; min-width: 32px; height: 32px;
  padding: 0;
}
.pill-right[id$="-offcanvas-open"] :is(.iconify, iconify-icon, svg){
  display: inline-block !important;
  width: 16px !important;
  height: 16px !important;
  font-size: 16px !important;      /* so 1em = 16px */
  color: #fff !important;
  fill: currentColor !important;
  stroke: currentColor !important;
}
.pill-right[id$="-offcanvas-open"] > :not(.iconify):not(iconify-icon):not(svg){ display: none !important; }
.pill-right[id$="-offcanvas-open"]::before,
.pill-right[id$="-offcanvas-open"]::after{ content: none !important; background: none !important; }

/* ==========================================================================
   Minor UI polish for AG Grid / DataTable
   ========================================================================== */
.ag-theme-alpine .ag-overlay-no-rows-center{
  color: var(--gray-700);
  font-weight: 500;
  background: linear-gradient(0deg, var(--blue-050), transparent);
  border: 1px dashed color-mix(in srgb, var(--blue-500) 35%, transparent);
  border-radius: 2px;
  padding: .6rem .9rem;
}
.ag-header-cell-label .ag-sort-order{ display: none !important; }
.custom-ag-grid.grid-hidden{ opacity: 0; pointer-events: none; }
.custom-ag-grid.grid-visible{ opacity: 1; transition: opacity .12s ease-in !important; }

.pi-table .dash-table-tooltip{
  z-index: 2000 !important;
  background: #fff !important;
  color: #334155 !important;
  border: 1px solid rgba(0,0,0,.08) !important;
  border-radius: .5rem !important;
  padding: 6px 8px !important;
  box-shadow: 0 .5rem 1rem rgba(0,0,0,.15) !important;
  font-size: .90rem !important;
  line-height: 1.25rem !important;
  white-space: normal !important;
  max-width: 28rem !important;
  pointer-events: none !important;
}
.pi-table .dash-table-tooltip::before{
  content: "";
  position: absolute;
  top: 50%;
  left: -7px;
  transform: translateY(-50%);
  border-width: 7px;
  border-style: solid;
  border-color: transparent rgba(0,0,0,.08) transparent transparent;
}
.pi-table .dash-table-tooltip::after{
  content: "";
  position: absolute;
  top: 50%;
  left: -6px;
  transform: translateY(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent #fff transparent transparent;
}

/* Small responsive tweaks for chip row */
.timeline-pill{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1200px){ #packs-chosen-display, #date-selection-display { max-width: 200px; } }
@media (max-width: 1100px){ #packs-chosen-display, #date-selection-display { max-width: 170px; } }
@media (max-width: 992px){ #date-selection-display { display: none; } }

/* Dash global loader off */
._dash-loading, #_dash-loading { display: none !important; }

/* Dropdown palette alignments (optional) */
.dropdown-menu-dark .dropdown-item.active,
.dropdown-menu-dark .dropdown-item:active{ background-color: rgba(255,255,255,.10) !important; color: #fff !important; }
.dropdown-menu-dark .dropdown-item:hover{ background-color: rgba(255,255,255,.06); }

.ag-link-cell{ white-space: nowrap; text-decoration: underline; cursor: pointer; }

/* --- Advanced filters usage indicator (badge) ----------------------------- */
.hist-toolbar #adv-active-count{
  display: none;               /* shown by callback when >0 */
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 .3rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.1rem;
  background: var(--brand) !important;
  color: #fff !important;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   “More filters” — consistent with Clear all (fills on hover)
   ========================================================================== */

/* Keep outline-secondary in brand blue in ALL states (base) */
#historic-toolbar .hist-btn.btn-outline-secondary{
  --bs-btn-color: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-color: var(--brand);
  --bs-btn-hover-bg: #fff;
  --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-color: var(--brand);
  --bs-btn-active-bg: #fff;
  --bs-btn-active-border-color: var(--brand-600);

  color: var(--brand);
  border-color: var(--brand);
  background-color: #fff;
}

/* Base look for the More filters button */
#historic-toolbar #adv-toggle-btn{
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: none;
  transition: transform .08s ease, box-shadow .12s ease,
              background-color .12s ease, color .12s ease, border-color .12s ease;

  /* ensure identical vertical sizing to pill controls */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: var(--control-h) !important;
  min-height: var(--control-h) !important;
  line-height: calc(var(--control-h) - 2px) !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  box-sizing: border-box;
}

/* Hover (fill + lift) */
#historic-toolbar #adv-toggle-btn:hover,
#historic-toolbar #adv-toggle-btn.is-open:hover{
  background: var(--brand);
  color: #fff;
  border-color: var(--brand-600);
  transform: translateY(-1px);
  box-shadow: var(--hover-shadow);
}

/* Focus (no halo) */
#historic-toolbar #adv-toggle-btn:focus,
#historic-toolbar #adv-toggle-btn:focus-visible,
#historic-toolbar #adv-toggle-btn:active:focus{
  outline: 0; box-shadow: none;
}

/* Pressed: keep at hover height (no downward jump) */
#historic-toolbar #adv-toggle-btn:active{
  transform: translateY(-1px) !important;
  background: var(--brand-600);
  color: #fff;
  border-color: var(--brand-600);
  box-shadow: var(--press-inset);
}

/* Open state baseline remains identical to closed */
#historic-toolbar #adv-toggle-btn.is-open{
  background: #fff; color: var(--brand); border-color: var(--brand); box-shadow: none;
}

/* Badge inside the button: blue, centered, and nudged DOWN slightly */
#historic-toolbar #adv-toggle-btn .badge,
#historic-toolbar #adv-toggle-btn #adv-active-count{
  position: static !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  height: 1.15rem !important;
  min-width: 1.15rem !important;
  padding: 0 .35rem !important;
  line-height: 1.15rem !important;
  font-size: .75rem !important;
  font-weight: 600 !important;

  background: var(--brand) !important;
  color: #fff !important;
  border: 0 !important;

  vertical-align: middle !important;
}

/* Unify small action buttons (Clear/More/Export) */
#historic-toolbar .hist-btn.btn{
  --bs-btn-padding-y: 0rem;
  --bs-btn-padding-x: .60rem;
  --bs-btn-font-weight: 600;
  --bs-btn-border-radius: var(--radius);

  height: var(--control-h);
  min-height: var(--control-h);

  padding: 0 var(--bs-btn-padding-x);
  font-weight: 600;

  transition: background-color .12s ease,
              border-color .12s ease,
              box-shadow .15s ease,
              transform .06s ease;
}

/* Global hover lift and soft shadow for hist buttons only */
#historic-toolbar .hist-btn:hover{
  transform: translateY(-1px);
  box-shadow: var(--hover-shadow);
}

/* Pressed */
#historic-toolbar .hist-btn:active,
#historic-toolbar .hist-btn.active{
  transform: translateY(0);
  box-shadow: var(--press-inset);
  font-weight: 600;
}
/* ──────────────────────────────────────────────────────────────
   Price type segmented control — NO hover/press lift on group
   (PPP/PRP already have no per-button lift)
   Place AFTER existing rules.
   ────────────────────────────────────────────────────────────── */

/* Stop the group from lifting or showing a shadow on hover/press */
#historic-toolbar .control--seg,
#historic-toolbar .control--seg:hover,
#historic-toolbar .control--seg:active {
  transform: none !important;
  box-shadow: none !important;
}

/* Keep the internal divider stable (prevents the faint line change) */
#historic-toolbar .control--seg .segmented .seg-btn + .seg-btn,
#historic-toolbar .control--seg:hover .segmented .seg-btn + .seg-btn {
  border-left-color: var(--brand) !important;
}

/* Segments remain fixed height and shadowless (defensive) */
#historic-toolbar .control--seg .segmented .seg-btn:hover,
#historic-toolbar .control--seg .segmented .seg-btn:active {
  transform: none !important;
  box-shadow: none !important;
}

/* match your theme class if different */
.ag-theme-alpine.custom-ag-grid .ag-cell.effective-win {
  background-color: rgba(0, 158, 143, 0.15) !important; /* same tint as COL_POS_TINT */
}

/* ==========================================================================
   FRONT PAGE — SaaS polish (uniform tiles; no search/CTA/support)
   ========================================================================== */

