/* ============================================================================
   health-dashboard.css
   Location: frontend/styles/health-dashboard.css

   Companion stylesheet for frontend/pages/health-dashboard.js (the Service
   Status surface). Every rule maps to an hd-* / hd__* class emitted by that
   module. Brand tokens inlined per the convention in regulatory-flags-admin.css
   (no CSS vars). Palette matches the app: brand green #015441, IBM Plex Sans,
   #F4F6F8 canvas, white cards with #E5E7EB borders.

   Status colours follow Lesson 41 — RED is reserved for genuine absence of
   relied-upon data ("No data"); overdue is amber, current is green, idle is
   neutral grey. No loud colour-key legend (aesthetic-restraint).
   ============================================================================ */

.hd-wrap{width:100%;background:#F4F6F8;padding:24px;font-family:'IBM Plex Sans',sans-serif;color:#111827;box-sizing:border-box;min-height:100%;}

/* ── Header ──────────────────────────────────────────────────────────────── */
.hd-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:16px;}
.hd-title{margin:0 0 4px;font-size:22px;font-weight:600;color:#015441;}
.hd-sub{margin:0;font-size:13px;color:#4B5563;line-height:1.5;}
.hd-head__titles{min-width:0;}
.hd-head__right{display:flex;align-items:center;gap:14px;flex:none;}
.hd-refresh{font-family:'IBM Plex Sans',sans-serif;font-size:13px;font-weight:500;background:#FFFFFF;color:#374151;border:1px solid #D1D5DB;border-radius:6px;padding:7px 14px;cursor:pointer;transition:all .15s ease;white-space:nowrap;}
.hd-refresh:hover:not(:disabled){background:#F9FAFB;border-color:#9CA3AF;}
.hd-refresh:disabled{opacity:.6;cursor:default;}

/* ── Vital-signs ECG monitor (decorative) ───────────────────────────────── */
/* A dark mini "patient monitor" with a green heartbeat trace scrolling across.
   The SVG holds two identical 140px ECG cycles and scrolls left by exactly one
   cycle, so the loop is seamless. Cosmetic only (aria-hidden). */
.hd-monitor{position:relative;width:140px;height:40px;background:#04140f;border:1px solid #0b3d2e;border-radius:6px;overflow:hidden;flex:none;box-shadow:inset 0 0 12px rgba(0,0,0,0.55);}
.hd-monitor__ecg{position:absolute;top:0;left:0;display:block;animation:hd-ecg-scroll 2.6s linear infinite;}
.hd-monitor__ecg path{fill:none;stroke:#34D399;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;filter:drop-shadow(0 0 3px rgba(52,211,153,0.7));}
.hd-monitor__dot{position:absolute;top:7px;right:8px;width:6px;height:6px;border-radius:50%;background:#34D399;box-shadow:0 0 6px 1px rgba(52,211,153,0.9);animation:hd-beat 1.3s ease-in-out infinite;}

@keyframes hd-ecg-scroll{from{transform:translateX(0);}to{transform:translateX(-140px);}}
@keyframes hd-beat{0%,100%{transform:scale(1);opacity:.6;}50%{transform:scale(1.5);opacity:1;}}

/* ── Sidebar nav icon = live ECG monitor (the Service Status item) ───────── */
/* The icon itself IS a mini heart-monitor: a luminous-green heartbeat trace that
   scrolls left→right and loops seamlessly — a 32px-wide SVG (two identical 16px
   ECG cycles) clipped to a 16px window and shifted by exactly one cycle, so the
   loop has no visible reset. Always lit as a "platform is alive & monitoring" cue
   at its resting colour; when its tab is active it brightens to match the other
   active nav icons (see the .active override below). Pure CSS + inline SVG. */
.hd-nav-ecg{display:inline-block;width:16px;height:14px;overflow:hidden;line-height:0;flex:none;}
.nav-item[data-tab-id="health-dashboard"] .hd-nav-ecg svg{display:block;width:32px;height:14px;animation:hd-nav-ecg-scroll 2.6s linear infinite;}
.hd-nav-ecg svg path{--ecg-glow-rgb:93,202,165;fill:none;stroke:#5DCAA5;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round;transform-box:fill-box;transform-origin:center;filter:drop-shadow(0 0 2px rgba(var(--ecg-glow-rgb),0.85));animation:hd-nav-ecg-pulse 2.2s ease-in-out infinite,hd-nav-ecg-beat 2.2s ease-in-out infinite;}
/* When Service Status is the active tab, brighten the ECG trace to the same green
   the sibling nav icons take. They inherit it via `.nav-item.active svg { color }`
   (resolves to var(--live) #00c471); tying the stroke to currentColor pins the
   active icon to that one source so it can never drift from the rest of the active
   nav. The resting #5DCAA5 above stays the always-lit monitor look. */
.nav-item[data-tab-id="health-dashboard"].active .hd-nav-ecg svg path{--ecg-glow-rgb:0,196,113;stroke:currentColor;filter:drop-shadow(0 0 2px rgba(var(--ecg-glow-rgb),0.9));}
@keyframes hd-nav-ecg-scroll{from{transform:translateX(-16px);}to{transform:translateX(0);}}
/* Heartbeat glow pulse: flares the trace bright on each beat, then settles — the
   "alive monitor" pulse on top of the horizontal scroll. Colour comes from
   --ecg-glow-rgb (set per state above) so one keyframe serves both resting teal
   and the active bright green; only the blur + alpha animate. */
@keyframes hd-nav-ecg-pulse{
  0%,100%{filter:drop-shadow(0 0 1px rgba(var(--ecg-glow-rgb),0.35));}
  45%{filter:drop-shadow(0 0 5px rgba(var(--ecg-glow-rgb),1));}
}
/* Vertical beat: scales the waveform around its baseline (transform-box:fill-box +
   transform-origin:center → the y=7 mid-line) so the flat segments hold still and
   only the spikes shoot up & dip down. Held compressed most of the cycle, then a
   quick beat at ~50% — the up-and-down pulse of a monitor. Peak 1.35 keeps the
   spikes inside the 14px viewBox (no vertical clipping). Runs alongside the glow
   pulse + the horizontal scroll (all three on different properties/elements). */
@keyframes hd-nav-ecg-beat{
  0%,40%,100%{transform:scaleY(0.78);}
  50%{transform:scaleY(1.35);}
  62%{transform:scaleY(0.92);}
}

@media (prefers-reduced-motion: reduce){
  .hd-monitor__ecg,.hd-monitor__dot,.hd-nav-ecg svg,.hd-nav-ecg svg path{animation:none;}
}
@media (max-width:720px){ .hd-monitor{display:none;} }

/* ── Sub-tab nav ─────────────────────────────────────────────────────────── */
.hd-subnav{display:flex;gap:4px;border-bottom:1px solid #E5E7EB;margin-bottom:18px;}
.hd-subnav__item{font-family:'IBM Plex Sans',sans-serif;font-size:13px;font-weight:500;color:#6B7280;background:transparent;border:none;border-bottom:2px solid transparent;padding:9px 14px;cursor:pointer;transition:color .15s ease,border-color .15s ease;margin-bottom:-1px;}
.hd-subnav__item:hover{color:#111827;}
.hd-subnav__item--active{color:#015441;border-bottom-color:#015441;}

/* ── Meta row + summary ──────────────────────────────────────────────────── */
.hd-meta{display:flex;justify-content:space-between;align-items:baseline;gap:12px;flex-wrap:wrap;margin-bottom:12px;}
.hd-meta__note{font-size:12px;color:#6B7280;}
.hd-meta__time{font-size:11px;color:#9CA3AF;}

.hd-summary{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:14px;}
.hd-sum{display:inline-flex;align-items:center;font-size:12px;font-weight:600;border-radius:6px;padding:5px 10px;background:#F3F4F6;color:#4B5563;border:1px solid #E5E7EB;}
.hd-sum--fresh{background:#D1FAE5;color:#065F46;border-color:#6EE7B7;}
.hd-sum--stale{background:#FEF3C7;color:#92400E;border-color:#F59E0B;}
.hd-sum--nodata{background:#FEE2E2;color:#991B1B;border-color:#FCA5A5;}
.hd-sum--idle{background:#F3F4F6;color:#4B5563;border-color:#D1D5DB;}

/* ── Warnings (degraded telemetry) ───────────────────────────────────────── */
.hd-warn{background:#FFFBEB;border:1px solid #FCD34D;border-radius:6px;padding:10px 12px;font-size:12px;color:#92400E;line-height:1.5;margin-bottom:14px;}

/* ── Source table ────────────────────────────────────────────────────────── */
.hd-table{width:100%;border-collapse:collapse;background:#FFFFFF;border:1px solid #E5E7EB;border-radius:8px;overflow:hidden;font-size:13px;}
.hd-table thead th{text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;color:#6B7280;background:#F9FAFB;padding:10px 14px;border-bottom:1px solid #E5E7EB;}
.hd-table tbody td{padding:12px 14px;border-bottom:1px solid #F3F4F6;vertical-align:middle;}
.hd-table tbody tr:last-child td{border-bottom:none;}
.hd-table tbody tr:hover{background:#FAFBFC;}
.hd-num{text-align:right;white-space:nowrap;}
.hd-src{font-weight:600;color:#111827;}
.hd-cat{color:#6B7280;font-size:12px;}
.hd-last{color:#374151;white-space:nowrap;}
.hd-next{color:#6B7280;white-space:nowrap;font-size:12px;}
.hd-rel{color:#9CA3AF;font-size:11px;}
.hd-unit{color:#9CA3AF;font-size:11px;}
.hd-muted{color:#9CA3AF;}
.hd-err{color:#991B1B;font-weight:600;}

/* ── Status chip ─────────────────────────────────────────────────────────── */
.hd-chip{display:inline-flex;align-items:center;font-size:11px;font-weight:700;letter-spacing:0.03em;border-radius:4px;padding:3px 9px;border:1px solid transparent;}
.hd-chip--fresh{background:#D1FAE5;color:#065F46;border-color:#6EE7B7;}
.hd-chip--stale{background:#FEF3C7;color:#92400E;border-color:#F59E0B;}
.hd-chip--nodata{background:#FEE2E2;color:#991B1B;border-color:#FCA5A5;}
.hd-chip--idle{background:#F3F4F6;color:#4B5563;border-color:#D1D5DB;}

/* ── States ──────────────────────────────────────────────────────────────── */
.hd-loading,.hd-empty,.hd-error{background:#FFFFFF;border:1px dashed #D1D5DB;border-radius:8px;padding:32px;text-align:center;font-size:14px;color:#6B7280;}
.hd-error{border-style:solid;border-color:#FCA5A5;background:#FEF2F2;color:#991B1B;}
.hd-retry{margin-left:10px;font-family:'IBM Plex Sans',sans-serif;font-size:12px;font-weight:500;background:#FFFFFF;color:#991B1B;border:1px solid #FCA5A5;border-radius:6px;padding:5px 12px;cursor:pointer;}
.hd-retry:hover{background:#FEE2E2;}

/* ── Vendor sub-tab placeholders ─────────────────────────────────────────── */
.hd-placeholder{background:#FFFFFF;border:1px dashed #D1D5DB;border-radius:8px;padding:28px;}
.hd-placeholder__title{font-size:16px;font-weight:600;color:#111827;margin-bottom:6px;}
.hd-placeholder__lead{font-size:13px;color:#6B7280;margin:0 0 14px;}
.hd-placeholder__list{margin:0;padding-left:20px;font-size:13px;color:#4B5563;line-height:1.8;}

@media (max-width:720px){
  .hd-table thead{display:none;}
  .hd-table tbody td{display:flex;justify-content:space-between;gap:12px;padding:8px 14px;}
  .hd-table tbody tr{display:block;border-bottom:1px solid #E5E7EB;padding:6px 0;}
  .hd-num{text-align:left;}
}
