/* ============================================================
   Twin Lions operator console — design system (spec §12.1)
   Dense, technical, calm. Brand royal blue from the Twin Lions
   logo; status colours (green/amber/red) stay load-bearing data.
   ============================================================ */

:root {
  /* Dark (default) */
  --ink-900: #0E1116;   /* page base — cool ink, not pure black */
  --ink-800: #151A21;   /* panel, card */
  --ink-700: #1D242D;   /* raised, row hover */
  --line:    #262E38;   /* hairline borders */
  --text-hi: #E6EAF0;
  --text-lo: #8A94A3;

  /* Twin Lions royal blue, lifted for dark surfaces */
  --accent:          #7186FF;
  --accent-contrast: #0B0E2A;   /* text on accent */
  --accent-dim:      #7186FF24;
  --brand-blue:      #232DBE;   /* the logo blue, fixed across themes */
  --brand-gold:      #F0B429;

  --live: #3FB950;
  --warn: #D29922;
  --down: #F85149;
  --live-dim: #3FB95022;
  --warn-dim: #D2992222;
  --down-dim: #F8514922;

  --font-ui: "Geist", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --sidebar-w: 250px;
  --sidebar-w-collapsed: 58px;
  --radius: 6px;
  --row-h: 34px;
}

[data-theme="light"] {
  --ink-900: #F5F6F9;
  --ink-800: #FFFFFF;
  --ink-700: #EEF0F5;
  --line:    #E1E5EC;
  --text-hi: #1B2430;
  --text-lo: #5A6472;

  --accent:          #232DBE;   /* the logo blue itself */
  --accent-contrast: #FFFFFF;
  --accent-dim:      #232DBE14;

  --live: #1A7F37;
  --warn: #9A6700;
  --down: #CF222E;
  --live-dim: #1A7F3716;
  --warn-dim: #9A670016;
  --down-dim: #CF222E12;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink-900);
  color: var(--text-hi);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-dim); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: -0.01em;
}

/* ---------- App frame: one sidebar → content ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--ink-800);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
  transition: width .16s ease;
}

.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px;
}
.tile {
  width: 32px; height: 32px; flex: none;
  border-radius: 8px;
  background: var(--brand-blue);
  color: var(--brand-gold);
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
  font-family: var(--font-mono);
}
.sidebar-head .names { min-width: 0; }
.sidebar-head .app-name {
  font-size: 13px; font-weight: 600; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-head .workspace {
  color: var(--text-lo); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .07em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar nav { padding: 4px 10px; flex: 1; }

.nav-label {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-lo);
  padding: 14px 8px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius);
  color: var(--text-hi);
  font: inherit;
  border: none; background: transparent; cursor: pointer;
  text-align: left;
  transition: background .1s ease;
}
.nav-item:hover { background: var(--ink-700); text-decoration: none; }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-item svg {
  width: 16px; height: 16px; flex: none;
  stroke-width: 1.7; color: var(--text-lo);
}
.nav-item.active svg { color: var(--accent); }
.nav-item .label {
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item .chev {
  width: 13px; height: 13px;
  color: var(--text-lo);
  transition: transform .14s ease;
}
.nav-item .chev.open { transform: rotate(90deg); }

/* Botpress-style sub-links: indented under the item, hairline guide */
.nav-sub {
  margin: 2px 0 4px 17px;
  border-left: 1px solid var(--line);
  padding-left: 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.nav-sub a {
  display: block;
  padding: 5px 9px;
  border-radius: var(--radius);
  color: var(--text-lo);
  font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-sub a:hover { background: var(--ink-700); color: var(--text-hi); text-decoration: none; }
.nav-sub a.active { color: var(--accent); background: var(--accent-dim); }

.sidebar-foot {
  padding: 10px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}

/* Collapsed: icon rail */
.app.collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.app.collapsed .sidebar-head { justify-content: center; padding: 14px 0 12px; }
.app.collapsed .sidebar-head .names,
.app.collapsed .nav-label,
.app.collapsed .nav-item .label,
.app.collapsed .nav-item .chev,
.app.collapsed .nav-sub { display: none; }
.app.collapsed .sidebar nav { padding: 4px 11px; }
.app.collapsed .nav-item { justify-content: center; padding: 8px 0; }
.app.collapsed .sidebar-foot .nav-item { justify-content: center; }

.content { flex: 1; min-width: 0; padding: 26px 34px 64px; max-width: 1240px; }

/* ---------- Page header ---------- */

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px;
}
.page-head h1 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.page-head .sub { color: var(--text-lo); font-size: 12.5px; margin-top: 3px; }

/* ---------- Cards ---------- */

.card {
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}
.card > h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; }
.card .hint { color: var(--text-lo); font-size: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .content > * { animation: rise .26s ease both; }
  .content > *:nth-child(2) { animation-delay: .04s; }
  .content > *:nth-child(3) { animation-delay: .08s; }
  .content > *:nth-child(4) { animation-delay: .12s; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } }
}

/* ---------- Tables ---------- */

table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-lo);
  padding: 0 10px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.grid td {
  height: var(--row-h);
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
table.grid td.wrap { white-space: normal; }
table.grid tbody tr { transition: background .1s ease; }
table.grid tbody tr:hover { background: var(--ink-700); }
table.grid .num { text-align: right; font-family: var(--font-mono); font-size: 12px; }
td .mono { color: var(--text-lo); }

/* ---------- Forms ---------- */

label.field { display: block; margin-bottom: 12px; }
label.field > span {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-lo); text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 4px;
}
input[type=text], input[type=number], input[type=time], input[type=date],
input[type=password], input[type=email], input[type=file], select, textarea {
  width: 100%;
  background: var(--ink-900);
  color: var(--text-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 9px;
  font: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { resize: vertical; font-family: var(--font-ui); }
textarea.mono { font-family: var(--font-mono); font-size: 12px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type=checkbox] { accent-color: var(--accent); }
input.cell {
  width: 90px; padding: 3px 6px; font-family: var(--font-mono); font-size: 12px;
}
input.cell-time { width: 84px; padding: 3px 6px; font-family: var(--font-mono); font-size: 12px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink-800);
  color: var(--text-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  font: inherit; font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .05s ease, filter .12s ease;
}
.btn:hover { border-color: var(--text-lo); background: var(--ink-700); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn.primary:hover { filter: brightness(1.1); background: var(--accent); }
.btn.danger { color: var(--down); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-lo); }
.btn.ghost:hover { color: var(--text-hi); border-color: var(--line); background: var(--ink-700); }
.btn.ghost.danger:hover { color: var(--down); }

/* ---------- Status ---------- */

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.live { background: var(--live); }
.dot.warn { background: var(--warn); }
.dot.down { background: var(--down); }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
}
.pill.live { background: var(--live-dim); color: var(--live); }
.pill.warn { background: var(--warn-dim); color: var(--warn); }
.pill.down { background: var(--down-dim); color: var(--down); }
.pill.neutral { background: var(--ink-700); color: var(--text-lo); }

/* ---------- Channel strip ---------- */

.strip { display: flex; flex-wrap: wrap; gap: 4px; }
.strip a.cell {
  width: 16px; height: 16px;
  border-radius: 3px;
  display: block;
  transition: transform .1s ease, box-shadow .1s ease;
}
.strip a.cell:hover { transform: scale(1.35); z-index: 1; }
.strip a.cell.live { background: var(--live); }
.strip a.cell.live:hover { box-shadow: 0 0 0 3px var(--live-dim); }
.strip a.cell.warn { background: var(--warn); }
.strip a.cell.warn:hover { box-shadow: 0 0 0 3px var(--warn-dim); }
.strip a.cell.down { background: var(--down); animation: pulse 2s ease infinite; }
.strip a.cell.down:hover { box-shadow: 0 0 0 3px var(--down-dim); }
@keyframes pulse { 50% { opacity: .55; } }
.strip-legend { display: flex; gap: 16px; margin-top: 10px; color: var(--text-lo); font-size: 12px; }

/* ---------- Stat tiles ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--ink-800); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px;
}
.stat .v { font-size: 23px; font-weight: 600; font-family: var(--font-mono); letter-spacing: -0.02em; }
.stat .k { color: var(--text-lo); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }

/* ---------- Progress bars ---------- */

.bar {
  height: 8px; border-radius: 999px;
  background: var(--ink-700);
  overflow: hidden;
}
.bar > span {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .4s ease;
}
.bar > span.warn { background: var(--warn); }
.bar > span.down { background: var(--down); }

/* ---------- Chat log ---------- */

.chat { display: flex; flex-direction: column; gap: 6px; max-width: 620px; }
.msg {
  padding: 7px 11px; border-radius: 12px;
  max-width: 78%; font-size: 13px; overflow-wrap: anywhere;
}
.msg .text { white-space: pre-wrap; }  /* line breaks live here, not in the markup */
.msg.in  { background: var(--ink-700); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--accent-dim); color: var(--text-hi); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .meta {
  display: block; margin-top: 2px; text-align: right;
  color: var(--text-lo); font-size: 10.5px; font-family: var(--font-mono);
  opacity: .85;
}
.msg.note { background: transparent; border: 1px dashed var(--line); color: var(--text-lo); align-self: center; font-size: 12px; }
.msg.failed { background: var(--down-dim); border: 1px solid var(--down); }
.msg.failed .meta { color: var(--down); font-weight: 600; }

/* ---------- Misc ---------- */

.muted { color: var(--text-lo); }
.small { font-size: 12px; }
.right { text-align: right; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
hr.hairline { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.flash {
  border: 1px solid var(--line); border-left: 3px solid var(--live);
  background: var(--ink-800); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px; font-size: 13px;
}
.flash.error { border-left-color: var(--down); }
.flash.warning { border-left-color: var(--warn); }

.empty {
  border: 1px dashed var(--line); border-radius: 8px;
  padding: 32px; text-align: center; color: var(--text-lo);
}
.empty strong { color: var(--text-hi); display: block; margin-bottom: 4px; }

.htmx-swapping { opacity: 0; transition: opacity .12s ease; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(640px 420px at 20% 10%, var(--accent-dim), transparent 60%),
    var(--ink-900);
}
.login-card {
  width: 340px; background: var(--ink-800);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 28px;
}
.login-card h1 { font-size: 16px; margin: 0 0 4px; }
.login-card .sub { color: var(--text-lo); font-size: 12px; margin-bottom: 20px; }
