/* CLord — UI Stylesheet */
/* Four themes: warm-dark (default), soft-light, warm-paper, desert */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

/* ── THEME: Warm Dark ─────────────────────────────────────────────────── */
:root, [data-theme="warm-dark"] {
    --bg:          #1a1714;
    --bg-alt:      #211e1b;
    --surface:     #2a2622;
    --surface-2:   #332e29;
    --border:      #3d3731;
    --text:        #f0ebe4;
    --text-muted:  #8a7f74;
    --text-dim:    #5a5248;
    --primary:     #d4a96a;
    --primary-dark:#b8874a;
    --primary-glow:rgba(212,169,106,0.15);
    --accent:      #e8c896;
    --success:     #6ab88a;
    --warning:     #d4a96a;
    --error:       #d46a6a;
    --error-bg:    rgba(212,106,106,0.12);
    --success-bg:  rgba(106,184,138,0.12);
    --warning-bg:  rgba(212,169,106,0.12);
    --shadow:      0 2px 12px rgba(0,0,0,0.4);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
    --radius:      8px;
    --radius-lg:   12px;
    --sidebar-w:   260px;
    --font:        'Geist', system-ui, sans-serif;
    --mono:        'Geist Mono', ui-monospace, monospace;
}

/* ── THEME: Soft Light ────────────────────────────────────────────────── */
[data-theme="soft-light"] {
    --bg:          #f5f4f2;
    --bg-alt:      #eeece8;
    --surface:     #ffffff;
    --surface-2:   #f0ede8;
    --border:      #ddd9d2;
    --text:        #2a2520;
    --text-muted:  #7a736a;
    --text-dim:    #b0a89e;
    --primary:     #7a5c3a;
    --primary-dark:#5e4228;
    --primary-glow:rgba(122,92,58,0.1);
    --accent:      #9a7c5a;
    --success:     #3a7a5a;
    --warning:     #9a7c3a;
    --error:       #9a3a3a;
    --error-bg:    rgba(154,58,58,0.08);
    --success-bg:  rgba(58,122,90,0.08);
    --warning-bg:  rgba(154,124,58,0.08);
    --shadow:      0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg:   0 8px 24px rgba(0,0,0,0.12);
}

/* ── THEME: Warm Paper ────────────────────────────────────────────────── */
[data-theme="warm-paper"] {
    --bg:          #f7f0e6;
    --bg-alt:      #f0e8d8;
    --surface:     #fdf8f0;
    --surface-2:   #ede4d4;
    --border:      #d8cebf;
    --text:        #3a2e20;
    --text-muted:  #8a7460;
    --text-dim:    #b8a890;
    --primary:     #8a5a2a;
    --primary-dark:#6a3e18;
    --primary-glow:rgba(138,90,42,0.12);
    --accent:      #a8743a;
    --success:     #4a7a4a;
    --warning:     #9a7a2a;
    --error:       #9a3a2a;
    --error-bg:    rgba(154,58,42,0.1);
    --success-bg:  rgba(74,122,74,0.1);
    --warning-bg:  rgba(154,122,42,0.1);
    --shadow:      0 2px 8px rgba(58,46,32,0.1);
    --shadow-lg:   0 8px 24px rgba(58,46,32,0.15);
}

/* ── THEME: Desert ───────────────────────────────────────────────────── */
[data-theme="desert"] {
    --bg:          #1c1510;
    --bg-alt:      #241b13;
    --surface:     #2e2218;
    --surface-2:   #3a2c1f;
    --border:      #4a3828;
    --text:        #f2e8d8;
    --text-muted:  #9a8570;
    --text-dim:    #6a5848;
    --primary:     #d47c3a;
    --primary-dark:#b8601e;
    --primary-glow:rgba(212,124,58,0.15);
    --accent:      #e8a86a;
    --success:     #7ab86a;
    --warning:     #d4a83a;
    --error:       #d4603a;
    --error-bg:    rgba(212,96,58,0.12);
    --success-bg:  rgba(122,184,106,0.12);
    --warning-bg:  rgba(212,168,58,0.12);
    --shadow:      0 2px 12px rgba(0,0,0,0.5);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
    --radius:      8px;
    --radius-lg:   12px;
    --sidebar-w:   260px;
    --font:        'Geist', system-ui, sans-serif;
    --mono:        'Geist Mono', ui-monospace, monospace;
}

/* ── RESET & BASE ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── APP LAYOUT ───────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-alt);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-top { padding: 16px 14px 12px; border-bottom: 1px solid var(--border); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.logo-icon { font-size: 20px; }
.logo-icon-xl { font-size: 64px; display: block; text-align: center; }

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.theme-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
}
.theme-btn:hover { color: var(--text); background: var(--surface-2); }

.sidebar-actions { display: flex; gap: 6px; }
.sidebar-new-btn { flex: 1; }

/* ── PROJECT LIST ─────────────────────────────────────────────────────── */
.project-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.folder-item { }
.folder-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
}
.folder-header:hover { color: var(--text); }
.folder-arrow { font-size: 10px; transition: transform 0.15s; }
.folder-item.open .folder-arrow { transform: rotate(90deg); }
.folder-children { padding-left: 8px; display: none; }
.folder-item.open .folder-children { display: block; }

.project-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    border-radius: 6px;
    margin: 1px 6px;
    transition: background 0.1s;
    position: relative;
}
.project-item:hover { background: var(--surface-2); }
.project-item.active {
    background: var(--primary-glow);
    color: var(--primary);
}
.project-item.active .project-name { color: var(--primary); font-weight: 500; }

.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-draft    { background: var(--text-dim); }
.status-deploying{ background: var(--warning); animation: pulse 1s infinite; }
.status-deployed { background: var(--success); }
.status-error    { background: var(--error); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.project-name { font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-owner { font-size: 11px; color: var(--text-muted); }

/* ── SIDEBAR FOOTER ───────────────────────────────────────────────────── */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-info { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 13px; font-weight: 500; }
.role-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-admin { background: var(--primary-glow); color: var(--primary); }
.role-user  { background: var(--surface-2); color: var(--text-muted); }

.sidebar-link { font-size: 12px; color: var(--text-muted); }
.sidebar-link:hover { color: var(--text); text-decoration: none; }

/* ── MAIN PANEL ───────────────────────────────────────────────────────── */
.main-panel {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ── WELCOME STATE ────────────────────────────────────────────────────── */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    text-align: center;
    padding: 40px;
}

.welcome-logo h1 {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -2px;
    margin-top: 8px;
}
.welcome-tagline { font-size: 18px; color: var(--text-muted); margin-top: 4px; }
.welcome-sub     { font-size: 12px; color: var(--text-dim); }

/* ── PROJECT VIEW TABS ────────────────────────────────────────────────── */
.project-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.project-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
    flex-shrink: 0;
}

.project-title-editable {
    font-size: 16px;
    font-weight: 600;
    cursor: text;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid transparent;
    background: none;
    color: var(--text);
}
.project-title-editable:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-muted);
}

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
    padding: 0 20px;
    flex-shrink: 0;
}

.tab-btn {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s;
    margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; flex: 1; overflow: hidden; }
.tab-panel.active { display: flex; flex-direction: column; }

/* ── CHAT ─────────────────────────────────────────────────────────────── */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 76%;
}
.chat-msg.user   { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; }
.chat-msg.system { align-self: center; max-width: 90%; }

.chat-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}
.chat-msg.user .chat-bubble {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.chat-msg.assistant .chat-bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 3px;
}
.chat-msg.system .chat-bubble {
    background: var(--success-bg);
    border: 1px solid var(--success);
    color: var(--success);
    font-size: 13px;
    text-align: center;
}

.chat-ts { font-size: 11px; color: var(--text-dim); margin-top: 3px; opacity: 0; transition: opacity 0.15s; }
.chat-msg:hover .chat-ts { opacity: 1; }

.apply-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.apply-btn:hover { background: var(--primary-dark); }
.apply-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.deploy-divider {
    text-align: center;
    padding: 6px 0;
    font-size: 12px;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: center;
}
.deploy-divider::before, .deploy-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--success);
    opacity: 0.3;
}

.depth-selector {
    display: flex;
    gap: 4px;
    padding: 2px;
    background: var(--surface-2);
    border-radius: 6px;
}
.depth-btn {
    padding: 4px 10px;
    font-size: 12px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-muted);
}
.depth-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ── READY TO DEPLOY BANNER ───────────────────────────────────────────── */
.deploy-ready-banner {
    margin: 12px 20px;
    padding: 16px 20px;
    background: var(--success-bg);
    border: 1px solid var(--success);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
}
.deploy-ready-banner .check { font-size: 20px; }
.deploy-ready-banner p { flex: 1; font-size: 14px; color: var(--success); }

/* ── CHAT INPUT ───────────────────────────────────────────────────────── */
.chat-input-area {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-alt);
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: border-color 0.15s;
}
.chat-input-row:focus-within { border-color: var(--primary); }

.chat-textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    min-height: 24px;
    max-height: 120px;
}
.chat-textarea::placeholder { color: var(--text-dim); }

.chat-send-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.chat-send-btn:hover { background: var(--primary-dark); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.token-estimate { font-size: 11px; color: var(--text-dim); margin-top: 4px; text-align: right; }

/* ── DEPLOYMENT PROGRESS ─────────────────────────────────────────────── */
.deploy-panel {
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    overflow: hidden;
}

.deploy-title { font-size: 20px; font-weight: 600; }

.progress-bar-track {
    background: var(--surface-2);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.4s ease;
}
.progress-pct { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.agent-steps { display: flex; flex-direction: column; gap: 8px; }
.agent-step {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}
.step-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }
.step-name { flex: 1; }
.step-status { font-size: 12px; color: var(--text-muted); }
.step-done   .step-icon { color: var(--success); }
.step-running{ background: var(--primary-glow); border-color: var(--primary); }
.step-running .step-name { color: var(--primary); }

.log-box {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 12px;
    padding: 12px;
    line-height: 1.6;
    min-height: 0;
}
.log-line { white-space: pre-wrap; }
.log-line.warn { color: var(--warning); }
.log-line.error { color: var(--error); }

/* ── API INSPECTOR ────────────────────────────────────────────────────── */
.api-inspector { padding: 20px; overflow-y: auto; flex: 1; }
.api-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.api-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.api-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
}
.api-table tr:last-child td { border-bottom: none; }
.api-total { margin-top: 12px; font-size: 13px; color: var(--text-muted); font-family: var(--mono); }

/* ── LOGS TAB ─────────────────────────────────────────────────────────── */
.logs-panel { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }

.job-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.job-row-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
}
.job-row-header:hover { background: var(--surface-2); }
.job-num { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.job-type { font-size: 13px; font-weight: 500; flex: 1; }
.job-meta { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.job-status-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.badge-done    { background: var(--success-bg); color: var(--success); }
.badge-failed  { background: var(--error-bg);   color: var(--error); }
.badge-running { background: var(--warning-bg); color: var(--warning); }
.badge-pending { background: var(--surface-2);  color: var(--text-muted); }

.job-row-body { display: none; padding: 12px 14px; border-top: 1px solid var(--border); }
.job-row.open .job-row-body { display: block; }

.files-pill-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.file-pill {
    font-family: var(--mono);
    font-size: 11px;
    padding: 2px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
}
.file-pill:hover { color: var(--primary); border-color: var(--primary); }

/* ── VERSIONS TAB ─────────────────────────────────────────────────────── */
.versions-panel { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }

.version-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.version-row.current { border-left: 3px solid var(--primary); }
.version-num { font-family: var(--mono); font-weight: 600; color: var(--primary); min-width: 32px; }
.version-info { flex: 1; }
.version-summary { font-size: 13px; }
.version-meta { font-size: 11px; color: var(--text-muted); font-family: var(--mono); margin-top: 2px; }
.version-actions { display: flex; gap: 6px; }

/* ── ENVIRONMENTS TAB ─────────────────────────────────────────────────── */
.envs-panel { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }

.env-card {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.env-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 4px; }
.env-url  { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.env-footer { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.env-indicator { display: flex; align-items: center; gap: 5px; font-size: 12px; flex: 1; }

/* ── BUTTONS ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-danger    { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error); color: #fff; }

.btn-ghost  { background: none; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm     { padding: 5px 10px; font-size: 12px; }
.btn-lg     { padding: 12px 24px; font-size: 15px; }
.btn-full   { width: 100%; justify-content: center; }

/* ── MODALS ───────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-width: 360px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal h2 { font-size: 17px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── FORMS ────────────────────────────────────────────────────────────── */
.form-group   { margin-bottom: 14px; }
.form-label   { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 14px;
    color: var(--text);
    font-family: var(--font);
    transition: border-color 0.15s;
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }

/* ── ALERTS ───────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; border: 1px solid; }
.alert-error   { background: var(--error-bg);   color: var(--error);   border-color: var(--error); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }

/* ── CONTEXT MENU ─────────────────────────────────────────────────────── */
.context-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: 4px 0;
    min-width: 160px;
    z-index: 2000;
    font-size: 13px;
}
.context-menu li a, .context-menu li button {
    display: block;
    width: 100%;
    padding: 7px 14px;
    color: var(--text);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    font-family: var(--font);
}
.context-menu li a:hover, .context-menu li button:hover { background: var(--surface-2); text-decoration: none; }
.context-menu li.danger a, .context-menu li.danger button { color: var(--error); }
.context-menu li.sep { height: 1px; background: var(--border); margin: 4px 0; pointer-events: none; }

/* ── THEME PICKER ─────────────────────────────────────────────────────── */
.theme-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 900;
    display: flex; align-items: center; justify-content: center;
}
.theme-picker {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
}
.theme-picker h3 { margin-bottom: 16px; font-size: 15px; }
.theme-swatches { display: flex; gap: 12px; margin-bottom: 16px; }
.theme-swatch {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: none; border: 2px solid var(--border);
    border-radius: var(--radius); padding: 8px; cursor: pointer;
    font-size: 12px; color: var(--text-muted); transition: border-color 0.15s;
}
.theme-swatch:hover { border-color: var(--primary); }
.swatch-preview { width: 48px; height: 32px; border-radius: 4px; }
.swatch-warm-dark  { background: linear-gradient(135deg, #1a1714 50%, #d4a96a 50%); }
.swatch-soft-light { background: linear-gradient(135deg, #f5f4f2 50%, #7a5c3a 50%); }
.swatch-warm-paper { background: linear-gradient(135deg, #f7f0e6 50%, #8a5a2a 50%); }
.swatch-desert     { background: linear-gradient(135deg, #1c1510 50%, #d47c3a 50%); }

/* ── LOGIN PAGE ───────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 360px;
    box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.login-logo .logo-text { font-size: 24px; }
.login-tagline { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.login-version { font-size: 11px; color: var(--text-dim); text-align: center; margin-top: 16px; }

/* ── IMPORT PREVIEW ───────────────────────────────────────────────────── */
.import-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    font-size: 13px;
    margin-top: 12px;
}
.import-preview .preview-row { display: flex; gap: 8px; margin-bottom: 4px; }
.import-preview .preview-key { color: var(--text-muted); min-width: 120px; }

/* ── SCROLLBARS ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── SPINNING LOADER ──────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── REQUIREMENTS HISTORY IN ITERATION CHAT ──────────────────────────── */
.req-history-section {
    margin-bottom: 4px;
}
.req-history-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 6px 12px;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}
.req-history-toggle:hover { background: var(--surface-alt); color: var(--text); }
.req-history-arrow { display: inline-block; width: 12px; }
.req-history-body {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 8px;
    background: var(--surface);
    max-height: 300px;
    overflow-y: auto;
}
.req-history-sep {
    text-align: center;
    margin: 14px 0 10px;
    position: relative;
}
.req-history-sep::before {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 50%;
    border-top: 1px solid var(--border);
}
.req-history-sep span {
    position: relative;
    background: var(--bg);
    padding: 0 10px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ── FILE MANAGER ─────────────────────────────────────────────────────── */
.fm-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
    gap: 0;
}
.fm-sidebar {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
}
.fm-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.fm-toolbar-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}
.fm-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    cursor: pointer;
    font-size: 11px;
    padding: 4px 8px;
    white-space: nowrap;
    transition: background 0.15s;
}
.fm-btn:hover { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); }
.fm-btn-primary { background: var(--primary); border-color: var(--primary); color: var(--bg); font-weight: 600; }
.fm-btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: var(--bg); }
.fm-btn-danger:hover { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.fm-btn:disabled { opacity: 0.5; cursor: default; }

.fm-tree {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}
.fm-empty { padding: 16px; color: var(--text-muted); font-size: 13px; }
.fm-tree-list { list-style: none; margin: 0; padding: 0; }
.fm-tree-list .fm-tree-list { padding-left: 0; }

.fm-dir-row, .fm-file-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px 4px 6px;
    cursor: pointer;
    border-radius: 4px;
    margin: 1px 4px;
    font-size: 13px;
    user-select: none;
}
.fm-dir-row:hover, .fm-file-row:hover { background: var(--surface-2); }
.fm-file.active .fm-file-row { background: var(--primary-glow); color: var(--primary); }
.fm-arrow { font-size: 10px; width: 12px; flex-shrink: 0; color: var(--text-muted); }
.fm-dir-icon, .fm-file-icon { font-size: 13px; flex-shrink: 0; }
.fm-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-size { font-size: 10px; color: var(--text-dim); flex-shrink: 0; }
.fm-dir-children { display: none; }
.fm-dir.open .fm-dir-children { display: block; }

/* Editor pane */
.fm-editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}
.fm-editor-empty, .fm-editor-loading, .fm-editor-error, .fm-editor-binary {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 14px;
}
.fm-editor-error { color: var(--error); }
.fm-editor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.fm-editor-path {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fm-editor-size { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.fm-editor-actions { display: flex; gap: 6px; flex-shrink: 0; }
.fm-editor-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.fm-editor-textarea {
    flex: 1;
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: none;
    outline: none;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    padding: 14px 16px;
    resize: none;
    tab-size: 4;
}
.fm-image-preview {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: repeating-conic-gradient(var(--surface) 0% 25%, var(--bg) 0% 50%) 0 0 / 20px 20px;
}
.fm-image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: var(--shadow-lg); }

/* ── Image attachments in iterate chat ───────────────────────────────────── */
.chat-attach-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 6px;
    opacity: 0.6;
    flex-shrink: 0;
    line-height: 1;
}
.chat-attach-btn:hover { opacity: 1; }

.chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px 0;
}
.chat-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.chat-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.chat-thumb-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}
.chat-sent-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.chat-sent-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* ── Project description subtitle ───────────────────────────────────────── */
.project-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 4px;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

/* ── 3-dot project dropdown ─────────────────────────────────────────────── */
.project-dropdown {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    z-index: 9999;
    min-width: 200px;
    padding: 4px;
}
.project-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
}
.project-dropdown button:hover { background: var(--hover); }

/* ── API Inspector summary bar ──────────────────────────────────────────── */
.api-summary {
    display: flex;
    gap: 2rem;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.api-summary-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.api-summary-num {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--mono);
}
.api-summary-lbl {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 600;
}

/* ── Admin panel iframe ──────────────────────────────────────────────────── */
#adminFrame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    flex: 1;
    min-height: 0;
}
.main-panel:has(#adminFrame) {
    overflow: hidden;
}

/* ── Docs Tab ────────────────────────────────────────────────────────────── */
.docs-panel { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.docs-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.docs-content { flex: 1; overflow-y: auto; padding: 24px 32px; }
.docs-meta { font-size: 11px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; margin-bottom: 16px; display: inline-block; }
.docs-body h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 16px; color: var(--text); }
.docs-body h2 { font-size: 1.2rem; font-weight: 600; margin: 24px 0 10px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.docs-body h3 { font-size: 1rem; font-weight: 600; margin: 16px 0 8px; color: var(--text); }
.docs-body h4 { font-size: 0.9rem; font-weight: 600; margin: 12px 0 6px; color: var(--text-muted); }
.docs-body p { margin: 0 0 10px; line-height: 1.6; color: var(--text); }
.docs-body ul { margin: 8px 0 12px 20px; }
.docs-body li { margin: 4px 0; line-height: 1.5; color: var(--text); }
.docs-body code { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 0.85em; }
.docs-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.docs-body strong { font-weight: 600; }
.docs-body em { font-style: italic; color: var(--text-muted); }

/* ── Admin panel stat cards ─────────────────────────────────────────────── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}

/* ── Iterate chat depth selector ─────────────────────────────────────────── */
.chat-depth-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 6px;
}
.chat-depth-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-right: 2px;
}
.chat-depth-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.chat-depth-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.chat-depth-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}
