/*! * AgentFlow * Copyright (c) 2026 Omry Damari "Visigence". All rights reserved. * Proprietary and confidential. */
/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:         #0f1117;
  --surface:    #181c27;
  --surface-2:  #1e2335;
  --surface-3:  #252c40;
  --border:     #2a3050;
  --border-2:   #3a4468;
  --text:       #e0e4f2;
  --text-2:     #8b93b0;
  --text-3:     #555e7a;
  --accent:     #6c8eff;
  --accent-dim: rgba(108,142,255,.15);
  --danger:     #ff6b6b;
  --success:    #4ade80;
  --warn:       #fbbf24;

  /* Role palette */
  --role-input:      #f97316;
  --role-retrieve:   #06b6d4;
  --role-plan:       #8b5cf6;
  --role-tool:       #ec4899;
  --role-synthesize: #10b981;
  --role-validate:   #f59e0b;
  --role-output:     #3b82f6;

  --radius: 8px;
  --font: 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
}

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

/* ── Layout ── */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
#header { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 48px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
#header .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: -.3px; }
#header .logo svg { flex-shrink: 0; }
#header .tagline { font-size: 11px; color: var(--text-3); margin-left: 4px; letter-spacing: .2px; }
#header .spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 12px; font-family: var(--font); cursor: pointer; transition: background .15s, border-color .15s; user-select: none; }
.btn:hover { background: var(--surface-3); border-color: var(--border-2); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: #5a7df0; }
.btn.danger { color: var(--danger); border-color: rgba(255,107,107,.3); }
.btn.danger:hover { background: rgba(255,107,107,.1); }
.btn svg { flex-shrink: 0; }

#main { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
#sidebar { width: 256px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
#sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
#sidebar-header h2 { font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--text-3); }
#runs-list { flex: 1; overflow-y: auto; padding: 6px; }
.run-item { display: flex; align-items: center; padding: 8px 10px; border-radius: 6px; cursor: pointer; gap: 8px; transition: background .1s; position: relative; }
.run-item:hover { background: var(--surface-2); }
.run-item.active { background: var(--accent-dim); }
.run-item.active .run-name { color: var(--accent); }
.run-meta { flex: 1; min-width: 0; }
.run-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.run-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); font-weight: 600; flex-shrink: 0; }

/* ── Canvas area ── */
#canvas-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
#toolbar .section-label { font-size: 11px; color: var(--text-3); margin-right: 4px; font-weight: 600; letter-spacing: .4px; }
.tab-bar { display: flex; gap: 2px; }
.tab { padding: 4px 10px; border-radius: 5px; font-size: 12px; cursor: pointer; color: var(--text-2); transition: background .1s, color .1s; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); }
.cf-selector { display: flex; align-items: center; gap: 6px; }
.cf-selector label { font-size: 11px; color: var(--text-3); }
.cf-selector select { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 3px 8px; border-radius: 5px; font-size: 12px; font-family: var(--font); cursor: pointer; }
.cf-selector select:focus { outline: none; border-color: var(--accent); }
#cf-badge { font-size: 10px; padding: 2px 8px; border-radius: 4px; background: rgba(108,142,255,.2); color: var(--accent); font-weight: 600; border: 1px solid rgba(108,142,255,.3); }

#graph-scroll { flex: 1; overflow: auto; position: relative; }
#graph-canvas { position: relative; min-width: 100%; }

/* ── Nodes ── */
.node-wrapper { position: absolute; }
.node { width: 220px; border-radius: var(--radius); border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.node:hover { box-shadow: 0 4px 24px rgba(0,0,0,.4); border-color: var(--border-2); }
.node.selected { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-dim), 0 4px 24px rgba(0,0,0,.4); }
.node.cf-override { border-style: dashed !important; opacity: .9; }
.node-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; }
.role-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.role-label { font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; }
.node-name { padding: 0 12px 6px; font-size: 13px; font-weight: 600; line-height: 1.3; }
.node-content { padding: 0 12px 8px; font-size: 11px; color: var(--text-2); line-height: 1.5; max-height: 60px; overflow: hidden; }
.node-footer { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-top: 1px solid var(--border); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-label { font-size: 10px; color: var(--text-3); }
.node-duration { font-size: 10px; color: var(--text-3); margin-left: auto; }

/* ── Edges ── */
svg.edges-layer { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.edge { fill: none; stroke: var(--border-2); stroke-width: 1.5; }
.edge.cf { stroke: var(--accent); stroke-dasharray: 5 3; opacity: .6; }

/* ── Detail panel ── */
#detail { width: 320px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
#detail-inner { flex: 1; overflow-y: auto; padding: 16px; }
#detail.empty { display: flex; align-items: center; justify-content: center; }
.detail-empty-state { text-align: center; color: var(--text-3); }
.detail-empty-state svg { margin-bottom: 12px; opacity: .4; }
.detail-empty-state p { font-size: 12px; }
.detail-section { margin-bottom: 20px; }
.detail-section h3 { font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.detail-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.detail-row .label { color: var(--text-3); min-width: 80px; flex-shrink: 0; }
.detail-row .value { color: var(--text); word-break: break-word; }
.detail-content-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; font-size: 12px; line-height: 1.6; color: var(--text-2); white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; }
.cf-note { display: flex; align-items: flex-start; gap: 8px; background: rgba(108,142,255,.1); border: 1px solid rgba(108,142,255,.25); border-radius: 6px; padding: 10px; font-size: 11px; color: var(--accent); line-height: 1.5; margin-bottom: 16px; }
.cf-note svg { flex-shrink: 0; margin-top: 1px; }

/* ── Metrics bar ── */
#metrics-bar { display: flex; gap: 16px; align-items: center; padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; }
.metric { display: flex; flex-direction: column; gap: 1px; }
.metric-label { font-size: 10px; color: var(--text-3); letter-spacing: .4px; }
.metric-value { font-size: 15px; font-weight: 600; font-family: var(--mono); }
.metric-delta { font-size: 10px; font-weight: 500; }
.metric-delta.pos { color: var(--success); }
.metric-delta.neg { color: var(--danger); }
.metric-sep { width: 1px; height: 28px; background: var(--border); }

/* ── Final answer panel ── */
#answer-panel { padding: 16px; border-top: 1px solid var(--border); }
#answer-panel h3 { font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.answer-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-size: 13px; line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow-y: auto; }
.answer-box.cf { border-color: rgba(108,142,255,.4); background: rgba(108,142,255,.06); }

/* ── Empty states ── */
#empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 16px; color: var(--text-3); text-align: center; padding: 48px; }
#empty-state svg { opacity: .3; }
#empty-state h2 { font-size: 18px; font-weight: 600; color: var(--text-2); }
#empty-state p { font-size: 13px; max-width: 340px; line-height: 1.6; }

/* ── Counterfactuals tab ── */
#cf-list { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.cf-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: pointer; transition: border-color .15s; }
.cf-card:hover { border-color: var(--border-2); }
.cf-card.active { border-color: var(--accent); background: var(--accent-dim); }
.cf-card-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.cf-card-desc { font-size: 11px; color: var(--text-2); margin-top: 4px; line-height: 1.5; }
.cf-overrides { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.cf-override-tag { font-size: 10px; padding: 2px 7px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); }

/* ── Role legend ── */
#legend { display: flex; gap: 12px; flex-wrap: wrap; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--text-3); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: 480px; max-width: 90vw; }
.modal h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal label { display: block; font-size: 11px; color: var(--text-3); font-weight: 600; letter-spacing: .4px; margin-bottom: 4px; margin-top: 12px; }
.modal input, .modal textarea, .modal select { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; color: var(--text); font-size: 13px; font-family: var(--font); }
.modal textarea { min-height: 80px; resize: vertical; }
.modal input:focus, .modal textarea:focus, .modal select:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.error-msg { font-size: 11px; color: var(--danger); margin-top: 6px; }

/* ── Tooltip ── */
[title] { position: relative; }

/* ── Status colours ── */
.s-pending  { background: var(--text-3); }
.s-running  { background: var(--warn); }
.s-success  { background: var(--success); }
.s-failed   { background: var(--danger); }
.s-skipped  { background: var(--text-3); opacity: .5; }

.no-runs-msg { padding: 24px 12px; text-align: center; color: var(--text-3); font-size: 12px; }