/* ============================================================================
   Futurebridge Agents — interactive demo console (/demo)
   Loads after styles.css; reuses brand tokens.
   ========================================================================== */

.demo-page {
  padding: 56px 0 96px;
}

.demo-page__head {
  max-width: 720px;
  margin-bottom: 36px;
}
.demo-page__head h1 {
  font-size: clamp(38px, 5vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 500;
  margin: 0 0 14px;
}
.demo-page__sub {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  margin: 0 0 16px;
}
.demo-page__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--pill);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  margin: 0;
}
.pulse--amber {
  background: #febc2e;
  box-shadow: 0 0 0 0 rgba(254, 188, 46, 0.5);
}

/* ── Agent tabs ────────────────────────────────────────────────────────────── */
.agent-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.agent-tabs[hidden] { display: none; }
.agent-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.agent-tab:hover { background: rgba(12, 12, 13, 0.04); }
.agent-tab__tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.agent-tab__name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.agent-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
}
.agent-tab.is-active .agent-tab__name { color: var(--cream); }
.agent-tab.is-active .agent-tab__tag { color: var(--accent-2); }

/* ── Console shell ─────────────────────────────────────────────────────────── */
.console {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.console[hidden], .ops[hidden] { display: none; }

.console__main {
  background: var(--dark);
  border: 1px solid rgba(247, 244, 236, 0.1);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(12, 12, 13, 0.25);
}

.console__head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(247, 244, 236, 0.1);
}
.console__title {
  margin-left: 8px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
  color: rgba(247, 244, 236, 0.85);
}
.console__env {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #febc2e;
  border: 1px solid rgba(254, 188, 46, 0.4);
  border-radius: 999px;
  padding: 2px 8px;
}
.console__live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(247, 244, 236, 0.7);
}

.thread {
  flex: 1;
  min-height: 380px;
  max-height: 520px;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* Messages */
.t-msg { display: flex; gap: 10px; }
.t-msg--user { justify-content: flex-end; }
.t-msg__avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.t-msg__bubble {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  color: rgba(247, 244, 236, 0.92);
  background: rgba(247, 244, 236, 0.07);
  border: 1px solid rgba(247, 244, 236, 0.08);
}
.t-msg--user .t-msg__bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 500;
}
.t-msg__bubble b { color: var(--accent-2); font-weight: 600; }
.t-msg--user .t-msg__bubble b { color: inherit; }

/* Thoughts */
.t-thought {
  font-size: 12.5px;
  font-style: italic;
  color: rgba(247, 244, 236, 0.45);
  padding-left: 38px;
}

/* Tool calls */
.t-tool {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 38px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(247, 244, 236, 0.04);
  border: 1px solid rgba(247, 244, 236, 0.08);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  color: rgba(247, 244, 236, 0.78);
}
.t-tool__sys {
  flex: none;
  font-weight: 700;
  color: var(--accent-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.t-tool__action { flex: 1; min-width: 0; }
.t-tool__status { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.t-tool__ok { color: #28c840; font-weight: 700; }
.t-tool__result { color: rgba(247, 244, 236, 0.6); }
.t-tool.is-done { border-color: rgba(40, 200, 64, 0.25); }

.spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(247, 244, 236, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Artifacts */
.t-artifact {
  margin-left: 38px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(247, 244, 236, 0.14);
  background: var(--cream);
}
.t-artifact__kind {
  padding: 8px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.t-artifact__body {
  margin: 0;
  padding: 14px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: pre-wrap;
}

/* Composer */
.composer {
  border-top: 1px solid rgba(247, 244, 236, 0.1);
  padding: 14px 16px 16px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  transition: opacity 0.2s ease;
}
.chips.is-disabled { opacity: 0.35; pointer-events: none; }
.chip-btn {
  border: 1px solid rgba(247, 244, 236, 0.18);
  background: transparent;
  color: rgba(247, 244, 236, 0.85);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chip-btn:hover {
  background: rgba(247, 244, 236, 0.08);
  border-color: rgba(247, 244, 236, 0.35);
}
.chip-btn--accent {
  border-color: var(--accent);
  color: var(--accent-2);
}
.chip-btn--accent:hover { background: rgba(255, 106, 61, 0.12); }

#composer-form {
  display: flex;
  gap: 8px;
  background: rgba(247, 244, 236, 0.06);
  border: 1px solid rgba(247, 244, 236, 0.14);
  border-radius: 999px;
  padding: 5px;
}
#composer-form input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--cream);
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
}
#composer-form input::placeholder { color: rgba(247, 244, 236, 0.4); }
#composer-form .btn--primary { background: var(--accent); color: var(--ink); }
#composer-form .btn--primary:hover { background: #ff7a52; }
#composer-form .btn:disabled { opacity: 0.5; cursor: default; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.console__side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.side__block {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.side__block--grow { flex: 1; min-height: 0; }
.side__block h2 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 12px;
}

.systems {
  list-style: none;
  margin: 0;
  padding: 0;
}
.systems li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  font-size: 14px;
  font-weight: 500;
  border-top: 1px solid var(--line);
}
.systems li:first-child { border-top: 0; }
.sys-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #28c840;
  flex: none;
}
.sys-state {
  margin-left: auto;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.log li {
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.log li:first-child { border-top: 0; }
.log__time {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  color: var(--muted);
  margin-right: 6px;
}
.log__sys {
  font-weight: 600;
  color: var(--accent);
  margin-right: 4px;
}
.log b { font-weight: 600; }
.log:empty::after {
  content: "Tool calls will appear here as the agent works.";
  color: var(--muted);
  font-style: italic;
}

.impact__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.impact__num {
  display: block;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.impact__label {
  font-size: 12px;
  color: var(--muted);
}

/* ── Conversion band ───────────────────────────────────────────────────────── */
.demo-cta {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  background: var(--dark);
  color: var(--cream);
  border-radius: var(--radius-lg);
  padding: 34px 38px;
}
.demo-cta h2 {
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.02em;
  font-weight: 500;
  margin: 0 0 8px;
}
.demo-cta p {
  margin: 0;
  color: rgba(247, 244, 236, 0.7);
  font-size: 15px;
  max-width: 520px;
}
.demo-cta .btn--primary { background: var(--accent); color: var(--ink); flex: none; }
.demo-cta .btn--primary:hover { background: #ff7a52; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .console { grid-template-columns: 1fr; }
  .console__side { flex-direction: row; flex-wrap: wrap; }
  .console__side .side__block { flex: 1 1 240px; }
  .demo-cta { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 620px) {
  .demo-page { padding: 36px 0 64px; }
  .thread { min-height: 300px; max-height: 60vh; padding: 16px 12px; }
  .t-msg__bubble { max-width: 90%; }
  .t-tool { margin-left: 0; flex-wrap: wrap; }
  .t-thought, .t-artifact { margin-left: 0; }
  #composer-form .btn { padding: 9px 14px; }
}

/* ============================================================================
   DEMO VIEW SWITCH + OPERATIONS DASHBOARD
   ========================================================================== */
.demo-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--pill);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.demo-switch__btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.demo-switch__btn:hover { color: var(--ink); }
.demo-switch__btn.is-active { background: var(--ink); color: var(--cream); }

/* Mode badges reuse the existing agent-tab design; a divider sets the row apart */
.demo-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.ops {
  --o-bg: #0d0f14;
  --o-panel: #15181f;
  --o-line: rgba(247, 244, 236, 0.09);
  --o-text: rgba(247, 244, 236, 0.92);
  --o-muted: rgba(247, 244, 236, 0.5);
  --o-teal: #3fd0c9;
  background: var(--o-bg);
  border: 1px solid rgba(247, 244, 236, 0.1);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(12, 12, 13, 0.25);
}
.ops__chrome {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--o-line);
}
.ops__title {
  margin-left: 8px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
  color: var(--o-text);
}
.ops__range {
  margin-left: auto;
  font-size: 11px;
  color: var(--o-muted);
  border: 1px solid var(--o-line);
  border-radius: 999px;
  padding: 3px 10px;
}
.ops__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--o-muted);
}
.ops__body { padding: 20px; }

.ops__kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kpi {
  background: var(--o-panel);
  border: 1px solid var(--o-line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--o-muted); }
.kpi__num { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--o-text); line-height: 1.05; }
.kpi__sub { font-size: 11.5px; color: var(--o-muted); }

.ops__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ops__grid--3 { grid-template-columns: repeat(3, 1fr); }
.ops__panel {
  background: var(--o-panel);
  border: 1px solid var(--o-line);
  border-radius: var(--radius);
  padding: 18px;
}
.ops__panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.ops__panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--o-text); letter-spacing: -0.01em; }
.ops__tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; padding: 3px 9px; border-radius: 999px; }
.ops__tag--ok { color: #28c840; background: rgba(40, 200, 64, 0.12); border: 1px solid rgba(40, 200, 64, 0.25); }
.ops__legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--o-muted); }
.ops__dot { width: 8px; height: 8px; border-radius: 50%; }
.ops__dot--sent { background: var(--accent); }
.ops__dot--reply { background: var(--o-teal); margin-left: 8px; }

.ops__bars { display: flex; flex-direction: column; gap: 13px; }
.opsbar { display: grid; grid-template-columns: 116px 1fr auto; align-items: center; gap: 12px; }
.opsbar__name { font-size: 12.5px; color: var(--o-text); }
.opsbar__track { height: 8px; border-radius: 999px; background: rgba(247, 244, 236, 0.06); overflow: hidden; }
.opsbar__track i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; animation: growbar 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.opsbar__val { font-size: 11.5px; color: var(--o-muted); font-family: ui-monospace, SFMono-Regular, monospace; white-space: nowrap; }

.ops__chart { width: 100%; height: 150px; display: block; }
.ops__chart-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--o-line);
  font-size: 12px;
  color: var(--o-muted);
}
.ops__chart-foot b { color: var(--o-text); font-weight: 600; }

.ops__stat { display: flex; flex-direction: column; gap: 5px; }
.ops__stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--o-muted); }
.ops__stat-num { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; color: var(--o-text); line-height: 1; }
.ops__stat-sub { font-size: 12px; color: var(--o-muted); }

/* Dashboard sub-tabs + views */
.ops__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--o-line);
}
.ops__tab {
  border: 0;
  background: transparent;
  color: var(--o-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ops__tab:hover { color: var(--o-text); background: rgba(255, 255, 255, 0.04); }
.ops__tab.is-active { color: var(--o-text); background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 -2px 0 var(--accent); }
.ops__view { display: flex; flex-direction: column; gap: 16px; }
.ops__view[hidden] { display: none; }
.ops__list { list-style: none; margin: 0; padding: 0; }
.ops__list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--o-line);
  font-size: 13.5px;
  color: var(--o-text);
}
.ops__list li:first-child { border-top: 0; }
.ops__list-meta { font-size: 11.5px; color: var(--o-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }

@media (max-width: 980px) {
  .ops__kpis { grid-template-columns: repeat(3, 1fr); }
  .ops__grid, .ops__grid--3 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .ops__kpis { grid-template-columns: repeat(2, 1fr); }
  .ops__body { padding: 14px; }
  .opsbar { grid-template-columns: 100px 1fr; }
  .opsbar__val { grid-column: 1 / -1; text-align: right; margin-top: -4px; }
}

/* ── Templates leaderboard + System map (Dashboard sub-tabs) ──────────────── */
.ops__lead { display: flex; flex-direction: column; }
.ops__lead-row {
  display: grid;
  grid-template-columns: minmax(0, 2.5fr) 0.9fr 0.9fr 1fr;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--o-line);
}
.ops__lead-row:first-child { border-top: 0; }
.ops__lead-row--head { padding: 0 0 10px; }
.ops__lead-row--head span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--o-muted);
}
.ops__lead-tpl {
  display: grid;
  grid-template-columns: minmax(0, auto) auto;
  justify-content: start;
  align-items: center;
  gap: 7px 10px;
  min-width: 0;
}
.ops__lead-name { font-size: 13px; color: var(--o-text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops__lead-bar { grid-column: 1 / -1; height: 5px; border-radius: 999px; background: rgba(247, 244, 236, 0.06); overflow: hidden; }
.ops__lead-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; animation: growbar 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.ops__lead-num { font-size: 12px; color: var(--o-muted); font-family: ui-monospace, SFMono-Regular, monospace; text-align: right; white-space: nowrap; }
.ops__lead-rate { font-weight: 600; }
.ops__lead-rate--hi { color: #28c840; }
.ops__lead-rate--mid { color: #f5b049; }
.ops__lead-rate--lo { color: var(--o-muted); }

.ops__chip {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--o-muted);
  background: rgba(247, 244, 236, 0.05);
  border: 1px solid var(--o-line);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.ops__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ops__chips .ops__chip { font-size: 11.5px; text-transform: none; letter-spacing: 0; padding: 5px 12px; color: var(--o-text); }

.ops__li-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ops__li-main b { font-weight: 600; font-size: 13.5px; }
.ops__li-main small { font-size: 11.5px; color: var(--o-muted); line-height: 1.35; }

.sysmap { width: 100%; }
.sysmap svg { width: 100%; height: auto; display: block; }
.sysmap__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--o-line);
}
.sysmap__key { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--o-muted); }
.sysmap__sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.sysmap__note { margin: 14px 0 0; font-size: 12px; color: var(--o-muted); line-height: 1.5; }

@media (max-width: 620px) {
  .ops__lead-row { grid-template-columns: minmax(0, 1.7fr) 1fr; gap: 10px; }
  .ops__lead-sends, .ops__lead-replies { display: none; }
}
