/* ═══════════════════════════════════════════════════════════════
   GLOBAL
   ═══════════════════════════════════════════════════════════════ */
html { zoom: 1.20; }
*, *::before, *::after { box-sizing: border-box; }

/* ═══════════════════════════════════════════════════════════════
   NAV BAR — dark charcoal from Dribbble palette
   ═══════════════════════════════════════════════════════════════ */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  background: #2b2d42;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.nav-logo-mark {
  width: 30px; height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4361ee 0%, #6c5ce7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-pill {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.1);
  padding: 0.25rem 0.7rem;
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,0.15);
  letter-spacing: 0.03em;
}

.nav-clear-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-clear-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #ffffff;
}

/* ═══════════════════════════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════════════════════════ */
.chat-panel {
  background: #ffffff;
  border-right: 1px solid #edeef5;
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 15vh;
}
.empty-state-icon {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eceeff 0%, #e0d7ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4361ee;
}
.suggestion-chip {
  font-size: 0.8rem;
  color: #3450d4;
  background: #eceeff;
  border: 1px solid #d9ddff;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(67,97,238,0.1);
}
.suggestion-chip:hover {
  background: #d9ddff;
  border-color: #b8bffa;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(67,97,238,0.18);
}

/* ═══════════════════════════════════════════════════════════════
   CHAT INPUT AREA
   ═══════════════════════════════════════════════════════════════ */
.chat-input-area {
  padding: 0.75rem 1.25rem 1rem;
  background: #ffffff;
  border-top: 1px solid #edeef5;
}
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f5f6fa;
  border: 1.5px solid #edeef5;
  border-radius: 14px;
  padding: 0.35rem 0.35rem 0.35rem 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input-bar:focus-within {
  border-color: #a5b0f8;
  box-shadow: 0 0 0 3px rgba(67,97,238,0.08);
  background: #ffffff;
}
.chat-attach-btn {
  cursor: pointer;
  color: #6b7280;
  transition: color 0.15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.chat-attach-btn:hover { color: #4361ee; }
.chat-text-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  color: #1e1f36;
  padding: 0.4rem 0.25rem;
  outline: none;
}
.chat-text-input::placeholder { color: #8b8fa0; }
.chat-send-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: none;
  background: #4361ee;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(67,97,238,0.35);
}
.chat-send-btn:hover { background: #3450d4; transform: scale(1.04); box-shadow: 0 3px 10px rgba(67,97,238,0.45); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ═══════════════════════════════════════════════════════════════
   PIPELINE PANEL — lavender-gray background
   ═══════════════════════════════════════════════════════════════ */
.pipeline-panel-wrapper {
  background: #f5f6fa;
  overflow: hidden;
  min-width: 0;
}
#pipeline-panel {
  overflow-x: hidden;
}
.pipeline-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #edeef5;
  background: #ffffff;
}

/* ═══════════════════════════════════════════════════════════════
   AGENT ICON BADGES — pastel category cards (Dribbble-style)
   ═══════════════════════════════════════════════════════════════ */
.agent-icon {
  width: 22px; height: 22px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stage-label.compact .agent-icon { width: 20px; height: 20px; border-radius: 6px; }

/* Routing — dark charcoal */
.agent-icon--routing { background: #e8e9f0; color: #2b2d42; }
/* ES — indigo-blue */
.agent-icon--es { background: #eceeff; color: #4361ee; }
/* SQL — warm amber */
.agent-icon--sql { background: #fff0e1; color: #f4a261; }
/* Synthesis — green */
.agent-icon--synthesis { background: #e6fbf0; color: #36b37e; }

/* ═══════════════════════════════════════════════════════════════
   STAGE GROUP
   ═══════════════════════════════════════════════════════════════ */
.stage-group {
  transition: all 0.3s;
}

/* Stage label row */
.stage-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #2b2d42;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 0.15rem 0.4rem;
}
.stage-label.compact {
  font-size: 0.68rem;
  padding-bottom: 0.3rem;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}
.stage-label.compact > span:first-of-type {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.stage-group[data-status="running"] .stage-label { color: #4361ee; }
.stage-group[data-status="complete"] .stage-label { color: #36b37e; }
.stage-group[data-status="error"] .stage-label { color: #ef4444; }

/* Badge */
.stage-badge {
  display: none;
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 9999px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.stage-group[data-status="running"] .stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #eceeff;
  color: #4361ee;
}
.stage-group[data-status="running"] .stage-badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #4361ee;
  animation: blink-dot 0.9s ease-in-out infinite;
}
.stage-group[data-status="complete"] .stage-badge {
  display: inline-block;
  background: #e6fbf0;
  color: #36b37e;
}
.stage-group[data-status="error"] .stage-badge {
  display: inline-block;
  background: #fef2f2;
  color: #ef4444;
}

/* ═══════════════════════════════════════════════════════════════
   SUB-NODE FLOW
   ═══════════════════════════════════════════════════════════════ */
.subnode-flow {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ── Sub-node card ────────────────────────────────────────────── */
.subnode {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.48rem 0.65rem;
  background: #ffffff;
  border: 1px solid #edeef5;
  border-radius: 10px;
  font-size: 0.8rem;
  color: #6b7280;
  transition: all 0.25s ease;
  position: relative;
}
.agent .subnode { padding: 0.3rem 0.4rem; font-size: 0.68rem; }

/* Sub-node status icon */
.subnode-status-icon {
  width: 16px; height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
}
.agent .subnode-status-icon { width: 14px; height: 14px; }

/* ── Pending ─────────────────────────────────────────────────── */
.subnode[data-status="pending"] {
  background: #ffffff;
  border-color: #edeef5;
  color: #a0a3b1;
}
.subnode[data-status="pending"] .subnode-status-icon {
  background: transparent;
  border: 1.5px solid #dddee8;
}

/* ── Running ─────────────────────────────────────────────────── */
.subnode[data-status="running"] {
  border-color: #b8bffa;
  background: #f5f6ff;
  box-shadow: 0 0 0 1px rgba(67,97,238,0.06), 0 2px 8px rgba(67,97,238,0.05);
  color: #3450d4;
  font-weight: 500;
}
.subnode[data-status="running"] .subnode-status-icon {
  background: transparent;
  border: 2px solid #b8bffa;
  border-top-color: #4361ee;
  animation: spinner 0.6s linear infinite;
}

/* ── Complete ────────────────────────────────────────────────── */
.subnode[data-status="complete"] {
  border-color: #b2f0d1;
  background: #f0fdf7;
  color: #1a7a4c;
}
.subnode[data-status="complete"] .subnode-status-icon {
  background: #36b37e;
  border: none;
}
.subnode[data-status="complete"] .subnode-status-icon::after {
  content: "";
  width: 6px; height: 9px;
  border: solid white;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) translate(-0.5px, -0.5px);
}
.agent .subnode[data-status="complete"] .subnode-status-icon::after {
  width: 5px; height: 7px;
  border-width: 0 1.5px 1.5px 0;
}

/* ── Error ───────────────────────────────────────────────────── */
.subnode[data-status="error"] {
  border-color: #fca5a5;
  background: #fef8f8;
  color: #991b1b;
}
.subnode[data-status="error"] .subnode-status-icon {
  background: #ef4444;
  border: none;
}
.subnode[data-status="error"] .subnode-status-icon::after {
  content: "!";
  color: white;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

/* Sub-node text & detail */
.subnode-text { flex: 1; }
.subnode-detail {
  font-size: 0.65rem;
  color: #a0a3b1;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}
.subnode[data-status="complete"] .subnode-detail { color: #6b7280; }

/* ── Sub-node connector wire ─────────────────────────────────── */
.subnode-wire {
  width: 2px;
  height: 5px;
  background: #edeef5;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  border-radius: 1px;
}
.subnode[data-status="complete"] + .subnode-wire {
  background: #b2f0d1;
}
.subnode[data-status="complete"] + .subnode-wire::after {
  content: "";
  position: absolute;
  width: 2px; height: 5px;
  background: #36b37e;
  top: -5px; left: 0;
  animation: wire-flow 0.4s ease-out forwards;
}
@keyframes wire-flow {
  from { top: -5px; opacity: 0; }
  to   { top: 5px;  opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   STAGE WIRES
   ═══════════════════════════════════════════════════════════════ */
.stage-wire {
  width: 2px;
  height: 14px;
  background: #edeef5;
  margin: 3px auto;
  position: relative;
  overflow: hidden;
  border-radius: 1px;
}
.wire-pulse {
  position: absolute;
  width: 2px; height: 10px;
  background: linear-gradient(to bottom, transparent, #4361ee, transparent);
  top: -10px; left: 0;
  opacity: 0;
  animation: stage-flow 1.4s ease-in-out infinite;
  animation-play-state: paused;
}
.stage-group[data-status="complete"] + .stage-wire .wire-pulse,
.merge-visual + .stage-wire .wire-pulse {
  animation-play-state: running;
  opacity: 1;
}
@keyframes stage-flow {
  0%   { top: -10px; opacity: 0; }
  30%  { opacity: 1; }
  100% { top: 16px; opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   PARALLEL LANE — 2 columns
   ═══════════════════════════════════════════════════════════════ */
.parallel-lane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  min-width: 0;
}
.parallel-lane .agent {
  min-width: 0;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   FORK / MERGE visuals — 2 legs
   ═══════════════════════════════════════════════════════════════ */
.fork-visual, .merge-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.fork-stem, .merge-stem {
  width: 2px; height: 7px; background: #edeef5; border-radius: 1px;
}
.fork-bar, .merge-bar {
  width: 50%; height: 2px; background: #edeef5; border-radius: 1px;
}
.fork-legs, .merge-legs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  width: 100%;
}
.fork-leg, .merge-leg {
  height: 8px;
  position: relative;
}
.fork-leg::after, .merge-leg::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 100%;
  background: #edeef5;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 1px;
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */
@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}
@keyframes spinner {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT STATUS
   ═══════════════════════════════════════════════════════════════ */
.chat-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  font-size: 0.88rem;
  color: #6b7280;
}
.chat-status .status-spinner {
  width: 16px; height: 16px;
  border: 2px solid #edeef5;
  border-top-color: #4361ee;
  border-radius: 50%;
  animation: spinner 0.7s linear infinite;
  flex-shrink: 0;
}
.chat-status .status-text {
  animation: status-in 0.15s ease-out;
}
@keyframes status-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   STREAMING CURSOR
   ═══════════════════════════════════════════════════════════════ */
.streaming-cursor::after {
  content: "\25AE";
  animation: blink-cursor 0.8s step-end infinite;
  color: #4361ee;
  margin-left: 1px;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT BUBBLES
   ═══════════════════════════════════════════════════════════════ */
.msg-user {
  background: #2b2d42;
  color: white;
  border-radius: 18px 18px 4px 18px;
}
.msg-assistant {
  background: #ffffff;
  border: 1px solid #edeef5;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.msg-assistant .prose { font-size: 0.95rem; line-height: 1.7; color: #2b2d42; }
.msg-assistant .prose p { margin-bottom: 0.5em; }
.msg-assistant .prose ul, .msg-assistant .prose ol { margin: 0.5em 0; padding-left: 1.5em; }
.msg-assistant .prose li { margin-bottom: 0.25em; }
.msg-assistant .prose strong { font-weight: 600; color: #1e1f36; }
.msg-assistant .prose code {
  background: #eceeff; padding: 0.15em 0.35em;
  border-radius: 6px; font-size: 0.83em;
  color: #4361ee; font-weight: 500;
}
.msg-assistant .prose h1, .msg-assistant .prose h2, .msg-assistant .prose h3,
.msg-assistant .prose h4, .msg-assistant .prose h5, .msg-assistant .prose h6 {
  font-weight: 600; margin: 0.75em 0 0.25em; color: #1e1f36;
}
.msg-assistant .prose h1 { font-size: 1.2em; }
.msg-assistant .prose h2 { font-size: 1.1em; }
.msg-assistant .prose h3 { font-size: 1.02em; }
.msg-assistant .prose h4 { font-size: 0.95em; }
.msg-assistant .prose h5 { font-size: 0.9em; }
.msg-assistant .prose h6 { font-size: 0.85em; color: #6b7280; }
.msg-assistant .prose table {
  border-collapse: collapse; margin: 0.5em 0;
  font-size: 0.88em; width: 100%;
  border-radius: 10px; overflow: hidden;
}
.msg-assistant .prose th, .msg-assistant .prose td {
  border: 1px solid #edeef5; padding: 0.45em 0.7em; text-align: left;
}
.msg-assistant .prose th { background: #f5f6fa; font-weight: 600; color: #2b2d42; }
.msg-assistant .prose pre {
  background: #1e1f36; color: #e2e8f0;
  padding: 0.85em 1.1em; border-radius: 12px;
  overflow-x: auto; margin: 0.6em 0;
  font-size: 0.83em; line-height: 1.55;
}
.msg-assistant .prose pre code {
  background: none; padding: 0;
  border-radius: 0; font-size: inherit; color: inherit;
  font-weight: 400;
}
.msg-assistant .prose blockquote {
  border-left: 3px solid #b8bffa;
  padding: 0.3em 0.8em; margin: 0.5em 0;
  color: #6b7280; background: #f5f6fa;
  border-radius: 0 10px 10px 0;
}
.msg-assistant .prose blockquote p { margin-bottom: 0.25em; }
.msg-assistant .prose hr {
  border: none; border-top: 1px solid #edeef5;
  margin: 0.75em 0;
}
.msg-assistant .prose del { color: #a0a3b1; }
.msg-assistant .prose ol { list-style-type: decimal; }

/* ═══════════════════════════════════════════════════════════════
   CITATIONS
   ═══════════════════════════════════════════════════════════════ */
.citations-section {
  margin-top: 0.85rem; padding-top: 0.85rem;
  border-top: 1px solid #edeef5;
}
.citation-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: #e6fbf0; color: #1a7a4c;
  font-size: 0.78rem; padding: 0.3rem 0.6rem;
  border-radius: 8px; border: 1px solid #b2f0d1;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════
   STAGE OUTPUT
   ═══════════════════════════════════════════════════════════════ */
.stage-output {
  display: none;
  margin-top: 0.35rem;
}
.stage-output.has-data {
  display: block;
}
.stage-output-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.65rem;
  color: #a0a3b1;
  padding: 0.15rem 0.25rem;
  transition: color 0.15s;
}
.stage-output-toggle:hover { color: #6b7280; }
.output-chevron {
  font-size: 0.6rem;
  transition: transform 0.2s;
  display: inline-block;
}
.stage-output.expanded .output-chevron {
  transform: rotate(90deg);
}
.stage-output-content {
  display: none;
  margin-top: 0.25rem;
  padding: 0.45rem 0.55rem;
  background: #ffffff;
  border: 1px solid #edeef5;
  border-radius: 10px;
  font-size: 0.74rem;
  color: #2b2d42;
  line-height: 1.5;
  max-height: 12rem;
  overflow-y: auto;
}
.stage-output.expanded .stage-output-content {
  display: block;
}
.output-item {
  margin-bottom: 0.35rem;
}
.output-item:last-child {
  margin-bottom: 0;
}
.output-sub {
  padding-left: 0.8rem;
  color: #6b7280;
  font-size: 0.7rem;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════════════ */
#chat-messages::-webkit-scrollbar,
#pipeline-panel::-webkit-scrollbar { width: 5px; }
#chat-messages::-webkit-scrollbar-track,
#pipeline-panel::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb,
#pipeline-panel::-webkit-scrollbar-thumb {
  background: #dddee8; border-radius: 9999px;
}
#chat-messages::-webkit-scrollbar-thumb:hover,
#pipeline-panel::-webkit-scrollbar-thumb:hover {
  background: #a0a3b1;
}
