/* VB-Orc Mission Control — dark control-room dashboard, vanilla CSS, no build step */

:root {
  --bg: #0a0d12;
  --bg-grid: #0d1119;
  --panel: #10151d;
  --panel-alt: #141b26;
  --border: #232c3a;
  --border-soft: #1a212c;
  --text: #d7e0ea;
  --text-dim: #7c8aa0;
  --text-faint: #4d5a6e;

  --engine: #3aa0ff;
  --engine-dim: #1c4a73;
  --provider: #9aa4b5;
  --provider-dim: #3a4250;

  --live: #35d488;
  --mock: #f5a623;
  --err: #ff5c6c;
  --warn: #f5c518;

  --mono: "Cascadia Code", Consolas, "SFMono-Regular", "Courier New", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100%;
}

body {
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 28px 28px;
  background-color: var(--bg-grid);
}

.scanline-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.0) 0px,
    rgba(255,255,255,0.0) 2px,
    rgba(0,0,0,0.015) 3px,
    rgba(0,0,0,0.015) 4px
  );
  mix-blend-mode: overlay;
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 58px;
  padding: 0 20px;
  background: linear-gradient(180deg, #12181f 0%, #0d1218 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(58,160,255,0.15), 0 6px 18px rgba(0,0,0,0.4);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--engine), #1a4a75);
  color: #04101c;
  font-weight: 800;
  font-family: var(--mono);
  font-size: 13px;
  box-shadow: 0 0 14px rgba(58,160,255,0.45);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title { font-weight: 700; letter-spacing: 2px; font-size: 14px; }
.brand-sub { font-size: 10px; letter-spacing: 3px; color: var(--text-dim); }

.pills { display: flex; gap: 8px; margin-left: 8px; }

.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: default;
}

.pill .pdot { width: 7px; height: 7px; border-radius: 50%; }
.pill.mode-live .pdot { background: var(--live); box-shadow: 0 0 6px var(--live); }
.pill.mode-mock .pdot { background: var(--mock); box-shadow: 0 0 6px var(--mock); }
.pill .pname { color: var(--text-dim); text-transform: uppercase; }
.pill .pmode { color: var(--text); font-weight: 700; }

.force-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.force-label { font-family: var(--mono); font-size: 11px; letter-spacing: 1px; color: var(--text-dim); }

.switch { position: relative; display: inline-block; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  display: block;
  width: 40px; height: 22px;
  border-radius: 999px;
  background: #232c3a;
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.15s ease;
}
.switch-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .switch-track { background: rgba(245,166,35,0.25); border-color: var(--mock); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); background: var(--mock); box-shadow: 0 0 8px var(--mock); }

.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.conn-dot.ok { background: var(--live); box-shadow: 0 0 6px var(--live); }
.conn-dot.bad { background: var(--err); box-shadow: 0 0 6px var(--err); }

/* ---------- board layout ---------- */

.board {
  display: grid;
  gap: 14px;
  padding: 16px;
  grid-template-columns: 1.1fr 1.3fr 1fr 1.1fr;
  grid-template-areas:
    "prompt   nodes  vars       feed"
    "voice    nodes  vars       feed"
    "voice    nodes  crm        feed"
    "validate nodes  crm        feed"
    "compile  compile compile   compile"
    "sim      sim    transcript transcript";
  align-items: start;
}

@media (max-width: 1200px) {
  .board {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "prompt  prompt"
      "voice   voice"
      "nodes   nodes"
      "vars    crm"
      "validate feed"
      "compile compile"
      "sim     transcript";
  }
}

@media (max-width: 760px) {
  .board {
    grid-template-columns: 1fr;
    grid-template-areas:
      "prompt"
      "voice"
      "nodes"
      "vars"
      "crm"
      "validate"
      "feed"
      "compile"
      "sim"
      "transcript";
  }
}

/* ---------- panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  min-width: 0;
}

.panel-title {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-sub {
  font-weight: 400;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: none;
}

.empty { color: var(--text-faint); font-size: 12.5px; font-style: italic; margin: 4px 0; }

/* ---------- prompt panel ---------- */

textarea#promptInput {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 10px;
}
textarea#promptInput:focus { outline: none; border-color: var(--engine); }

.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.05s ease, background 0.12s ease;
}
.btn:hover { border-color: var(--engine); background: #17202c; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, var(--engine), #1c5a8a); border-color: #2a6ea0; color: #04101c; }
.btn-primary:hover { filter: brightness(1.08); }

.btn-danger { border-color: var(--err); color: var(--err); background: rgba(255,92,108,0.08); }
.btn-danger:hover { background: rgba(255,92,108,0.16); }

.hint { font-size: 11.5px; color: var(--text-dim); font-family: var(--mono); }
.hint.err { color: var(--err); }
.hint.ok { color: var(--live); }

/* ---------- node list ---------- */

.legend { display: flex; gap: 16px; font-size: 11px; color: var(--text-dim); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.dot-engine { background: var(--engine); box-shadow: 0 0 5px var(--engine); }
.dot-provider { background: var(--provider-dim); border: 1px solid var(--provider); }

.node-list {
  display: flex;
  flex-direction: column;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.node-row {
  border: 1px solid var(--border);
  border-left: 3px solid var(--engine-dim);
  background: var(--panel-alt);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 4px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.node-row.provider { border-left-color: var(--provider-dim); }

.node-row.active {
  background: rgba(58,160,255,0.10);
  border-color: var(--engine);
  box-shadow: 0 0 0 1px rgba(58,160,255,0.35), 0 0 16px rgba(58,160,255,0.25);
}
.node-row.provider.active {
  background: rgba(154,164,181,0.10);
  border-color: var(--provider);
  box-shadow: 0 0 0 1px rgba(154,164,181,0.3);
}

.node-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.node-id { font-family: var(--mono); font-size: 12.5px; font-weight: 700; }
.node-type { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); }

.badge {
  font-size: 9.5px;
  font-family: var(--mono);
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}
.badge-engine { background: rgba(58,160,255,0.15); color: var(--engine); border: 1px solid var(--engine-dim); }
.badge-provider { background: rgba(154,164,181,0.12); color: var(--provider); border: 1px solid var(--provider-dim); }

.node-meta { margin-top: 4px; font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.node-arrow { text-align: center; color: var(--text-faint); font-size: 13px; margin: 1px 0 3px; }

/* ---------- monospace data panels ---------- */

.mono-list, .mono-block, .feed-list, .validate-list {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.mono-list { max-height: 220px; }
.var-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; border-bottom: 1px dashed var(--border-soft); }
.var-row:last-child { border-bottom: none; }
.var-key { color: var(--text-dim); }
.var-val { color: var(--live); font-weight: 600; }
.var-row.flash { animation: flashvar 0.9s ease; }
@keyframes flashvar { from { background: rgba(58,160,255,0.25); } to { background: transparent; } }

.crm-grid, .compile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crm-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 1px;
  color: var(--text-faint);
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}

.mono-block { min-height: 60px; margin: 0; max-height: 220px; }
.mono-block.mono-tall { max-height: 340px; }

.tag {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.tag-blue { background: rgba(58,160,255,0.15); color: var(--engine); }
.tag-grey { background: rgba(154,164,181,0.15); color: var(--provider); }

/* ---------- feed ---------- */

.feed-list { max-height: 480px; }
.feed-row { padding: 4px 0; border-bottom: 1px solid var(--border-soft); }
.feed-row:last-child { border-bottom: none; }
.feed-seq { color: var(--text-faint); }
.feed-type { color: var(--engine); font-weight: 700; }
.feed-type.type-error { color: var(--err); }
.feed-type.type-corrective { color: var(--warn); }
.feed-data { color: var(--text-dim); display: block; margin-top: 2px; }

/* ---------- validator ---------- */

.validate-list { max-height: 220px; }
.validate-row {
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 5px;
  border-left: 3px solid var(--err);
  background: rgba(255,92,108,0.08);
}
.validate-row.pass {
  border-left-color: var(--live);
  background: rgba(53,212,136,0.08);
  color: var(--live);
}
.validate-check { font-weight: 700; color: var(--err); }
.validate-row.pass .validate-check { color: var(--live); }
.validate-node { color: var(--text-dim); font-size: 10.5px; }

/* ---------- simulator ---------- */

.transcript-live, .transcript-final {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.line { padding: 4px 8px; border-radius: 5px; max-width: 92%; }
.line-caller { align-self: flex-end; background: rgba(58,160,255,0.14); color: var(--text); }
.line-agent { align-self: flex-start; background: rgba(154,164,181,0.12); color: var(--text); }
.line-system { align-self: center; color: var(--warn); font-style: italic; font-size: 11.5px; }
.line-label { display: block; font-size: 9.5px; letter-spacing: 1px; color: var(--text-faint); margin-bottom: 2px; }

.sim-input-row { display: flex; gap: 8px; }
#simInput {
  flex: 1;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 10px;
}
#simInput:focus { outline: none; border-color: var(--engine); }
#simInput:disabled { opacity: 0.5; }

/* ---------- settings drawer (opened from the ⚙ header button) ---------- */

.settings-overlay[hidden] { display: none; }
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(4, 8, 14, 0.72);
  display: flex;
  justify-content: flex-end;
}
.settings-drawer {
  width: min(880px, 94vw);
  height: 100%;
  overflow-y: auto;
  border-radius: 0;
  border-left: 1px solid var(--border);
}

/* ---------- settings (drawer content) ---------- */

.settings-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1200px) { .settings-groups { grid-template-columns: 1fr; } }
.settings-group { display: flex; flex-direction: column; gap: 10px; }
.provider-cards { display: flex; flex-direction: column; gap: 10px; }
.provider-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.provider-card .telephony-form input { background: var(--bg, #0b0f16); }
.param-set { border-color: var(--engine) !important; }
.btn-small { font-size: 11px; padding: 3px 8px; margin-left: 8px; }

/* ---------- voice agent (panel 02) ---------- */

.voice-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; }
@media (max-width: 1200px) { .voice-grid { grid-template-columns: 1fr; } }
.voice-select { width: 100%; margin-top: 4px; }
.voice-free-model {
  width: 100%;
  margin-top: 6px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
}
.voice-prompt {
  width: 100%;
  min-height: 132px;
  margin-top: 4px;
  resize: vertical;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  padding: 8px 10px;
}
.voice-prompt:focus, .voice-select:focus { outline: none; border-color: var(--engine); }
.dest-select {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
}
.add-provider-form {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}
.telephony-form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.telephony-form input {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
}
.telephony-form input:focus { outline: none; border-color: var(--engine); }
.number-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.number-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}
.number-e164 { font-family: var(--mono); font-size: 13px; color: var(--text); }
.number-name { flex: 1; font-size: 12px; color: var(--text-faint); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #263042; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #34435c; }
