/* ═══════════════════════════════════════
   Flow Page — Premium Dark Cyber Theme
   ═══════════════════════════════════════ */
:root {
  --bg-base: #0f172a;
  --bg-panel: rgba(30, 41, 59, 0.7);
  --bg-card: rgba(15, 23, 42, 0.6);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-glow: 0 0 20px rgba(99, 102, 241, 0.5);
  --success: #10b981;
  --danger: #ef4444;
  --node-start: linear-gradient(135deg, #10b981, #059669);
  --node-process: #1e293b;
  --node-decision: rgba(99, 102, 241, 0.1);
  --node-end: linear-gradient(135deg, #6366f1, #4f46e5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body { 
  font-family: 'Inter', sans-serif; 
  background: var(--bg-base); 
  color: var(--text-main); 
  display: flex; 
  min-height: 100vh;
  overflow: hidden;
}

.icon-sm { width: 18px; height: 18px; }
.lucide { vertical-align: middle; }

/* ═══ MAIN LAYOUT ═══ */
.main { flex: 1; display: flex; flex-direction: column; background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent 50%); height: 100vh;}

.topbar { padding: 32px 40px; border-bottom: 1px solid var(--border-color); background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(12px); z-index: 10; flex-shrink: 0;}
.topbar h1 { font-size: 1.8rem; font-weight: 700; color: var(--text-main); margin: 0; display: flex; align-items: center; gap: 12px; }
.topbar p { font-size: 0.95rem; color: var(--text-muted); margin-top: 8px; }

.panels { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* ═══ LEFT: FLOW PANEL ═══ */
.flow-panel { width: 340px; min-width: 250px; background: rgba(15,23,42,0.8); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0; }
.flow-panel::-webkit-scrollbar { width: 4px; }
.flow-panel::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.zoom-controls { display: flex; gap: 8px; padding: 12px; margin: 16px; background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 8px; align-items: center; justify-content: center; backdrop-filter: blur(4px); flex-shrink: 0; }
.zoom-btn { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border-color); background: rgba(255,255,255,0.05); color: var(--text-main); cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; font-family: monospace; font-size: 16px; }
.zoom-btn:hover { background: var(--primary); border-color: var(--primary); }
.zoom-level { font-size: 12px; font-weight: 600; min-width: 44px; text-align: center; }

.flow-content { padding: 32px 20px 60px; display: flex; flex-direction: column; align-items: center; transform-origin: top center; transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); }

.flow-node { padding: 14px 24px; border-radius: 12px; font-size: 13px; font-weight: 600; text-align: center; min-width: 200px; transition: all 0.2s; border: 1px solid var(--border-color); box-shadow: 0 4px 15px rgba(0,0,0,0.2); cursor: pointer; }
.flow-node:hover { transform: translateY(-2px); box-shadow: var(--primary-glow); border-color: var(--primary); }
.flow-node.active-step { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(99,102,241,0.3), var(--primary-glow); }
.node-sub { font-size: 11px; font-weight: 400; color: var(--text-muted); margin-top: 4px; }

.node-start { background: var(--node-start); border: none; color: white; border-radius: 30px; letter-spacing: 0.5px;}
.node-process { background: var(--node-process); color: white; }
.node-decision { background: var(--node-decision); border-color: var(--primary); color: #fff; }
.node-tool { background: rgba(245, 158, 11, 0.05); border-color: rgba(245, 158, 11, 0.3); color: #fbbf24; }
.node-end { background: var(--node-end); border: none; color: white; border-radius: 30px; letter-spacing: 0.5px;}

.flow-arrow { display: flex; flex-direction: column; align-items: center; padding: 4px 0; }
.arrow-line { width: 2px; height: 24px; background: rgba(255,255,255,0.15); }
.arrow-head { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid rgba(255,255,255,0.15); }
.arrow-label { font-size: 10px; color: var(--text-muted); background: var(--bg-panel); padding: 4px 10px; border-radius: 12px; margin: 2px 0; border: 1px solid var(--border-color); letter-spacing: 0.5px; }

.flow-branch { display: flex; gap: 20px; align-items: flex-start; justify-content: center; position: relative; }
.flow-branch::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: calc(100% - 70px); height: 2px; background: rgba(255,255,255,0.15); }
.branch-item { display: flex; flex-direction: column; align-items: center; }
.branch-connector { width: 2px; height: 16px; background: rgba(255,255,255,0.15); }

.loop-indicator { border: 1px dashed rgba(99,102,241,0.5); border-radius: 16px; padding: 28px 16px 20px; display: flex; flex-direction: column; align-items: center; position: relative; background: rgba(99, 102, 241, 0.03); margin: 8px 0; width: 100%; max-width: 280px;}
.loop-label { position: absolute; top: -10px; left: 24px; background: var(--primary); color: white; font-size: 10px; font-weight: 700; padding: 4px 12px; border-radius: 4px; letter-spacing: 1px; box-shadow: var(--primary-glow); }

.panel-resizer { width: 6px; cursor: col-resize; background: var(--border-color); display: flex; align-items: center; justify-content: center; transition: all 0.2s; z-index: 5;}
.panel-resizer:hover, .panel-resizer.dragging { background: var(--primary); }
.panel-resizer::after { content: ''; width: 2px; height: 20px; background: rgba(255,255,255,0.5); border-radius: 2px; }

/* ═══ RIGHT: EXPLAIN CONTENT ═══ */
.explain-panel { flex: 1; padding: 40px; overflow-y: auto; background: transparent; scroll-behavior: smooth; }
.explain-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; padding: 32px; margin-bottom: 24px; backdrop-filter: blur(10px); transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); position: relative; scroll-margin-top: 40px;}
.explain-card:hover { border-color: rgba(99, 102, 241, 0.4); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.explain-card.highlight { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--primary-glow); }

.explain-card h4 { font-size: 17px; font-weight: 700; color: white; margin: 0 0 16px 0; display: flex; align-items: center; gap: 10px; letter-spacing: 0.3px;}
.explain-card h4 i { color: var(--primary); }
.explain-card p { font-size: 14px; line-height: 1.7; color: var(--text-muted); margin-bottom: 14px; }
.explain-card p strong { color: #e2e8f0; font-weight: 600; }
.explain-card p em { color: #818cf8; font-style: normal; background: rgba(99, 102, 241, 0.1); padding: 0 4px; border-radius: 4px;}

.step-badge { font-size: 11px; padding: 4px 10px; background: rgba(99, 102, 241, 0.15); border: 1px solid rgba(99, 102, 241, 0.3); color: #818cf8; border-radius: 20px; font-weight: 600; margin-left: auto; letter-spacing: 0.5px; }

/* Why Box */
.why-box { margin-top: 24px; padding: 20px; background: rgba(16, 185, 129, 0.05); border-left: 4px solid var(--success); border-radius: 0 12px 12px 0; border-top: 1px solid var(--border-color); border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); }
.why-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--success); margin-bottom: 8px; display: flex; align-items: center; gap: 8px;}
.why-box-content { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.why-box-content strong { color: #e2e8f0; }

/* Table overrides */
table { width: 100%; border-collapse: collapse; margin: 20px 0; background: rgba(255,255,255,0.02); border-radius: 12px; overflow: hidden; border: 1px solid var(--border-color); }
th { text-align: left; padding: 14px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: #cbd5e1; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.2); }
td { padding: 16px; font-size: 13px; color: var(--text-muted); border-bottom: 1px solid rgba(255,255,255,0.05); }
tr:last-child td { border-bottom: none; }

/* Tool grid */
.tool-grid-inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 24px 0; }
.tool-chip { display: flex; align-items: center; gap: 14px; padding: 16px; background: rgba(255,255,255,0.02); border: 1px solid var(--border-color); border-radius: 12px; transition: all 0.2s; }
.tool-chip:hover { border-color: var(--primary); background: rgba(99, 102, 241, 0.05); transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.15);}
.chip-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: rgba(99, 102, 241, 0.15); color: #818cf8; border-radius: 10px; border: 1px solid rgba(99,102,241,0.2); }
.chip-name { display: block; font-size: 14px; font-weight: 600; color: #e2e8f0; }
.chip-type { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Core Highlight overrides */
.core-highlight { border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 0 30px rgba(239, 68, 68, 0.1); background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), rgba(15, 23, 42, 0.6));}
.core-highlight::before { content: '🔥 CORE SYSTEM'; position: absolute; top: -12px; right: 24px; background: #ef4444; color: white; font-size: 10px; font-weight: 800; padding: 4px 12px; border-radius: 20px; letter-spacing: 1px; box-shadow: 0 0 15px rgba(239,68,68,0.5);}
.core-highlight h4 i { color: #f87171; }
.core-highlight .step-badge { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); color: #f87171; }

/* Hide global sidebar from main body if in iframe */
html.in-iframe body { background: transparent; }
html.in-iframe .main { background: transparent; }
