/* ============================================================
   Comma Workflows — Design System
   Brand: #003d38 (dark), #b7eedb (pistache), #fdf4ea (biscuit),
          #fad7e3 (blush), #7e807f (grey)
   ============================================================ */

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .heading-font {
    font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    /* Brand */
    --brand-dark: #003d38;
    --brand-pistache: #b7eedb;
    --brand-biscuit: #fdf4ea;
    --brand-blush: #fad7e3;
    --brand-grey: #7e807f;

    /* Semantic */
    --blue: #3b82f6;
    --amber: #f59e0b;
    --emerald: #10b981;
    --red: #ef4444;

    /* Surfaces */
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #ffffff;
    --bg-muted: #f1f5f9;

    /* Borders */
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-focus: var(--brand-dark);

    /* Text */
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-faint: #cbd5e1;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);

    /* Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--border-hover); transform: translateY(-1px); }
.card-interactive { cursor: pointer; }
.card-interactive:hover { box-shadow: var(--shadow-md); border-color: var(--brand-dark); transform: translateY(-2px); }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: var(--radius);
    font-family: 'Inter', sans-serif; font-weight: 600; font-size: 0.875rem;
    border: none; cursor: pointer; transition: all 0.2s;
    text-decoration: none; line-height: 1.4;
}
.btn-primary {
    background: var(--brand-dark);
    color: var(--brand-pistache);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(0,61,56,0.25); }

.btn-secondary { background: var(--bg-muted); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }

.btn-ghost { background: transparent; color: var(--text-muted); padding: 8px 12px; }
.btn-ghost:hover { color: var(--text); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* --- Inputs --- */
.input {
    width: 100%; padding: 10px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg-input);
    color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.875rem;
    outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { border-color: var(--brand-dark); box-shadow: 0 0 0 3px rgba(0,61,56,0.1); }
.input::placeholder { color: var(--text-faint); }

/* --- Labels --- */
.label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.label-optional { color: var(--text-muted); font-weight: 400; }

/* --- Badges --- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 0.7rem; font-weight: 600; line-height: 1.4; }
.badge-blue { background: rgba(59,130,246,0.12); color: #3b82f6; }
.badge-amber { background: rgba(245,158,11,0.12); color: #f59e0b; }
.badge-emerald { background: rgba(16,185,129,0.12); color: #10b981; }
.badge-brand { background: rgba(183,238,219,0.3); color: var(--brand-dark); }

/* --- Section headers --- */
.section-label { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.section-title {
    font-family: 'Space Grotesk', sans-serif; font-size: 0.75rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page-centered { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.container-sm { max-width: 420px; width: 100%; padding: 2rem; }
.container-md { max-width: 560px; width: 100%; padding: 2rem; }
.container-lg { max-width: 1400px; width: 100%; margin: 0 auto; padding: 0 24px; }

/* ============================================================
   HEADER (for non-sidebar pages)
   ============================================================ */
.app-header { background: var(--bg-card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; box-shadow: var(--shadow-sm); }
.app-header-inner { max-width: 1400px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; }
.app-logo { width: 32px; height: 32px; }
.app-title { font-family: 'Space Grotesk', sans-serif; font-size: 0.95rem; font-weight: 700; color: var(--brand-dark); line-height: 1.2; }
.app-subtitle { font-size: 0.65rem; color: var(--text-muted); }

/* ============================================================
   NODE / AGENT CARDS
   ============================================================ */
.node { /* kept for JS compat */ }
.node-title { font-size: 11px; font-weight: 600; color: var(--text); line-height: 1.2; }
.node-subtitle { font-size: 9px; color: var(--text-muted); margin-top: 1px; }
.node-content { flex: 1; min-width: 0; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse-status { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:0.5; transform:scale(1.4); } }
@keyframes icon-pulse { 0%,100% { transform:scale(1); filter:brightness(1); } 50% { transform:scale(1.08); filter:brightness(1.15); } }
@keyframes fade-in-up { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes slide-in-right { from { transform:translateX(100%); } to { transform:translateX(0); } }
@keyframes highlight-flash { 0% { background:rgba(183,238,219,0.3); } 100% { background:transparent; } }
@keyframes typewriter-cursor { 0%,100% { opacity:1; } 50% { opacity:0; } }
@keyframes pulse-launch { 0%,100% { transform:scale(1); opacity:0.85; } 50% { transform:scale(1.04); opacity:1; } }

/* ============================================================
   SIDE PANEL
   ============================================================ */
.side-panel {
    position: fixed; top: 0; right: 0; width: 480px; max-width: 90vw; height: 100vh;
    background: var(--bg-card); z-index: 60; transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg); overflow: hidden;
}
.side-panel.is-open { transform: translateX(0); }
.side-panel-inner { height: 100%; overflow-y: auto; padding: 24px; }

.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3); backdrop-filter: blur(2px);
    z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.overlay.is-visible { opacity: 1; pointer-events: auto; }

/* ============================================================
   TERMINAL / PROGRESS LOG
   ============================================================ */
.terminal {
    background: #0f172a; border-radius: var(--radius-lg); padding: 16px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 11px; overflow-y: auto; color: #64748b;
}
.terminal .log-entry { padding: 2px 0; border-left: 2px solid transparent; padding-left: 8px; animation: fade-in-up 0.3s ease; }
.terminal .log-entry.log-new { animation: fade-in-up 0.3s ease, highlight-flash 1s ease; }
.terminal .log-entry.log-agent { border-left-color: var(--emerald); color: #6ee7b7; font-weight: 500; }
.terminal .log-entry.log-tool { border-left-color: var(--amber); color: #fbbf24; }
.terminal .log-entry.log-raw { color: #475569; font-size: 10px; opacity: 0.7; }
.terminal .log-entry.log-complete { border-left-color: var(--emerald); color: #34d399; font-weight: 600; }
.terminal .log-entry.log-error { border-left-color: var(--red); color: #f87171; font-weight: 500; }
.terminal-cursor::after { content: '\2588'; animation: typewriter-cursor 0.8s step-end infinite; color: var(--emerald); margin-left: 1px; }

/* ============================================================
   PROSE / RESULTS
   ============================================================ */
.prose h1 { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--brand-dark); }
.prose h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.2rem; margin-top: 1.5rem; margin-bottom: 0.5rem; color: var(--brand-dark); }
.prose h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; margin-top: 1rem; color: var(--text); }
.prose table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 1rem 0; font-size: 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.prose th { background: var(--bg-muted); text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--brand-dark); }
.prose th:not(:last-child) { border-right: 1px solid var(--border); }
.prose td { padding: 10px 14px; border-bottom: 1px solid var(--bg-muted); color: var(--text); }
.prose td:not(:last-child) { border-right: 1px solid var(--bg-muted); }
.prose tr:nth-child(even) td { background: var(--bg-muted); }
.prose tr:hover td { background: var(--border); }
.prose tr:last-child td { border-bottom: none; }
.prose strong { color: var(--brand-dark); }
.prose hr { border-color: var(--border); margin: 1.5rem 0; }
.prose p { margin: 0.5rem 0; line-height: 1.7; color: var(--text); }
.prose ul, .prose ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.prose li { margin: 0.25rem 0; color: var(--text); }

/* ============================================================
   SCORING & REPORTS
   ============================================================ */
.score-card { background: var(--bg-muted); border-radius: var(--radius-lg); padding: 16px; border: 1px solid var(--border); }
.score-card h5 { font-family: 'Space Grotesk', sans-serif; font-size: 13px; font-weight: 600; color: var(--brand-dark); margin-bottom: 8px; }
.score-option { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 12px; color: var(--text-secondary); }
.score-option .score-value { font-weight: 600; color: var(--brand-dark); background: rgba(183,238,219,0.3); padding: 2px 8px; border-radius: 4px; }

.report-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; background: var(--bg-muted); border-radius: var(--radius);
    border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;
}
.report-item:hover { border-color: var(--brand-dark); background: var(--bg-card); }

/* ============================================================
   WIZARD
   ============================================================ */
.wizard-viewport { position: relative; width: 100%; height: 100vh; overflow: hidden; }
.wizard-step {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}
.wizard-step.below { transform: translateY(100%); opacity: 0; pointer-events: none; }
.wizard-step.above { transform: translateY(-40%); opacity: 0; pointer-events: none; }
.wizard-step.active { transform: translateY(0); opacity: 1; pointer-events: auto; }

.wizard-input {
    width: 100%; padding: 14px 0; font-size: 1.2rem; font-family: 'Inter', sans-serif;
    background: transparent; border: none; border-bottom: 2px solid var(--border);
    outline: none; color: var(--text); caret-color: var(--brand-dark); transition: border-color 0.3s;
}
.wizard-input:focus { border-bottom-color: var(--brand-dark); }
.wizard-input::placeholder { color: var(--text-faint); }

.wizard-progress {
    position: fixed; top: 0; left: 0; height: 3px;
    background: linear-gradient(90deg, var(--brand-dark), var(--brand-pistache));
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); z-index: 100;
}

.step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: var(--radius-sm);
    background: var(--brand-dark); color: var(--brand-pistache);
    font-size: 12px; font-weight: 700;
}

.kbd {
    display: inline-block; padding: 2px 7px; border-radius: 4px;
    border: 1px solid var(--border); font-size: 11px; font-family: monospace;
    color: var(--text-muted); background: var(--bg-card);
}

.launch-pulse { animation: pulse-launch 1.5s ease-in-out infinite; }
