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

:root {
  --sidebar-bg: #1e1e2e;
  --sidebar-text: #cdd6f4;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #22c55e;
  --warning: #f59e0b;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

.app { display: flex; height: 100vh; }

/* Chat Panel */
.chat-panel { width: 400px; min-width: 350px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; }
.chat-header { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo { font-size: 18px; font-weight: 700; }
.btn-icon { background: none; border: none; color: var(--sidebar-text); font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.btn-icon:hover { background: rgba(255,255,255,0.1); }

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.msg { max-width: 95%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.msg.ai { background: rgba(255,255,255,0.08); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .step-badge { display: inline-block; background: var(--primary); color: #fff; border-radius: 10px; padding: 2px 8px; font-size: 11px; margin-bottom: 6px; font-weight: 600; }

.chat-input-area { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.input-wrap { display: flex; gap: 8px; align-items: flex-end; }
.input-wrap textarea { flex: 1; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); color: #fff; border-radius: 10px; padding: 10px 14px; font-size: 14px; resize: none; font-family: inherit; max-height: 120px; outline: none; }
.input-wrap textarea:focus { border-color: var(--primary); }
.btn-send { background: var(--primary); border: none; color: #fff; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 16px; flex-shrink: 0; }
.btn-send:hover { background: var(--primary-hover); }
.btn-generate { width: 100%; margin-top: 8px; padding: 10px; background: var(--success); color: #fff; border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-generate:hover { background: #16a34a; }

/* Flow Panel */
.flow-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.flow-header { padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--border); }
.flow-header h2 { font-size: 16px; font-weight: 600; }
.flow-actions { display: flex; gap: 6px; }
.btn-sm { padding: 6px 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-sm:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }

.flow-container { flex: 1; overflow: auto; padding: 20px; position: relative; }
.flow-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); }
.placeholder-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.5; }

.mermaid-output { background: var(--surface); border-radius: 12px; padding: 24px; border: 1px solid var(--border); transform-origin: top center; }

/* Details Panel */
.details-panel { background: var(--surface); border-top: 1px solid var(--border); max-height: 280px; overflow-y: auto; }
.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 16px; }
.tab { padding: 10px 16px; background: none; border: none; cursor: pointer; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent; font-weight: 500; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { padding: 16px; font-size: 13px; }

.tab-content table { width: 100%; border-collapse: collapse; }
.tab-content th, .tab-content td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.tab-content th { background: var(--bg); font-weight: 600; }
.tab-content ul { list-style: none; }
.tab-content li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.tab-content li:last-child { border: none; }

/* Responsive */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .chat-panel { width: 100%; height: 50vh; }
  .flow-panel { height: 50vh; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; padding: 14px 18px; }
.typing-indicator span { width: 8px; height: 8px; background: rgba(255,255,255,0.4); border-radius: 50%; animation: typingBounce 1.2s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
