/* ============================================================
   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; }
}

/* ── Pin Analytics ── */
.pa-shell {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0; overflow: hidden;
  padding: 8px; gap: 8px;
}
.pa-main-wrap {
  flex: 0 0 36%; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
}
.pa-main-head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px 5px; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.pa-main-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: #4e5a66;
}
.pa-main-sub { font-size: 10px; color: var(--txt-muted); flex-shrink: 0; }
.pa-mode-btns { display: flex; gap: 4px; }
.pa-mode-btn {
  font-size: 11px; padding: 2px 9px; border-radius: 3px;
  background: transparent; color: var(--txt-muted);
  border: 1px solid var(--line); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}
.pa-mode-btn.active {
  background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600;
}
.pa-mode-btn:not(.active):hover { background: var(--bg-alt); color: var(--txt-main); border-color: #aaa; }
.pa-main-chart { flex: 1; min-height: 0; width: 100%; }

/* Grid der Info-Karten */
.pa-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 8px; flex: 1; min-height: 0;
}
.pa-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
  display: flex; flex-direction: column; min-height: 0;
}
.pa-card-head {
  display: flex; align-items: baseline; gap: 6px;
  padding: 6px 10px 4px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.pa-card-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--txt-soft);
}
.pa-card-sub { font-size: 9px; color: var(--txt-muted); }
.pa-card-kpi { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--txt-main); }
.pa-card-body { flex: 1; min-height: 0; overflow: hidden; }
/* Radar chart nimmt den ganzen body */
.pa-radar-body { padding: 0; }

/* Zeilen in Info-Karten */
.pa-row {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-bottom: 1px solid var(--line);
  font-size: 11px; min-height: 0;
}
.pa-row:last-child { border-bottom: none; }
.pa-row-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pa-row-name { font-weight: 700; color: var(--txt-main); width: 28px; flex-shrink: 0; }
.pa-row-val  { font-weight: 700; color: var(--txt-main); min-width: 52px; text-align: right; font-family: 'Cascadia Code','Consolas',monospace; font-size: 11px; }
.pa-row-val2 { color: var(--txt-muted); min-width: 38px; text-align: right; font-family: 'Cascadia Code','Consolas',monospace; font-size: 10px; }
.pa-row-bar-wrap { flex: 1; min-width: 0; height: 4px; background: var(--line); border-radius: 2px; overflow: visible; position: relative; }
.pa-row-bar-center { position: absolute; top: 0; height: 4px; border-radius: 2px; transition: left .18s, width .18s, background .18s; }
/* Inline Deviation-Balken (zentriert auf 50%) */
.pa-dev-bar-wrap { flex: 1; min-width: 0; height: 4px; background: var(--line); border-radius: 2px; position: relative; }
.pa-dev-bar { position: absolute; top: 0; height: 4px; border-radius: 2px; }

/* Status-Chips */
.pa-chip {
  font-size: 9px; font-weight: 700; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 999px; border: 1px solid; flex-shrink: 0;
}
.pa-chip.ok     { background: #e6f4e6; color: #107c10; border-color: #8bcb8b; }
.pa-chip.warn   { background: #fff3e0; color: #c47a1a; border-color: #f3c57a; }
.pa-chip.danger { background: #fde8e8; color: #d13438; border-color: #f1a0a0; }

/* Paar-Karte spezifisch */
.pa-pair-block { display: flex; flex-direction: column; justify-content: space-evenly; height: 100%; padding: 4px 0; }
.pa-pair-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
}
.pa-pair-row:last-child { border-bottom: none; }
.pa-pair-label { font-size: 11px; font-weight: 700; color: var(--txt-soft); width: 64px; flex-shrink: 0; }
.pa-pair-delta { font-size: 16px; font-weight: 700; font-family: 'Cascadia Code','Consolas',monospace; color: var(--txt-main); min-width: 58px; }
.pa-pair-detail { font-size: 10px; color: var(--txt-muted); flex: 1; }

/* Electrical card rows */
.pa-el-row {
  display: grid;
  grid-template-columns: 7px 28px 1fr 1fr 18px;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.pa-el-row:last-child { border-bottom: none; }
.pa-el-header {
  font-size: 9px; font-weight: 700; letter-spacing: .05em;
  color: var(--txt-muted);
  border-bottom: 1px solid var(--line) !important;
  padding: 2px 8px;
}
.pa-rank-header {
  min-height: 20px;
  border-bottom: 1px solid var(--line) !important;
  padding: 2px 10px;
}
/* Universal spacer row — matches the Electrical ΔV/P-loss header height */
.pa-spacer-row {
  display: block;
  height: 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
body.dark-mode .pa-rank-header  { border-bottom-color: #2a2a2a !important; }
body.dark-mode .pa-spacer-row   { border-bottom-color: #2a2a2a; }
.pa-el-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pa-el-name { font-weight: 700; color: var(--txt-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pa-el-vdrop {
  font-family: 'Cascadia Code','Consolas',monospace;
  font-weight: 700; color: var(--txt-main);
  text-align: right; font-size: 11px;
}
.pa-el-ploss {
  font-family: 'Cascadia Code','Consolas',monospace;
  font-weight: 700; color: var(--txt-main);
  text-align: right; font-size: 11px;
}
body.dark-mode .pa-el-row { border-bottom-color: #2a2a2a; }
body.dark-mode .pa-el-header { border-bottom-color: #2a2a2a !important; }

/* Rang-Karte spezifisch */
.pa-rank-row {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-bottom: 1px solid var(--line); font-size: 11px;
}
.pa-rank-row:last-child { border-bottom: none; }
.pa-rank-num  { font-size: 10px; font-weight: 700; color: var(--txt-muted); width: 18px; flex-shrink: 0; }
.pa-rank-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pa-rank-name { font-weight: 700; color: var(--txt-main); width: 28px; flex-shrink: 0; }
.pa-rank-amp  { font-weight: 700; font-family: 'Cascadia Code','Consolas',monospace; min-width: 46px; text-align: right; color: var(--txt-main); }
.pa-rank-bar-wrap { flex: 1; height: 4px; background: var(--line); border-radius: 2px; }
.pa-rank-bar  { height: 4px; border-radius: 2px; transition: width .18s; }

/* Dark mode overrides */
body.dark-mode .pa-main-wrap  { background: #1e1e1e; border-color: #2f2f2f; }
body.dark-mode .pa-main-head  { border-bottom-color: #2a2a2a; }
body.dark-mode .pa-mode-btn   { background: transparent; color: #666; border-color: #3a3a3a; }
body.dark-mode .pa-mode-btn:not(.active):hover { background: #252525; color: #c8c8c8; border-color: #555; }
body.dark-mode .pa-card       { background: #1e1e1e; border-color: #2f2f2f; }
body.dark-mode .pa-card-head  { border-bottom-color: #2a2a2a; }
body.dark-mode .pa-row        { border-bottom-color: #2a2a2a; }
body.dark-mode .pa-pair-row   { border-bottom-color: #2a2a2a; }
body.dark-mode .pa-rank-row   { border-bottom-color: #2a2a2a; }
body.dark-mode .pa-chip.ok     { background: #1a2e1a; color: #4caf50; border-color: #2d5a2d; }
body.dark-mode .pa-chip.warn   { background: #2d1f00; color: #f5a623; border-color: #5a3d00; }
body.dark-mode .pa-chip.danger { background: #2d1414; color: #e05252; border-color: #5a2a2a; }

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

/* Section titles */
body.dark-mode .section-title,
body.dark-mode .main-title,
body.dark-mode .pa-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); }
