/* Guardian Demo Control Centre — operator UI */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2431;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  /* Pilot Agent (the LLM being defended). Uses a distinct cyan so it
     doesn't collide with the operator's blue (#58a6ff) or Cisco AI
     Defense's purple (#a371f7). Variable kept named --brain for
     historical compatibility with the CSS classes below. */
  --brain: #39c5cf;
  --obs: #56d364;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cil-logo {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}
.cil-logo img {
  display: block;
  width: 144px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: 0.2px; }
.settings-link {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-family: var(--mono);
}
.settings-link:hover {
  color: var(--text);
  border-color: var(--text);
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 6px currentColor;
  transition: background 0.2s, color 0.2s;
}
.dot.on { background: var(--ok); color: var(--ok); }
.dot.err { background: var(--danger); color: var(--danger); }
.meta { display: flex; gap: 8px; }
.pill {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}

.pill.adrian-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pill.adrian-live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 6px currentColor;
}

.pill.adrian-live.live {
  color: #56d364;
  border-color: rgba(86, 211, 100, 0.5);
  background: rgba(86, 211, 100, 0.08);
}

.pill.adrian-live.offline {
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.6);
  background: rgba(248, 81, 73, 0.12);
}

.pill.adrian-live.unknown {
  color: var(--muted);
}

.pill.aidef-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pill.aidef-live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 6px currentColor;
}

.pill.aidef-live.live {
  color: #56d364;
  border-color: rgba(86, 211, 100, 0.5);
  background: rgba(86, 211, 100, 0.08);
}

.pill.aidef-live.offline {
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.6);
  background: rgba(248, 81, 73, 0.12);
}

.pill.aidef-live.unknown {
  color: var(--muted);
}

/* Settings page */
.settings-layout {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.settings-card {
  width: 100%;
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.settings-card h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.settings-help {
  margin: 0 0 16px;
  color: var(--muted);
}

.settings-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.settings-select {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 36px;
  padding: 0 10px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary {
  color: var(--muted);
  background: transparent;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text);
}

.btn-primary {
  color: #08111a;
  background: var(--accent);
  border-color: transparent;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.settings-status {
  margin: 12px 0 0;
  color: var(--muted);
  min-height: 18px;
  font-size: 12px;
}

.settings-status.error {
  color: var(--danger);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 12px;
  padding: 12px;
  flex: 1;
  min-height: 0;
}

.col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  flex-shrink: 0;
}
.col-header h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}
.header-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.col-header button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}
.col-header button:hover { color: var(--text); border-color: var(--text); }

/* Reasoning trace */
.trace .stream {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Architecture legend — inline strip above the transcript that maps
   each colour to its role in the defence-in-depth story. Keeps the
   trace self-explanatory even for a first-time viewer. */
.legend {
  list-style: none;
  margin: 0;
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.legend.is-hidden {
  display: none;
}
.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  white-space: nowrap;
}
.legend li b {
  color: var(--text);
  font-weight: 600;
  margin-right: 2px;
}
/* Vendor byline shown after each legend item description ("Cisco",
   "SecureAgentics.ai", "Ollama · llama3.2" etc). Distinct colour so
   sales viewers can immediately spot which components belong to which
   partner. */
.legend li em {
  font-style: normal;
  color: var(--muted);
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.2px;
}
.legend li em.cisco {
  color: #4fbdff;
  border-color: rgba(79, 189, 255, 0.4);
  background: rgba(79, 189, 255, 0.08);
}
.legend li em.secureagentics {
  color: #ff9a95;
  border-color: rgba(255, 154, 149, 0.4);
  background: rgba(255, 154, 149, 0.06);
}
.legend .sw {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--muted);
  flex-shrink: 0;
}
.legend .lg-mission     .sw { background: var(--accent); }
.legend .lg-adversary   .sw { background: var(--danger); }
.legend .lg-aidef       .sw { background: #a371f7; }
.legend .lg-brain       .sw { background: var(--brain); }
/* Adrian shares the red family with Adversary (both are refusals) but
   Adrian is a defence layer, so give its swatch a solid inner block +
   ring to visually distinguish it from the adversary chip. */
.legend .lg-adrian      .sw {
  background: var(--danger);
  box-shadow: inset 0 0 0 2px #0d1117;
  outline: 1px solid var(--danger);
}
.legend .lg-supervisor  .sw { background: var(--warn); }
.legend .lg-obs         .sw { background: var(--obs); }
/* Cisco Splunk is a passive sink (all events flow there) rather than
   a card type in the trace \u2014 shown as a legend chip with a distinct
   Cisco-blue swatch so viewers know where the observability lives. */
.legend .lg-splunk      .sw {
  background: #4fbdff;
  outline: 1px dashed rgba(79, 189, 255, 0.5);
  outline-offset: 1px;
}
/* Backhaul-link swatch \u2014 uses the Cisco-blue palette but with a
   two-tone gradient to distinguish it from the passive Splunk sink. */
.legend .lg-network     .sw {
  background: linear-gradient(90deg, #4fbdff 0%, #4fbdff 50%, #d29922 50%, #d29922 100%);
  outline: 1px dashed rgba(79, 189, 255, 0.5);
  outline-offset: 1px;
}

/* Header pill variants. `.pill.cisco` marks the Splunk pill so the
   audience can immediately parse it as a Cisco component. */
.pill.cisco {
  color: #4fbdff;
  border-color: rgba(79, 189, 255, 0.5);
  background: rgba(79, 189, 255, 0.08);
}
.pill.cisco.disabled {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
  opacity: 0.6;
}
/* Link-status pill \u2014 flips colour with the uplink health. */
.pill.link {
  border-style: dashed;
}
.pill.link-connected {
  color: #56d364;
  border-color: rgba(86, 211, 100, 0.5);
  background: rgba(86, 211, 100, 0.08);
}
.pill.link-degraded {
  color: var(--warn);
  border-color: rgba(210, 153, 34, 0.6);
  background: rgba(210, 153, 34, 0.10);
}
.pill.link-lost {
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.6);
  background: rgba(248, 81, 73, 0.12);
}

/* Backhaul & Data Plane panel in the right sidebar. */
.netpanel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.net-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
}
.net-row .k { color: var(--muted); }
.net-row .v { font-family: var(--mono, monospace); }
.net-row .tag {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.net-row .tag-ok  { background: rgba(86, 211, 100, 0.15); color: #56d364; }
.net-row .tag-warn { background: rgba(210, 153, 34, 0.15); color: var(--warn); }
.net-row .tag-err { background: rgba(248, 81, 73, 0.15); color: var(--danger); }
.net-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.net-actions button {
  flex: 1;
  padding: 5px 8px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}
.net-actions button:hover { background: rgba(255, 255, 255, 0.05); }
.btn-danger { color: var(--danger) !important; border-color: rgba(248, 81, 73, 0.5) !important; }
.btn-warn   { color: var(--warn) !important;   border-color: rgba(210, 153, 34, 0.5) !important; }
.btn-ok     { color: #56d364 !important;       border-color: rgba(86, 211, 100, 0.5) !important; }
.net-note {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  margin-top: 2px;
}
.net-note b { color: #4fbdff; font-weight: 500; }
.net-note code {
  font-family: var(--mono, monospace);
  font-size: 0.75rem;
  color: var(--fg);
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 6px;
  padding: 10px 12px;
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.card .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.card .label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.card .step { color: var(--muted); font-size: 11px; font-family: var(--mono); }
.card .thought { margin: 4px 0 0; color: var(--text); }
.card .action {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(88, 166, 255, 0.08);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  word-break: break-word;
}
.card .obs {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--obs);
}

.card.mission { border-left-color: var(--accent); }
.card.mission .label { color: var(--accent); }
.card.mission .thought { font-weight: 500; }

/* Missions submitted by the red-team adversary agent. */
.card.mission.adversary {
  border-left-color: var(--danger);
  background: rgba(248, 81, 73, 0.06);
}
.card.mission.adversary .label {
  color: var(--danger);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.card.mission.adversary .thought::before {
  content: "⚠ ";
  color: var(--danger);
  font-weight: 700;
}

/* Supervisor-agent veto — visually related to Adrian blocks but with
   its own colour so operators can tell the two safety layers apart. */
.card.supervisor-block {
  border-left-color: var(--warn);
  background: rgba(210, 153, 34, 0.08);
}
.card.supervisor-block .label { color: var(--warn); }
.card.supervisor-block .rule {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(210, 153, 34, 0.15);
  border: 1px solid var(--warn);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--warn);
}
.card.supervisor-block .action {
  background: rgba(210, 153, 34, 0.12);
  color: var(--warn);
}

/* Cisco AI Defense block — front-door gateway rejection. Uses a
   distinct purple/indigo so it stands out from Adrian (red) and the
   Supervisor (amber). */
.card.ai-defense-block {
  border-left-color: #a371f7;
  background: rgba(163, 113, 247, 0.08);
}
.card.ai-defense-block .label { color: #a371f7; font-weight: 600; }
.card.ai-defense-block .rule {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(163, 113, 247, 0.15);
  border: 1px solid #a371f7;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  color: #a371f7;
}
.card.ai-defense-block .action {
  background: rgba(163, 113, 247, 0.12);
  color: #d2b6ff;
}
.card.ai-defense-block .fallback {
  color: #d2b6ff;
}

.card.brain { border-left-color: var(--brain); }
.card.brain .label { color: var(--brain); }

.card.observation { border-left-color: var(--obs); padding: 6px 12px; }
.card.observation .label { color: var(--obs); }

.card.blocked {
  border-left-color: var(--danger);
  background: rgba(248, 81, 73, 0.08);
}
.card.blocked .label { color: var(--danger); }
.card.blocked .action { background: rgba(248, 81, 73, 0.12); color: var(--danger); }
.card.blocked .rule {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid var(--danger);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--danger);
}
.card.blocked .fallback {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--warn);
}

.card.complete {
  border-left-color: var(--ok);
  background: rgba(63, 185, 80, 0.06);
}
.card.complete .label { color: var(--ok); }

.card.system {
  border-left-color: var(--muted);
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Chat composer */
.composer {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  background: var(--panel-2);
  flex-shrink: 0;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font);
}
.chip:hover { color: var(--accent); border-color: var(--accent); }

.input-row {
  display: flex;
  gap: 8px;
}
#prompt {
  flex: 1;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
}
#prompt:focus { outline: none; border-color: var(--accent); }
#send {
  padding: 9px 18px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #0d1117;
  font-weight: 600;
  cursor: pointer;
}
#send:hover { filter: brightness(1.1); }
#send:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; }

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  flex-shrink: 0;
}
.tile {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile .k {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.4px;
}
.tile .v {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
}
.tile .tag {
  align-self: flex-start;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: rgba(63, 185, 80, 0.15);
  color: var(--ok);
  border: 1px solid var(--ok);
}
.tile .tag.blocked { background: rgba(248, 81, 73, 0.15); color: var(--danger); border-color: var(--danger); }
.tile .tag.alarm   { background: rgba(210, 153, 34, 0.15); color: var(--warn); border-color: var(--warn); }

.blocks {
  list-style: none;
  margin: 0;
  padding: 0 12px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.blocks li {
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.4);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 12px;
}
.blocks li .rule-id {
  font-family: var(--mono);
  color: var(--danger);
  font-size: 11px;
  display: block;
  margin-bottom: 2px;
}
.blocks li.empty {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

/* Combined dashboard layout:
   - LHS: video (top) + telemetry (bottom)
   - RHS: Guardian Control Centre (embedded iframe) */
.combined-layout {
  display: grid;
  grid-template-columns: minmax(420px, 46%) 1fr;
  gap: 12px;
  padding: 12px;
  flex: 1;
  min-height: 0;
}

.combined-visual {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto auto;
}

.combined-ops {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.combined-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.combined-controls .settings-label {
  margin: 0;
}

.combined-select {
  width: auto;
  min-width: 90px;
  height: 28px;
  padding: 0 8px;
}

.visual-wrap {
  position: relative;
  min-height: 0;
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: #05080d;
}

#webots-feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#webots-scene-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #05080d;
}

.feed-inset-wrap {
  position: absolute;
  left: 12px;
  top: 12px;
  width: min(34%, 260px);
  aspect-ratio: 5 / 3;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(3, 6, 12, 0.9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#webots-feed-inset {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#webots-feed-inset.hidden {
  display: none;
}

.combined-subheader {
  border-top: 1px solid var(--border);
}

.combined-telemetry {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

#guardian-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}

@media (max-width: 1100px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .topbar {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .cil-logo img {
    width: 120px;
  }

  .brand {
    flex: 1 1 320px;
    flex-wrap: wrap;
    min-width: 0;
  }

  .brand h1 {
    flex: 1 1 100%;
  }

  .meta {
    margin-left: auto;
  }

  .combined-layout {
    flex: 0 0 auto;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(460px, auto) minmax(520px, auto);
  }

  .combined-visual {
    grid-template-rows: auto minmax(220px, 38vh) auto auto;
  }

  .combined-ops {
    min-height: 520px;
  }
}

/* Scrollbars */
.stream::-webkit-scrollbar, .blocks::-webkit-scrollbar { width: 8px; }
.stream::-webkit-scrollbar-thumb, .blocks::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
