/* =============================================================================
   ADA observability deck — phosphor-terminal stylesheet.

   Only the bits Tailwind utilities don't cover comfortably live here:
   the CSS-var palette, the scan-line overlay, table rhythm, hairline rules,
   the wordmark cursor pulse, and the few bespoke component aliases used
   in index.html (.data-table, .chip, .filter-label, etc.).
   ============================================================================= */

:root {
  /* Dark phosphor palette — quoted as raw RGB triplets so Tailwind's
     `rgb(var(--c-ink) / <alpha-value>)` syntax can compose opacity. */
  --c-paper:  10  14  20;   /* #0a0e14 */
  --c-ink:    197 200 198;  /* #c5c8c6 */
  --c-muted:  92  99  112;  /* #5c6370 */
  --c-rule:   28  33  40;   /* #1c2128 */
  --c-accent: 86  182 194;  /* #56b6c2 */
  --c-good:   152 195 121;  /* #98c379 */
  --c-warn:   224 108 117;  /* #e06c75 */
  --c-amber:  229 192 123;  /* #e5c07b */
}

html:not(.dark) {
  /* Light-mode inversion — used by the toggle in the status strip.
     Same palette, redistributed for high-contrast on paper white. */
  --c-paper:  248 248 244;  /* #f8f8f4 — warm paper, never pure white */
  --c-ink:     34  41  53;  /* #222935 */
  --c-muted:  108 117 132;  /* #6c7584 */
  --c-rule:   220 221 217;  /* #dcddd9 */
  --c-accent:  20 122 132;  /* darker cyan for light bg */
  --c-good:    72 132  52;  /* #486834 */
  --c-warn:   178  68  74;  /* #b2444a */
  --c-amber:  152 109  41;  /* #986d29 */
}

html, body { background: rgb(var(--c-paper)); color: rgb(var(--c-ink)); }
[x-cloak] { display: none !important; }
body { font-feature-settings: "tnum", "calt", "ss01"; }

/* ── Scan-line overlay — fixed, behind everything, only in dark mode.
       Pair of CSS gradients with very low opacity creates a phosphor effect
       without ever competing with content. */
.scanlines {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(86,182,194,0.020) 0px,
      rgba(86,182,194,0.020) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(ellipse at center top, rgba(86,182,194,0.04), transparent 70%);
  mix-blend-mode: screen;
  opacity: 0.9;
}
html:not(.dark) .scanlines { opacity: 0.15; }

/* ── Status strip: a single-row monospace readout. */
.status-strip {
  font-feature-settings: "tnum";
  background: rgb(var(--c-paper));
  position: sticky; top: 0; z-index: 30;
  height: 33px;
}

/* ── Wordmark on the login screen, with a single calm phosphor pulse. */
.wordmark { font-family: 'IBM Plex Mono', monospace; line-height: 1; }
.pulse-dot {
  display: inline-block; width: 10px; height: 10px;
  background: rgb(var(--c-accent));
  border-radius: 999px;
  vertical-align: middle;
  animation: pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  box-shadow: 0 0 14px 2px rgba(86,182,194,0.55);
}
@keyframes pulse {
  0%, 100% { opacity: 0.95; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.85); }
}

/* ── Side nav: active-row cursor (a thin animated underscore). */
.sidenav { background: rgb(var(--c-paper)); }
.nav-active span:first-child { color: rgb(var(--c-ink)); }
.nav-active .text-muted\/60   { color: rgb(var(--c-accent) / 0.7) !important; }
.nav-cursor {
  height: 1px; width: 14px;
  background: rgb(var(--c-accent));
  position: relative;
  animation: blink 1.1s steps(2, end) infinite;
}
@keyframes blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ── Surface headers — typographic punch without competing with data. */
.surface-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 14px; margin-bottom: 22px;
  border-bottom: 1px solid rgb(var(--c-rule));
}
.surface-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: rgb(var(--c-ink));
}

/* ── Filter strip + chips: small caps, tight tracking, low chrome. */
.filters {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-label {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: rgb(var(--c-muted)); margin-right: 6px;
}
.chip, .chip-active, .chip-accent {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.05em;
  padding: 4px 10px;
  border: 1px solid rgb(var(--c-rule));
  background: transparent;
  color: rgb(var(--c-muted));
  cursor: pointer; transition: all 0.15s ease;
  text-transform: lowercase;
}
.chip:hover { color: rgb(var(--c-ink)); border-color: rgb(var(--c-accent) / 0.4); }
.chip-active {
  color: rgb(var(--c-paper));
  background: rgb(var(--c-accent));
  border-color: rgb(var(--c-accent));
}
.chip-accent {
  color: rgb(var(--c-accent));
  border-color: rgb(var(--c-accent) / 0.5);
}
.chip-accent:hover {
  background: rgb(var(--c-accent) / 0.1);
  color: rgb(var(--c-ink));
}
.input-bare {
  background: transparent;
  color: rgb(var(--c-ink));
  border: 1px solid rgb(var(--c-rule));
  border-radius: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 4px 10px;
  min-width: 240px;
  outline: none;
  transition: border-color 0.15s ease;
}
.input-bare:focus { border-color: rgb(var(--c-accent)); }
.input-bare::placeholder { color: rgb(var(--c-muted) / 0.7); }

/* ── Data table: hairline rules, tabular numerics, hover-cyan border. */
.data-table {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: 12px;
  font-feature-settings: "tnum";
}
.data-table thead th {
  text-align: left;
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgb(var(--c-muted));
  padding: 6px 12px 6px 0;
  border-bottom: 1px solid rgb(var(--c-rule));
  position: sticky; top: 0;
  background: rgb(var(--c-paper));
}
.data-table tbody td {
  padding: 6px 12px 6px 0;
  border-bottom: 1px dashed rgb(var(--c-rule) / 0.5);
  height: 28px;
  vertical-align: middle;
  max-width: 360px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table tbody tr:hover td {
  background: rgb(var(--c-accent) / 0.04);
  border-bottom-color: rgb(var(--c-accent) / 0.3);
}
.data-table tbody tr:hover td:first-child {
  box-shadow: inset 2px 0 rgb(var(--c-accent));
}
.row-clickable { cursor: pointer; }

/* ── Per-action positive-rate cards (feedback surface). */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.stat-card {
  border: 1px solid rgb(var(--c-rule));
  padding: 10px 12px;
  background: rgb(var(--c-paper));
}
.sparkbar {
  flex: 1;
  height: 4px;
  background: rgb(var(--c-rule) / 0.6);
  position: relative;
}
.sparkbar-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  background: linear-gradient(90deg,
    rgb(var(--c-good)) 0%,
    rgb(var(--c-amber)) 60%,
    rgb(var(--c-warn)) 100%);
  background-size: 200% 100%;
  background-position: 100% 0;
  transition: width 0.5s ease;
}

/* ── Message thread (conversations detail). */
.message-thread { font-size: 13px; line-height: 1.55; }
.msg { padding: 12px 16px; border-left: 2px solid transparent; }
.msg-user { border-left-color: rgb(var(--c-muted) / 0.5); }
.msg-ada  { border-left-color: rgb(var(--c-accent)); background: rgb(var(--c-accent) / 0.03); }
.msg-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.role-tag {
  font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase;
  padding: 1px 6px;
}
.tag-user { color: rgb(var(--c-muted)); border: 1px solid rgb(var(--c-rule)); }
.tag-ada  { color: rgb(var(--c-accent)); border: 1px solid rgb(var(--c-accent) / 0.5); }
.msg-body { color: rgb(var(--c-ink)); white-space: pre-wrap; word-break: break-word; }
.msg-body p { margin: 0 0 0.6em 0; }
.msg-body code { background: rgb(var(--c-rule)); padding: 1px 5px; font-size: 0.92em; }
.msg-body pre { background: rgb(var(--c-rule)); padding: 8px 12px; margin: 8px 0; overflow-x: auto; font-size: 0.92em; }
.msg-attachments { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.att-chip {
  font-size: 10px; padding: 2px 6px;
  border: 1px solid rgb(var(--c-rule));
  color: rgb(var(--c-muted));
}

/* ── Empty state — bordered, muted, never apologetic. */
.empty-state {
  padding: 28px 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgb(var(--c-muted) / 0.7);
  border-top: 1px dashed rgb(var(--c-rule));
  margin-top: -1px;
}

/* ── Tabular numerics + scroll bar polish. */
.tabular-nums { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgb(var(--c-rule));
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover { background: rgb(var(--c-muted)); }

/* ── Telegram-widget iframe styling tweak. */
#telegramLoginSlot iframe {
  filter: invert(0.92) hue-rotate(170deg) saturate(0.9);
  border-radius: 0 !important;
}
html:not(.dark) #telegramLoginSlot iframe { filter: none; }
