/* IIS Log Viewer — chart chrome + layout.
   Design tokens from the validated reference palette; dark is the default theme,
   [data-theme="light"] opts into light. */

:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222221;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;  /* blue    — humans / primary */
  --series-2: #d95926;  /* orange  — bots / secondary */
  --series-3: #199e70;  /* aqua */
  --series-4: #c98500;  /* yellow */
  --series-5: #d55181;  /* magenta */
  --series-6: #008300;  /* green */
  --series-7: #9085e9;  /* violet */
  --series-8: #e66767;  /* red */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --status-neutral: #898781;
  --seq-lo: #16233a;  /* dark surface end — near zero recedes */
  --seq-hi: #86b6ef;  /* light end — high values pop on dark */
  --accent: var(--series-1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --seq-lo: #cde2fb;  /* light surface end — near zero recedes */
  --seq-hi: #0d366b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* ---- header ---- */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: 0.2px; }
a.brand {
  color: inherit; text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px;
}
a.brand img { margin-right: 3px; }
a.brand span { transition: color 0.15s; }
/* on hover the wordmark takes the icon's bar colors: IIS / Log / Viewer */
a.brand:hover .b1 { color: var(--series-1); }
a.brand:hover .b2 { color: var(--series-2); }
a.brand:hover .b3 { color: var(--series-3); }
a.brand img { display: block; border-radius: 5px; }
header .spacer { flex: 1; }
.live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.live-dot::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--status-critical);
}
.live-dot.on::before { background: var(--status-good); }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---- tabs ---- */
nav.tabs {
  display: flex; gap: 4px; padding: 8px 20px 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
nav.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-secondary); padding: 8px 14px 10px; cursor: pointer;
  font-size: 14px; font-family: inherit;
}
nav.tabs button:hover { color: var(--text-primary); }
nav.tabs button.active {
  color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600;
}
nav.tabs button .count { color: var(--text-muted); font-size: 12px; margin-left: 6px; }

/* ---- filter row ---- */
.filters {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px;
}
.filters .group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.filters .group button {
  background: none; border: none; color: var(--text-secondary); padding: 6px 12px;
  cursor: pointer; font-size: 13px; font-family: inherit;
}
.filters .group button + button { border-left: 1px solid var(--border); }
.filters .group button.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.filters select, .filters input[type="search"] {
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
  font-size: 13px; font-family: inherit;
}
.filters input[type="search"] { width: 220px; }
.filters label { font-size: 12px; color: var(--text-muted); }

/* ---- layout grid ---- */
main { padding: 8px 20px 40px; max-width: 1720px; margin: 0 auto; }
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(12, 1fr);
}
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 0;
  transition: opacity 0.15s;
}
.panel.loading { opacity: 0.55; }
.panel h2 {
  margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--text-secondary);
  display: flex; align-items: center; gap: 8px;
}
.panel h2 .sub { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.panel h2 .right { margin-left: auto; display: inline-flex; gap: 4px; }
.panel .chart { width: 100%; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
@media (max-width: 1100px) {
  .span-8, .span-6, .span-4, .span-3 { grid-column: span 12; }
}
.hidden { display: none !important; }

/* ---- stat tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 14px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; min-width: 0;
}
.tile .label { font-size: 12px; color: var(--text-muted); }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- tables ---- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; color: var(--text-muted); font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.4px;
  padding: 6px 8px; border-bottom: 1px solid var(--grid);
}
table.data td { padding: 5px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
table.data th.num { text-align: right; }
table.data td.key {
  max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
.inline-bar {
  display: block; height: 4px; border-radius: 2px; background: var(--series-1);
  margin-top: 3px; min-width: 2px;
}
.scroll-x { overflow-x: auto; }
.table-wrap { max-height: 420px; overflow-y: auto; }

/* ---- status chips ---- */
.chip {
  display: inline-block; padding: 0 7px; border-radius: 10px; font-size: 11px;
  font-weight: 600; line-height: 18px; color: #fff;
}
.chip.s2 { background: var(--status-good); }
.chip.s3 { background: var(--status-neutral); }
.chip.s4 { background: var(--status-warning); color: #0b0b0b; }
.chip.s5 { background: var(--status-critical); }
.bot-mark { color: var(--series-2); font-size: 11px; font-weight: 600; }

/* ---- live tail ---- */
.tail {
  font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  max-height: 320px; overflow-y: auto; margin-top: 6px;
}
.tail .row { display: flex; gap: 10px; padding: 2px 4px; border-bottom: 1px solid var(--grid); align-items: baseline; }
.tail .row .t { color: var(--text-muted); flex: none; }
.tail .row .m { flex: none; width: 52px; color: var(--text-secondary); }
.tail .row .u { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tail .row .who { flex: none; color: var(--text-muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tail .row.new { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--surface-2); } to { background: transparent; } }

/* ---- hint / empty states ---- */
.hint-card {
  color: var(--text-secondary); font-size: 13px; padding: 18px 6px; line-height: 1.6;
}
.hint-card code { background: var(--surface-2); border-radius: 4px; padding: 1px 6px; }
.hint-card a { color: var(--accent); }
.attribution { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ---- overlay for first-run parsing ---- */
#overlay {
  position: fixed; inset: 0; background: var(--page); z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
#overlay .big { font-size: 22px; font-weight: 600; }
#overlay .bar { width: 320px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
#overlay .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.4s; }

/* ---- modal (row drill-down) ---- */
#modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
#modal .box {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  max-width: 720px; width: 92%; max-height: 80vh; overflow-y: auto; padding: 18px 20px;
}
#modal h3 { margin: 0 0 10px; font-size: 14px; }
#modal table.data td:first-child { color: var(--text-muted); white-space: nowrap; }
#modal td { word-break: break-all; }

footer { text-align: center; color: var(--text-muted); font-size: 12px; padding: 18px; }
