/* ============================================================
   charts.css — 1:1 from original LiveScatter3D/wwwroot/index.html
   ============================================================ */

/* ── Overview top row ── */
/* 50% of content height: 100vh - header(40px) - statusbar(40px) = 80px chrome */
/* Rolling strip is ~44px + 9px margins, so top = (100vh - 80px - 53px) * 0.5 */
#overview-top {
  display: flex; flex: 0 0 auto;
  height: calc((100vh - 133px) * 0.5);
  min-height: 260px;
  gap: 6px; padding: 6px 6px 3px;
}
#main-chart-wrap {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
}
#main-chart-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px 4px; flex-shrink: 0;
}
.main-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #4e5a66; }

/* ── Unified section title (used by all card headers) ── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #4e5a66;
  font-family: 'Segoe UI', 'Segoe UI Variable Text', sans-serif;
}

/* ── Toolbar Y-mode / average buttons — fixed equal width ── */
.ov-mode-btn {
  width: 52px;
  text-align: center;
  padding: 0;
  flex-shrink: 0;
}
#main-chart { flex: 1; min-height: 0; height: 100%; width: 100%; }

/* ── Overview sidebar ── */
#ov-sidebar { width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: hidden; }
#ov-card { flex-shrink: 0; padding: 10px 12px; }
#ov-card .ov-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
/* font handled by .section-title — no override needed */
.ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ov-cell { display: flex; flex-direction: column; gap: 1px; }
.ov-lbl  { font-size: 11px; color: #6f7883; text-transform: uppercase; letter-spacing: .06em; }
.ov-val  { font-size: 20px; font-weight: 700; color: #1a1a1a; line-height: 1.1; }
.ov-peak { font-size: 11px; color: #6f7883; }

#pins-card { flex: 1; min-height: 0; padding: 8px 12px; overflow: hidden; display: flex; flex-direction: column; }
#pins-card .ov-hdr { margin-bottom: 4px; flex-shrink: 0; }
#pin-summary-rows { flex-shrink: 0; }
#pins-img {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* ── Overview bottom row ── */
#ov-summary-bottom {
  width: auto; margin: 0 6px 6px 6px;
  display: flex; gap: 6px;
  flex: 1; min-height: 0;
}
#diag-summary-card {
  width: 220px; box-sizing: border-box; flex: 0 0 220px;
  min-height: 0; height: 100%; padding: 8px 12px; overflow: hidden;
}
#ov-safety-card {
  width: auto; box-sizing: border-box;
  flex: 1; min-height: 0; height: 100%;
  padding: 8px 0 8px; overflow: hidden;
  display: flex; flex-direction: column;
}
#ov-safety-chart { width: 100%; flex: 1; height: 100%; min-height: 0; }

/* ── Pin grid (overview + pins tab) ── */
#pin-grid {
  display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(2,1fr);
  gap: 6px; padding: 6px; flex: 1; min-height: 0;
}
#pin-grid-full {
  display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(2,1fr);
  gap: 6px; padding: 8px; flex: 1; min-height: 0;
}

/* ── Diagnostics ── */
.diag-shell {
  display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); grid-template-rows: repeat(3,minmax(0,1fr));
  gap: 8px; padding: 8px; flex: 1; min-height: 0; overflow: hidden;
}
.diag-panel { background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; overflow: hidden; min-height: 0; display: flex; flex-direction: column; }
.diag-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px 5px; border-bottom: 1px solid #f0f0f0; }
.diag-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #555; }
.diag-sub   { font-size: 10px; color: #888; }
.diag-chart { flex: 1; min-height: 0; width: 100%; }
.diag-kpi   { display: flex; align-items: center; gap: 6px; }
.diag-kpi-val { font-size: 11px; font-weight: 700; color: #1a1a1a; }

/* ── Diagnostics new layout ── */
.diag-grid-new {
  display: grid; grid-template-columns: 1.05fr 0.95fr;
  grid-template-rows: repeat(3,minmax(0,1fr));
  gap: 8px; padding: 8px; flex: 1; min-height: 0;
}
.diag-info-panel, .diag-fault-panel, .diag-trigger-panel, .diag-display-panel, .diag-raw-panel {
  background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; min-height: 0; overflow: hidden; display: flex; flex-direction: column;
}
.diag-zone-info  { grid-column: 1; grid-row: 1 / -1; }
.diag-zone-tests { grid-column: 2; grid-row: 1 / -1; }
.diag-info-body, .diag-fault-body, .diag-trigger-body, .diag-display-body, .diag-raw-body { padding: 10px; min-height: 0; overflow: hidden; }
.diag-block-title { font-size: 10px; color: #6f7883; letter-spacing: .09em; text-transform: uppercase; font-weight: 700; margin-bottom: 6px; }
.diag-info-refresh { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.diag-info-split { display: flex; flex-direction: column; gap: 10px; flex: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 14px; height: 14px; border: 2px solid #e0e0e0; border-top-color: #0078d4; border-radius: 50%; animation: spin .6s linear infinite; display: none; }
.loading .spinner { display: block; }

/* ── Load/Thermal ── */
.rel-shell { display: flex; flex: 1; min-height: 0; gap: 8px; padding: 8px; background: #f0f0f0; }
.rel-main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.rel-panel { background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.rel-panel.equal { flex: 1; }
.rel-panel-header { display: flex; align-items: center; gap: 10px; padding: 5px 12px 4px; flex-shrink: 0; border-bottom: 1px solid #f0f0f0; }
.rel-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: #555; }
.rel-sub   { font-size: 10px; color: #aaa; }
.rel-scale-label { font-size: 10px; color: #888; font-weight: 600; }
.rel-grow  { flex: 1; min-height: 0; }
.rel-heatmap-foot { padding: 4px 12px 6px; border-top: 1px solid #f0f0f0; flex-shrink: 0; }
.rel-heatmap-foot-inner { margin-left: 56px; margin-right: 70px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; row-gap: 4px; column-gap: 8px; }
.rel-heatmap-note { grid-column: 1/-1; font-size: 10px; color: #888; font-weight: 600; text-align: center; }
.rel-grad-bar { width: 100%; min-width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(to right,#1f4db6,#1fa3d6,#35b779,#f08c2e,#d13438); border: 1px solid #e0e0e0; }
.rel-side { width: 240px; flex-shrink: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.rel-section { padding: 8px 10px; }
.rel-section + .rel-section { border-top: 1px solid #f0f0f0; }
.rel-section-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: #666; margin-bottom: 6px; }
.rel-live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rel-metric-label { font-size: 8px; color: #888; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.rel-metric-value { font-size: 14px; font-weight: 700; line-height: 1.1; color: #1a1a1a; }
.rel-metric-value.warn { color: #f28e2b; }
.rel-table-wrap { padding: 8px 10px; flex: 1; overflow: hidden; }
.rel-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rel-table th { text-align: right; color: #777; font-weight: 600; padding: 2px 4px; }
.rel-table th:first-child { text-align: left; }
#heatmap-canvas-wrap { position: relative; overflow: hidden; }
#heatmap-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }

/* ── Media ── */
@media (max-width: 920px) {
  .diag-grid-new { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════
   DARK MODE OVERRIDES — charts.css
   ══════════════════════════════════════════════ */

/* Section titles */
body.dark-mode .section-title,
body.dark-mode .main-title { color: #a0a0a0; }

/* Overview cards */
body.dark-mode .ov-lbl  { color: #666; }
body.dark-mode .ov-val  { color: #e8e8e8; }
body.dark-mode .ov-peak { color: #666; }
body.dark-mode #pins-footnote { color: #555; }

/* Diag panels (analysis tab) */
body.dark-mode .diag-panel { background: #1e1e1e; border-color: #2f2f2f; }
body.dark-mode .diag-panel-head { border-bottom-color: #2a2a2a; }
body.dark-mode .diag-title { color: #a0a0a0; }
body.dark-mode .diag-sub   { color: #555; }
body.dark-mode .diag-kpi-val { color: #e8e8e8; }
body.dark-mode .diag-block-title { color: #666; }

/* Diag info/fault panels */
body.dark-mode .diag-info-panel,
body.dark-mode .diag-fault-panel,
body.dark-mode .diag-trigger-panel,
body.dark-mode .diag-display-panel,
body.dark-mode .diag-raw-panel { background: #1e1e1e; border-color: #2f2f2f; }

/* Load/Thermal */
body.dark-mode .rel-shell { background: #121212; }
body.dark-mode .rel-panel { background: #1e1e1e; border-color: #2f2f2f; }
body.dark-mode .rel-panel-header { border-bottom-color: #2a2a2a; }
body.dark-mode .rel-title { color: #a0a0a0; }
body.dark-mode .rel-sub   { color: #555; }
body.dark-mode .rel-scale-label { color: #666; }
body.dark-mode .rel-heatmap-foot { border-top-color: #2a2a2a; }
body.dark-mode .rel-heatmap-note { color: #666; }
body.dark-mode .rel-grad-bar { border-color: #3a3a3a; }
body.dark-mode .rel-section + .rel-section { border-top-color: #2a2a2a; }
body.dark-mode .rel-section-title { color: #666; }
body.dark-mode .rel-metric-label { color: #666; }
body.dark-mode .rel-metric-value { color: #e8e8e8; }
body.dark-mode .rel-table th { color: #666; }
body.dark-mode .spinner { border-color: #333; border-top-color: var(--brand); }
