/* ────────────────────────────────────────────────────────────────
   breadth_extras.css — full-page Bar Chart + Heatmap styling.
   Theme tokens via var(--*) so light/dark/blue all work.
   ──────────────────────────────────────────────────────────────── */

/* ── Bar Chart page (#brbar) ──────────────────────────────────── */
[data-page="brbar"] .brbar-wrap {
  margin: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  height: calc(100vh - 180px);
  min-height: 360px;
  display: flex;
  flex-direction: column;
}
[data-page="brbar"] .brbar-chart-host {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
}
[data-page="brbar"] .brbar-chart-host canvas {
  position: absolute; inset: 0;
  width: 100% !important;
  height: 100% !important;
}
[data-page="brbar"] .brbar-err {
  color: var(--red, #ef4444);
  padding: 12px;
}

/* ── Heatmap page (#brheat) ──────────────────────────────────── */
[data-page="brheat"] .brheat-wrap {
  margin: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  min-height: 360px;
}
[data-page="brheat"] .brheat-err {
  color: var(--red, #ef4444);
  padding: 12px;
}

[data-page="brheat"] .brh-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px;
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}
[data-page="brheat"] .brh-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
[data-page="brheat"] .brh-lg {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 2px;
  vertical-align: middle;
  margin: 0 4px 0 10px;
}
[data-page="brheat"] .brh-lg-hi { background: #22c55e; }
[data-page="brheat"] .brh-lg-lo { background: #e74c3c; }

/* ── Two-column layout: heatmap on the left, side panel on right.
   The side panel stays pinned (no horizontal scroll on the grid).
   Side panel is sized to fit Symbol + LTP + Day H/L with the typical
   ₹X,XX,XXX widths (think MRF at 1,22,000); 280px is the sweet spot
   — narrower wastes width on padding, wider eats heatmap real estate. */
[data-page="brheat"] .brh-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  min-height: 0;
}
[data-page="brheat"] .brh-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

/* ── Right-side companion panel ───────────────────────────────── */
[data-page="brheat"] .brh-side {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}
[data-page="brheat"] .brh-side-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  min-height: 0;
  overflow: hidden;
}
[data-page="brheat"] .brh-side-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 10px;
  font-size: 11px; font-weight: 700;
  color: var(--text);
  text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  flex: 0 0 auto;
}
[data-page="brheat"] .brh-side-head-hi { color: var(--green, #15803d); }
[data-page="brheat"] .brh-side-head-lo { color: var(--red,   #b91c1c); }
[data-page="brheat"] .brh-side-head .brh-side-meta {
  font-size: 10px; font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}
[data-page="brheat"] .brh-side-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
[data-page="brheat"] .brh-side-tbl {
  width: 100%;
  border-collapse: collapse;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
[data-page="brheat"] .brh-side-tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel);
  text-align: left;
  font-family: var(--font, Inter, sans-serif);
  font-size: 9.5px; font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.4px; text-transform: uppercase;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
[data-page="brheat"] .brh-side-tbl thead th:not(:first-child) { text-align: right; }
/* Tight side-padding so the symbol gets more visual room and the
   numeric columns hug their content. */
[data-page="brheat"] .brh-side-tbl tbody td {
  padding: 3px 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
}
[data-page="brheat"] .brh-side-tbl tbody td.brh-side-sym {
  font-family: var(--font, Inter, sans-serif);
  font-weight: 600; font-size: 11px;
  color: var(--text);
}
[data-page="brheat"] .brh-side-tbl tbody td.brh-side-px { text-align: right; color: var(--text); }
[data-page="brheat"] .brh-side-tbl tbody td.brh-side-hi { color: var(--green, #15803d); font-weight: 600; }
[data-page="brheat"] .brh-side-tbl tbody td.brh-side-lo { color: var(--red,   #b91c1c); font-weight: 600; }
[data-page="brheat"] .brh-side-tbl tbody tr:hover td {
  background: color-mix(in srgb, var(--accent, #3b82f6) 8%, transparent);
}
[data-page="brheat"] .brh-side-empty {
  padding: 14px 12px; font-size: 11px; color: var(--muted); text-align: center;
}

/* ── Slim themed scrollbars (Chromium + Firefox) ──────────────────
   Replaces the default heavyweight system scrollbar on every
   scrollable area inside the heatmap page (main grid + the two
   side tables). Matches the dark/blue chrome with a subtle thumb
   that shows on hover. Light theme gets a slightly darker thumb
   so it stays visible against the white panel. */
[data-page="brheat"] .brh-scroll,
[data-page="brheat"] .brh-side-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.35) transparent;
}
[data-page="brheat"] .brh-scroll::-webkit-scrollbar,
[data-page="brheat"] .brh-side-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
[data-page="brheat"] .brh-scroll::-webkit-scrollbar-track,
[data-page="brheat"] .brh-side-scroll::-webkit-scrollbar-track {
  background: transparent;
}
[data-page="brheat"] .brh-scroll::-webkit-scrollbar-thumb,
[data-page="brheat"] .brh-side-scroll::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.30);
  border-radius: 8px;
  border: 2px solid transparent;     /* inset effect — thumb appears thinner */
  background-clip: padding-box;
}
[data-page="brheat"] .brh-scroll::-webkit-scrollbar-thumb:hover,
[data-page="brheat"] .brh-side-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(148,163,184,0.55);
  background-clip: padding-box;
}
[data-page="brheat"] .brh-scroll::-webkit-scrollbar-corner,
[data-page="brheat"] .brh-side-scroll::-webkit-scrollbar-corner {
  background: transparent;
}
/* Light theme — slightly darker thumb so it stands out against
   the white panel background. */
:root[data-theme="light"] [data-page="brheat"] .brh-scroll,
:root[data-theme="light"] [data-page="brheat"] .brh-side-scroll {
  scrollbar-color: rgba(71,85,105,0.35) transparent;
}
:root[data-theme="light"] [data-page="brheat"] .brh-scroll::-webkit-scrollbar-thumb,
:root[data-theme="light"] [data-page="brheat"] .brh-side-scroll::-webkit-scrollbar-thumb {
  background: rgba(71,85,105,0.30);
  background-clip: padding-box;
}
:root[data-theme="light"] [data-page="brheat"] .brh-scroll::-webkit-scrollbar-thumb:hover,
:root[data-theme="light"] [data-page="brheat"] .brh-side-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(71,85,105,0.55);
  background-clip: padding-box;
}

/* table-layout:fixed forces the browser to honour each column's
   declared width exactly, instead of auto-sizing based on cell
   content. Without this, browsers redistribute width based on
   intrinsic content sizing — and even though our cells are empty,
   per-column border + padding accumulation can shift column widths
   by 1-2 px each, creating visible unevenness across 75 columns.
   border-collapse:collapse merges adjacent cell borders so the
   visual cell is exactly the declared width (vs ` separate` which
   adds the cell's right border ON TOP of the next cell's left). */
[data-page="brheat"] .brh-tbl {
  border-collapse: collapse;
  table-layout: fixed;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  white-space: nowrap;
}

/* Header row — sticky to top of scroll container. */
[data-page="brheat"] .brh-tbl thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 4;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 0;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-family: var(--font, Inter, sans-serif);
  box-sizing: border-box;
  height: 22px;
}
/* Time-axis labels: let the cell's text overflow its narrow one-bar column
   onto the empty neighbours (and paint above them) so "09:15" shows in full
   instead of clipping to "09:1". */
[data-page="brheat"] .brh-tbl thead th.brh-th-lbl {
  overflow: visible;
  white-space: nowrap;
  z-index: 5;
}
[data-page="brheat"] .brh-tbl thead th.brh-th-name {
  position: sticky;
  left: 0;
  z-index: 6;
  background: var(--panel);
  text-align: left;
  padding-left: 8px;
  border-right: 1px solid var(--border);
}

/* Symbol cell — sticky left so it stays visible while scrolling time. */
[data-page="brheat"] .brh-tbl tbody th.brh-row-head {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--panel);
  text-align: left;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font, Inter, sans-serif);
  font-size: 11px;
  padding: 0 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  height: 18px;
  line-height: 18px;
  box-sizing: border-box;
}
[data-page="brheat"] .brh-tbl tbody th.brh-row-head .brh-row-stats {
  color: var(--muted);
  font-weight: 400;
  font-size: 9px;
  margin-left: 6px;
  opacity: 0.85;
}
[data-page="brheat"] .brh-tbl tbody tr:hover th.brh-row-head {
  background: var(--panel-2);
}

/* Data cells. Width is NOT specified — table-layout:fixed + the
   single 90px <col> for the symbol distributes the rest equally
   across the bar columns, so the grid auto-fits page width
   without horizontal scroll. Height + box-sizing still locked so
   row height is uniform regardless of cell colour. */
[data-page="brheat"] .brh-tbl {
  width: 100%;   /* fill the brh-scroll wrapper */
}
[data-page="brheat"] .brh-tbl tbody td.brh-cell {
  height: 18px;
  padding: 0;
  background: transparent;
  border-right: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
  box-sizing: border-box;
}
[data-page="brheat"] .brh-tbl tbody td.brh-hi { background: #22c55e; }
[data-page="brheat"] .brh-tbl tbody td.brh-lo { background: #e74c3c; }

/* Hover affordance on cells. */
[data-page="brheat"] .brh-tbl tbody td.brh-cell:hover {
  outline: 1px solid var(--accent, #3b82f6);
  outline-offset: -1px;
  cursor: pointer;
}

/* Light theme — keep grid lines barely visible (same as Tape page fix). */
:root[data-theme="light"] [data-page="brheat"] .brh-tbl tbody td.brh-cell {
  border-right-color: #eef0f4;
  border-bottom-color: #eef0f4;
}
:root[data-theme="light"] [data-page="brheat"] .brh-tbl thead th,
:root[data-theme="light"] [data-page="brheat"] .brh-tbl tbody th.brh-row-head {
  border-bottom-color: #eef0f4;
  border-right-color: #eef0f4;
}
