/* ==========================================================================
   v2FundCategories.css — Fund Categories Dashboard (V2)
   ==========================================================================
   Styles the v2 port of the legacy /platform/home-office/etfa-ho-categories
   page. Mirrors the v2 toolbar conventions used by the Watchlist Dashboard
   (.wl-toggle-group / .wl-toggle-btn) and reuses the .ec-resources /
   .ec-jump-pill primitives from explorer-channels.css for the in-grid
   action buttons.
   ========================================================================== */

/* Pane override — the unlayered v2-tool-pane rules in v2-overlay.css set
   the active pane to `display: grid; grid-template-rows: minmax(0,1fr)`.
   That works for content that owns its own internal layout, but our
   wrapper expects to be a flex column with a fixed-height toolbar + a
   flex-grow grid wrap. Forcing `display: flex; flex-direction: column`
   on the active pane itself eliminates one layer of layout (the grid
   item), which was occasionally collapsing the inner grid wrap to 0px
   when AG Grid recalculated its size mid-render (e.g. when a filter
   popup opened and the pane briefly relayoutd). */
#v2-dashboards-fund-categories.v2-tool-pane.active {
  display: flex !important;
  flex-direction: column;
  overflow: hidden !important;
  height: 100%;
}

/* Pane root — fills the v2-tool-pane */
.v2-fc-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--v2-bg-page, #f8f9fa);
}

/* Toolbar / header strip */
.v2-fc-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--v2-bg-elevated, #ffffff);
  border-bottom: 1px solid var(--v2-border, #dee2e6);
  flex: 0 0 auto;
}

/* Segmented universe toggle (ETFs / MFs / All Funds).
   Uses hidden radios + clickable labels, identical visual to .wl-toggle-group. */
.v2-fc-toggle-group {
  display: inline-flex;
  border: 1px solid var(--v2-border, #dee2e6);
  border-radius: 6px;
  overflow: hidden;
}
.v2-fc-toggle-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.v2-fc-toggle-group label {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--v2-bg-elevated, #ffffff);
  color: var(--v2-text-muted, #6c757d);
  border-right: 1px solid var(--v2-border, #dee2e6);
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
  margin: 0;
}
.v2-fc-toggle-group label:last-of-type { border-right: none; }
.v2-fc-toggle-group label:hover { color: var(--v2-text-primary, #212529); }
.v2-fc-toggle-group input[type="radio"]:checked + label {
  background: var(--v2-accent, #0964A0);
  color: #ffffff;
}
.v2-fc-toggle-group input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--v2-accent, #0964A0);
  outline-offset: 1px;
}

/* View selector dropdown */
.v2-fc-view-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--v2-text-muted, #6c757d);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-left: 4px;
}
.v2-fc-view-toggle {
  padding: 5px 26px 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--v2-text-primary, #212529);
  background: var(--v2-bg-elevated, #ffffff)
              url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 8"><path fill="%236c757d" d="M6 8L0 0h12z"/></svg>')
              no-repeat right 8px center;
  background-size: 9px 6px;
  border: 1px solid var(--v2-border, #dee2e6);
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-width: 280px;
  transition: border-color .15s ease;
}
.v2-fc-view-toggle:hover { border-color: var(--v2-accent, #0964A0); }
.v2-fc-view-toggle:focus-visible {
  border-color: var(--v2-accent, #0964A0);
  box-shadow: 0 0 0 2px rgba(9, 100, 160, 0.15);
}

/* Grid container fills remaining vertical space.
   `flex: 1 1 0` (not `auto`) is important — `auto` lets the flex base size
   be the natural content height, which for an empty AG Grid div is 0,
   which (combined with min-height:0) lets the wrapper collapse to 0
   on initial render. With `flex-basis: 0`, the wrapper grows from 0 by
   the grow factor, taking ALL remaining space in the column. */
.v2-fc-grid-wrap {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  padding: 8px;
  overflow: hidden;
}
.v2-fc-grid-wrap .ag-theme-balham {
  width: 100%;
  height: 100%;
}

/* In-grid resource icons (PDF / Excel) — mirrors .ec-resources from
   explorer-channels.css, but scoped so cell padding doesn't squish them. */
.v2-fc-grid-wrap .ag-cell .ec-resources {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  height: 100%;
}
.v2-fc-grid-wrap .ag-cell .ec-res-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--v2-border, #dee2e6);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.12s ease;
  line-height: 1;
}
.v2-fc-grid-wrap .ag-cell .ec-res-btn:hover {
  border-color: var(--v2-accent, #0964A0);
  filter: brightness(0.9);
}
.v2-fc-grid-wrap .ag-cell .ec-muted {
  color: var(--v2-text-muted, #6c757d);
  font-size: 12px;
}

/* In-grid jump-to pills */
.v2-fc-grid-wrap .ag-cell .ec-jump-to {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 100%;
}
.v2-fc-grid-wrap .ag-cell .ec-jump-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--v2-accent, #0964A0);
  background: var(--v2-accent-bg, rgba(9, 100, 160, 0.08));
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.v2-fc-grid-wrap .ag-cell .ec-jump-pill:hover {
  background: var(--v2-accent, #0964A0);
  color: #fff;
}
.v2-fc-grid-wrap .ag-cell .ec-jump-pill i { font-size: 8px; }

/* Allow grid headers to line-wrap when long. AG Grid honors
   wrapHeaderText + autoHeaderHeight (set in JS), but the wrapping needs
   normal white-space + word-break to actually break long titles. */
.v2-fc-grid-wrap .ag-header-cell-label .ag-header-cell-text {
  white-space: normal !important;
  line-height: 1.2;
  word-break: normal;
  overflow-wrap: anywhere;
}

/* Filter / column-menu popup styling.
   Because we set `popupParent: document.body` in JS, the AG Grid popup
   for the column filter menu is appended directly to <body> instead of
   being nested inside .v2-fc-grid-wrap. We bump its z-index so it sits
   above the v2-tool-pane and the sidebar without getting clipped. The
   selector is scoped to popups that are direct children of body — i.e.
   only popups from the (one) grid that opted into popupParent body. */
body > .ag-popup,
body > .ag-popup .ag-popup-child {
  z-index: 1500;
}

/* Dark theme overrides */
html.dark-theme .v2-fc-wrapper { background: var(--v2-bg-page, #1a1d21); }
html.dark-theme .v2-fc-controls {
  background: var(--v2-bg-elevated, #25282d);
  border-bottom-color: var(--v2-border, #3a3f44);
}
html.dark-theme .v2-fc-toggle-group label,
html.dark-theme .v2-fc-view-toggle {
  background: var(--v2-bg-elevated, #25282d);
  color: var(--v2-text-primary, #e8eaed);
}
html.dark-theme .v2-fc-grid-wrap .ag-cell .ec-res-btn {
  border-color: var(--v2-border, #3a3f44);
}
