/* ============================================
   Quorum — Helix Astra Design System
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:wght@400;500;600&display=swap');

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

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #222222;
    --bg-tertiary: #2a2a2a;
    --bg-card: #2a2a2a;
    --gold: #C8944A;
    --gold-light: #d4a85c;
    --gold-dark: #a87a3a;
    --text-primary: #e8e0d4;
    --text-secondary: #9a9590;
    --text-muted: #6a6560;
    --white: #f5f0eb;
    --border-color: rgba(200, 148, 74, 0.15);
    --glow: rgba(200, 148, 74, 0.08);
    --green: #4ac878;
    --red: #ef4444;
    --analyst: #C8944A;
    --strategist: #8b5cf6;
    --researcher: #10b981;
    --advisor: #d4a85c;
    --user: #C8944A;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; font-weight: 400; }

.app { display: flex; flex-direction: column; height: 100vh; }

/* Header */
.header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 24px; background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.header-left { display: flex; align-items: center; }
.header h1 {
    font-family: 'Playfair Display', serif; font-size: 1.25rem; font-weight: 500;
    color: var(--white); letter-spacing: 0.05em;
}
.header-right { display: flex; align-items: center; gap: 8px; }
.subtitle { color: var(--text-secondary); font-size: 0.75rem; margin-left: 12px; letter-spacing: 0.05em; }

.status-indicator { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-secondary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.status-dot.connected { background: var(--green); }

/* Main layout */
.main-layout { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.agent-panel {
    width: 260px; background: var(--bg-secondary);
    border-right: 1px solid var(--border-color); padding: 16px; overflow-y: auto;
}
.agent-panel h2 {
    font-family: 'Inter', sans-serif; font-size: 0.7rem; text-transform: uppercase;
    letter-spacing: 0.12em; color: var(--gold); margin-bottom: 10px;
}
.agent-card {
    display: flex; align-items: center; gap: 10px; padding: 10px;
    border-radius: 12px; margin-bottom: 4px; transition: all 0.3s;
    border: 1px solid transparent;
}
.agent-card:hover { background: var(--bg-tertiary); border-color: var(--border-color); }
.agent-card.active { background: var(--bg-tertiary); border-color: rgba(200, 148, 74, 0.3); }
.agent-avatar {
    font-size: 1.3rem; width: 32px; height: 32px; display: flex; align-items: center;
    justify-content: center; border-radius: 10px; background: var(--bg-tertiary); flex-shrink: 0; overflow: hidden;
}
.agent-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.agent-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.agent-name { font-size: 0.82rem; font-weight: 500; color: var(--white); }
.agent-role { font-size: 0.65rem; color: var(--text-secondary); }
.agent-model { font-size: 0.58rem; color: var(--gold); opacity: 0.7; margin-top: 1px; }
.agent-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bg-tertiary); flex-shrink: 0; }
.agent-status-dot.thinking { background: var(--gold); animation: pulse 1s infinite; }
.agent-status-dot.idle { background: #374151; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Discussion panel */
.discussion-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.discussion-messages { flex: 1; overflow-y: auto; padding: 20px 24px; scroll-behavior: smooth; }
.welcome-message { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.welcome-message h2 { font-family: 'Playfair Display', serif; font-size: 1.4rem; color: var(--white); margin-bottom: 8px; }
.welcome-message p { font-size: 0.85rem; max-width: 500px; margin: 0 auto; line-height: 1.5; }

/* Messages */
.message { display: flex; gap: 12px; margin-bottom: 14px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.message-avatar {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 10px; background: var(--bg-tertiary); flex-shrink: 0; font-size: 1.1rem; overflow: hidden;
    border: 1px solid var(--border-color);
}
.message-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.message-body { flex: 1; min-width: 0; }
.message-header { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.message-sender { font-weight: 600; font-size: 0.82rem; }
.message-role {
    font-size: 0.65rem; color: var(--gold); background: var(--glow);
    padding: 2px 10px; border-radius: 100px; border: 1px solid var(--border-color);
}
.message-time { font-size: 0.65rem; color: var(--text-muted); margin-left: auto; }
.message-content {
    font-size: 0.88rem; line-height: 1.6; color: var(--text-primary);
    background: var(--bg-secondary); padding: 14px 18px;
    border-radius: 2px 14px 14px 14px; border-left: 3px solid var(--border-color);
    word-break: break-word;
}

/* Agent colors */
.message[data-agent="analyst"] .message-content,
.message[data-agent="coordinator"] .message-content { border-left-color: var(--analyst); }
.message[data-agent="analyst"] .message-sender,
.message[data-agent="coordinator"] .message-sender { color: var(--analyst); }
.message[data-agent="strategist"] .message-content,
.message[data-agent="planner"] .message-content { border-left-color: var(--strategist); }
.message[data-agent="strategist"] .message-sender,
.message[data-agent="planner"] .message-sender { color: var(--strategist); }
.message[data-agent="researcher"] .message-content { border-left-color: var(--researcher); }
.message[data-agent="researcher"] .message-sender { color: var(--researcher); }
.message[data-agent="advisor"] .message-content,
.message[data-agent="executor"] .message-content { border-left-color: var(--advisor); }
.message[data-agent="advisor"] .message-sender,
.message[data-agent="executor"] .message-sender { color: var(--advisor); }
.message[data-agent="user"] .message-content { border-left-color: var(--gold); background: rgba(200, 148, 74, 0.06); }
.message[data-agent="user"] .message-sender { color: var(--gold); }

/* Council vote colors */
.message[data-agent="council-mistral"] .message-content { border-left-color: #f97316; }
.message[data-agent="council-mistral"] .message-sender { color: #f97316; }
.message[data-agent="council-llama"] .message-content { border-left-color: #a855f7; }
.message[data-agent="council-llama"] .message-sender { color: #a855f7; }
.message[data-agent="council-nova"] .message-content { border-left-color: #14b8a6; }
.message[data-agent="council-nova"] .message-sender { color: #14b8a6; }

/* Thinking */
.thinking-indicator { display: flex; gap: 4px; padding: 8px 16px; }
.thinking-indicator span { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); animation: bounce 1.4s infinite; }
.thinking-indicator span:nth-child(2) { animation-delay: 0.2s; }
.thinking-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } }

/* Input */
.input-area { padding: 14px 24px; background: var(--bg-secondary); border-top: 1px solid var(--border-color); }
.input-wrapper { display: flex; gap: 12px; align-items: flex-end; }
textarea {
    flex: 1; background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: 14px; padding: 12px 16px; color: var(--text-primary);
    font-family: 'Inter', sans-serif; font-size: 0.88rem; resize: none; outline: none;
    transition: border-color 0.3s;
}
textarea:focus { border-color: var(--gold); }
textarea::placeholder { color: var(--text-muted); }

button#sendBtn {
    display: flex; align-items: center; gap: 8px; padding: 12px 24px;
    background: var(--gold); color: var(--bg-primary); border: none;
    border-radius: 100px; font-size: 0.85rem; font-weight: 500;
    cursor: pointer; white-space: nowrap; font-family: 'Inter', sans-serif;
    transition: all 0.3s;
}
button#sendBtn:hover { background: var(--gold-light); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(200, 148, 74, 0.3); }
button#sendBtn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* Phase divider */
.phase-divider {
    display: flex; align-items: center; gap: 12px; margin: 16px 0;
    color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
}
.phase-divider::before, .phase-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-color); }

/* Pipeline Progress */
.pipeline-progress { display: flex; justify-content: center; padding: 10px 24px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); }
.pipeline-steps { display: flex; align-items: center; }
.pipeline-step { display: flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 100px; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: #374151; transition: all 0.3s; }
.step-label { font-size: 0.68rem; color: var(--text-muted); }
.pipeline-step.active .step-dot { background: var(--gold); box-shadow: 0 0 8px var(--gold); animation: pulse 1s infinite; }
.pipeline-step.active .step-label { color: var(--gold); font-weight: 600; }
.pipeline-step.done .step-dot { background: var(--green); }
.pipeline-step.done .step-label { color: var(--green); }
.pipeline-connector { width: 20px; height: 2px; background: #374151; }

/* Markdown in messages */
.message-content h1, .message-content h2, .message-content h3 { margin: 6px 0 2px; color: var(--white); font-family: 'Playfair Display', serif; }
.message-content h1 { font-size: 1.05rem; } .message-content h2 { font-size: 0.95rem; } .message-content h3 { font-size: 0.88rem; }
.message-content p { margin: 2px 0; }
.message-content ul, .message-content ol { margin: 2px 0; padding-left: 18px; }
.message-content li { margin: 1px 0; } .message-content li p { margin: 0; }
.message-content strong { color: var(--white); }
.message-content code { background: var(--bg-tertiary); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; border: 1px solid var(--border-color); }
.message-content pre { background: var(--bg-primary); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 4px 0; border: 1px solid var(--border-color); }
.message-content pre code { background: none; padding: 0; border: none; }
.message-content table { border-collapse: collapse; margin: 4px 0; font-size: 0.85rem; width: 100%; }
.message-content th, .message-content td { border: 1px solid var(--border-color); padding: 4px 10px; text-align: left; }
.message-content th { background: var(--bg-tertiary); font-weight: 600; color: var(--gold); }
.message-content a { color: var(--gold); text-decoration: underline; }
.message-content > *:first-child { margin-top: 0; }
.message-content > *:last-child { margin-bottom: 0; }

/* Council votes */
.council-vote { margin: 6px 0; padding: 12px 16px; border-radius: 12px; border-left: 3px solid var(--border-color); background: var(--bg-secondary); animation: fadeIn 0.3s ease; font-size: 0.82rem; }
.council-vote.vote-approve { border-left-color: var(--green); background: rgba(74, 200, 120, 0.05); }
.council-vote.vote-revise { border-left-color: var(--gold); background: rgba(200, 148, 74, 0.05); }
.vote-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.vote-icon { font-size: 0.9rem; }
.vote-agent { font-weight: 600; font-size: 0.8rem; }
.vote-badge { font-size: 0.62rem; font-weight: 600; padding: 2px 10px; border-radius: 100px; text-transform: uppercase; letter-spacing: 0.05em; }
.vote-badge.vote-approve { background: rgba(74, 200, 120, 0.15); color: var(--green); border: 1px solid rgba(74, 200, 120, 0.25); }
.vote-badge.vote-revise { background: rgba(200, 148, 74, 0.15); color: var(--gold); border: 1px solid rgba(200, 148, 74, 0.25); }
.vote-time { font-size: 0.62rem; color: var(--text-muted); margin-left: auto; }
.vote-reason { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.4; }
.vote-suggestions { font-size: 0.78rem; color: var(--gold); line-height: 1.4; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-color); }
.vote-suggestions-label { font-weight: 600; }

/* Revision */
.revision-prompt { display: flex; align-items: center; gap: 12px; margin: 10px 0; padding: 12px 18px; background: var(--glow); border: 1px solid rgba(200, 148, 74, 0.25); border-radius: 12px; }
.revision-header { font-size: 0.82rem; color: var(--gold); font-weight: 500; }
.revision-btn { margin-left: auto; padding: 8px 20px; background: var(--gold); color: var(--bg-primary); border: none; border-radius: 100px; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.3s; }
.revision-btn:hover { background: var(--gold-light); box-shadow: 0 4px 16px rgba(200, 148, 74, 0.3); }
.revision-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cost */
.cost-summary { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 12px; margin: 8px 0; font-size: 0.68rem; color: var(--text-muted); opacity: 0.7; }

/* Spend tracker */
.spend-tracker { display: flex; align-items: center; gap: 6px; padding: 4px 14px; background: var(--bg-tertiary); border-radius: 100px; margin-right: 12px; border: 1px solid var(--border-color); }
.spend-amount { font-size: 0.82rem; font-weight: 600; color: var(--green); font-family: 'SF Mono', 'Fira Code', monospace; }
.spend-label { font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Input toggles */
.input-toggles { display: flex; gap: 6px; margin-bottom: 8px; }
.input-toggle { padding: 4px 12px; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 100px; color: var(--text-secondary); font-size: 0.7rem; cursor: pointer; transition: all 0.3s; }
.input-toggle:hover { border-color: var(--gold); color: var(--text-primary); }
.input-toggle.active { background: var(--gold); border-color: var(--gold); color: var(--bg-primary); }

/* Session list */
#sessionList .agent-card { border-left: 2px solid transparent; }
#sessionList .agent-card:hover { border-left-color: var(--gold); }
#sessionList .agent-card.active { border-left-color: var(--gold); background: var(--bg-tertiary); }

/* Office viz */
.agent-office { margin-top: 12px; padding: 8px; background: var(--bg-primary); border-radius: 12px; border: 1px solid var(--border-color); }
.agent-office svg { width: 100%; height: auto; }
.office-agent { transition: filter 0.3s, opacity 0.3s; opacity: 0.5; }
.office-agent.active { opacity: 1; filter: drop-shadow(0 0 6px currentColor); }
.office-agent.active .head { animation: headBob 0.8s ease-in-out infinite; }
.office-agent.active .typing-dots { opacity: 1 !important; }
.office-agent.done { opacity: 0.8; }
.office-agent.done .screen-glow { fill: var(--green); opacity: 0.3; }
@keyframes headBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.council-agent.active .head { animation: headBob 0.8s ease-in-out infinite; }

/* Paywall overlay */
.paywall-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.paywall-card {
    background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 20px;
    padding: 40px; max-width: 480px; width: 90%; text-align: center;
}
.paywall-card h2 { font-family: 'Playfair Display', serif; color: var(--white); margin-bottom: 12px; font-size: 1.5rem; }
.paywall-card p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.6; margin-bottom: 24px; }
.upgrade-options { display: flex; flex-direction: column; gap: 10px; }
.upgrade-btn {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; background: var(--glow); border: 1px solid var(--border-color);
    border-radius: 14px; color: var(--text-primary); font-size: 0.9rem; cursor: pointer;
    transition: all 0.3s; font-family: 'Inter', sans-serif;
}
.upgrade-btn:hover { border-color: var(--gold); background: rgba(200, 148, 74, 0.12); }
.upgrade-btn span { color: var(--gold); font-size: 0.8rem; }

/* Disclaimer */
.financial-disclaimer {
    margin: 8px 0; padding: 10px 14px; background: rgba(200, 148, 74, 0.05);
    border: 1px solid var(--border-color); border-radius: 8px;
    font-size: 0.7rem; color: var(--text-muted); line-height: 1.5;
}

/* Persistent chat disclaimer under input */
.chat-disclaimer {
    margin-top: 8px; padding: 8px 12px; background: rgba(200, 148, 74, 0.06);
    border: 1px solid rgba(200, 148, 74, 0.15); border-radius: 8px;
    font-size: 0.68rem; color: var(--text-muted); line-height: 1.5; text-align: center;
}
.chat-disclaimer a {
    color: var(--text-secondary); text-decoration: none; transition: color 0.2s;
}
.chat-disclaimer a:hover { color: var(--gold); }

/* Disclaimer modal */
.disclaimer-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.disclaimer-card {
    background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 20px;
    padding: 40px; max-width: 560px; width: 90%;
}
.disclaimer-card h2 { font-family: 'Playfair Display', serif; color: var(--white); margin-bottom: 16px; }
.disclaimer-card p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.7; margin-bottom: 12px; }
.disclaimer-card label { display: flex; align-items: center; gap: 10px; color: var(--text-primary); font-size: 0.85rem; margin: 20px 0; cursor: pointer; }
.disclaimer-card input[type="checkbox"] { accent-color: var(--gold); width: 18px; height: 18px; }
.disclaimer-accept-btn {
    width: 100%; padding: 14px; background: var(--gold); color: var(--bg-primary);
    border: none; border-radius: 100px; font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: all 0.3s; font-family: 'Inter', sans-serif;
}
.disclaimer-accept-btn:hover { background: var(--gold-light); }
.disclaimer-accept-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Responsive */
@media (max-width: 768px) { .agent-panel { display: none; } }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(200, 148, 74, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(200, 148, 74, 0.4); }
