/* static/css/metrics.css */
/* ===== BodyPlus — Metrics (ONE PAGE, tidy, RTL+LTR) ===== */

/* Base / Reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  direction: rtl;
  background: #f8fafc;
  color: #111827;
  font-family: "Rubik","Heebo","Assistant", system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tokens */
:root{
  --maxw: 1800px;
  --radius: 14px;
  --pad: 14px;
  --gap: 10px;

  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0b4bff;

  --shadow: 0 2px 10px rgba(0,0,0,.05);
  --shadowH: 0 10px 26px rgba(0,0,0,.10);

  --kpiValue: 18px;
  --mono: 12px;
  --labelW: clamp(160px, 24vw, 320px);

  --ok:   #10b981;
  --warn: #f59e0b;
  --err:  #ef4444;

  --pill-bg: #eef2ff;
  --pill-ink:#1e3a8a;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0b1020; --card:#10172a; --ink:#e5e7eb; --muted:#9aa4b2; --line:#1f2a44; --accent:#60a5fa;
    --shadow: 0 2px 10px rgba(0,0,0,.45);
    --shadowH: 0 12px 30px rgba(0,0,0,.55);
    --pill-bg:#0f1b3f; --pill-ink:#93c5fd;
  }
  body{ background: var(--bg); }
}

/* Utilities */
.mt-2{ margin-top: 8px; }
.mt-4{ margin-top: 16px; }
.small{ font-size: 12px; }
.tiny{ font-size: 11px; }
.muted{ color: var(--muted); }
.hidden{ display: none !important; }
.inline{ display: inline-flex; align-items: center;}
.gap-6{ gap: 6px; } .gap-8{ gap: 8px; } .gap-10{ gap: 10px; }
.nowrap{ white-space: nowrap; }
.clamp-text{ max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ltr-num{ direction:ltr; unicode-bidi: plaintext; font-variant-numeric: tabular-nums; }
.center{ display: grid; place-items: center; }
.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: var(--mono);
}

/* Page layout */
.bp-container{ max-width: var(--maxw); margin-inline: auto; padding: var(--pad); }
.bp-section{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
  margin-bottom: var(--pad);
  transition: box-shadow .18s ease;
}
.bp-section:hover{ box-shadow: var(--shadowH); }
.sec-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.sec-title{ margin:0; font-size:15px; font-weight:700; color:var(--ink); }
.actions{ display:flex; gap:8px; align-items:center; }

/* Top bar / search / buttons */
.topbar{ display:flex; align-items:center; gap:10px; flex-wrap: wrap; }
.topbar .search{ flex:1; }
.topbar input{
  width:100%; padding:9px 12px; border:1px solid var(--line); border-radius:10px;
  background: var(--card); color: var(--ink); outline:none;
}
.topbar input:focus{ border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* כפתורים כלליים בדשבורד (גם ל־RAW, Skeleton וכו') */
.btn{
  background:#ffffff;
  color: var(--ink);
  border:1px solid var(--line);
  padding:7px 10px;
  border-radius:10px;
  cursor:pointer;
  transition: box-shadow .15s ease, transform .05s ease, background .15s ease;
}
.btn:hover{ box-shadow:0 2px 6px rgba(0,0,0,.12); }
.btn:active{ transform: translateY(1px); }
.btn.ghost{ background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.small{ padding: 5px 8px; font-size: 12px; }

/* info dot */
.info{
  display:inline-flex; align-items:center; justify-content:center;
  width:14px; height:14px; border-radius:50%;
  background: var(--accent); color:#fff; font-size:11px; margin-inline-start:6px;
}

/* KPIs */
.kpis{ display:grid; gap:8px; grid-template-columns:repeat(3, minmax(0,1fr)); }
@media (min-width:900px){ .kpis{ grid-template-columns:repeat(6, minmax(0,1fr)); } }
@media (min-width:1300px){ .kpis{ grid-template-columns:repeat(9, minmax(0,1fr)); } }
.kpi{
  background: var(--card); border:1px solid var(--line); border-radius:12px; padding:10px; min-width:0;
  display:flex; flex-direction:column; gap:4px;
}
.kpi .label{ font-size:11px; color:var(--muted); }
.kpi .value{
  font-size: var(--kpiValue); font-weight:700; color:var(--ink);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-variant-numeric: tabular-nums;
}
.kpi .value span{ direction:ltr; unicode-bidi: plaintext; }

/* Sections grid (ALL metrics visible) */
.sections-grid{
  display:grid; gap: var(--pad);
  grid-template-columns: 1fr;
}
@media (min-width: 980px){ .sections-grid{ grid-template-columns: 1fr 1fr; } }
@media (min-width: 1400px){ .sections-grid{ grid-template-columns: 1fr 1fr 1fr; } }

/* Rows (label → value) */
.rows{ display:grid; gap:6px; }
.row{ display:grid; grid-template-columns: var(--labelW) 1fr; gap:12px; align-items:center; }
.row .label{ justify-self:end; color:var(--ink); font-weight:600; font-size:13px; }
.row .val{
  justify-self:start; color:var(--ink); font-weight:600; font-size:13px;
  display:flex; align-items:center; gap:8px; min-width: 0;
}
@media (max-width:720px){
  .row{ grid-template-columns: 1fr; gap:6px; }
  .row .label{ justify-self:start; }
}

/* VSTACK for R over L (Right is first, Left below) */
.vstack{ display:flex; flex-direction:column; gap:4px; }
.vitem{ display:flex; align-items:center; gap:6px; }
.vitem .side{ font-size:11px; color: var(--muted); }
.low-conf{ opacity:.6; text-decoration: underline dotted 1px; }

/* Neutral chips / confidence badges */
.pill{
  background: var(--pill-bg); color: var(--pill-ink);
  border-radius: 999px; padding: 2px 8px; font-size: 11px; white-space: nowrap;
}
/* State colors for pills */
.pill.ok   { background: #dcfce7; color:#166534; }
.pill.warn { background: #fef3c7; color:#92400e; }
.pill.err  { background: #fee2e2; color:#991b1b; }

/* Health pills (for stream/runner/etc) */
.health-pill{ display:inline-block; padding:.2rem .55rem; border-radius:.6rem; font-weight:700; }
.health-pill.ok   { background:#dcfce7; color:#166534; }
.health-pill.warn { background:#fef3c7; color:#92400e; }
.health-pill.err  { background:#fee2e2; color:#991b1b; }

/* Indicator bar (critical summaries) */
#indicator_bar{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
  padding:6px 8px; border:1px solid var(--line); border-radius:10px; background: var(--card);
}
#indicator_bar .pill{ margin-inline-end:2px; }
#indicator_detail{ font-size:12px; color:var(--muted); }

/* Alerts */
.alerts{ display:grid; gap:8px; grid-template-columns:repeat(1, minmax(0,1fr)); }
@media (min-width:900px){ .alerts{ grid-template-columns:repeat(2, minmax(0,1fr)); } }
@media (min-width:1300px){ .alerts{ grid-template-columns:repeat(3, minmax(0,1fr)); } }
.alerts .alert{
  display:flex; align-items:center; gap:10px; border:1px solid var(--line);
  border-radius:10px; padding:10px; background:var(--card);
}
.badge{ font-size:11px; padding:2px 6px; border-radius:999px; color:#fff; }
.badge.ok{   background: var(--ok); }
.badge.warn{ background: var(--warn); }
.badge.err{  background: var(--err); }

/* Misc grid (for uncategorized tiles) */
.misc-grid{ display:grid; gap:8px; grid-template-columns:repeat(2, minmax(0,1fr)); }
@media (min-width:1000px){ .misc-grid{ grid-template-columns:repeat(3, minmax(0,1fr)); } }
@media (min-width:1500px){ .misc-grid{ grid-template-columns:repeat(4, minmax(0,1fr)); } }

/* Also support the #misc-grid id used by the page */
#misc-grid{ display:grid; gap:8px; grid-template-columns:repeat(3, minmax(0,1fr)); }
@media (max-width:900px){ #misc-grid{ grid-template-columns:repeat(2, minmax(0,1fr)); } }

.tile{
  border:1px solid var(--line); border-radius:10px; padding:10px; background:var(--card);
  display:flex; align-items:center; justify-content:space-between; gap:8px; min-width:0;
}
.tile .name{
  font-size:12px; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.tile .val{
  font-weight:700; font-size:14px; direction:ltr; unicode-bidi: plaintext;
  font-variant-numeric: tabular-nums; max-width: 40%; text-overflow: ellipsis; overflow: hidden;
}

/* Tables */
.overflow-x-auto{ overflow-x: auto; }
table{ width:100%; border-collapse: collapse; }
thead th{
  position: sticky; top:0; z-index: 1;
  background: var(--card); color: var(--ink); font-weight:700; border-bottom:1px solid var(--line);
}
td, th{ padding:8px 10px; border-bottom:1px solid var(--line); font-size:13px; }
tbody tr:hover{ background: rgba(0,0,0,.03); }
@media (prefers-color-scheme: dark){ tbody tr:hover{ background: rgba(255,255,255,.03); } }

/* Scrollbars */
*::-webkit-scrollbar{ width:10px; height:10px; }
*::-webkit-scrollbar-thumb{ background:#c7ced6; border-radius:8px; }
*::-webkit-scrollbar-track{ background:transparent; }
@media (prefers-color-scheme: dark){ *::-webkit-scrollbar-thumb{ background:#44506a; } }

/* Raw data viewer */
.raw-box{
  border:1px solid var(--line); border-radius:10px; background: var(--card); padding:8px;
}
#rawDataJSON{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px; line-height: 1.4; white-space: pre; direction:ltr; unicode-bidi: plaintext;
  max-height: 320px; overflow:auto; margin:0;
}
