/* FaultRx — Trusted Authority Design System (Redesign) */

/* === Tokens === */
:root {
    --bg-page: #0f172a;
    --bg-panel: #111827;
    --bg-surface: #1e293b;
    --bg-surface-hover: #263548;
    --bg-input: #0c1322;
    --brand-blue: #4A7FE0;
    --accent-blue: #60a5fa;
    --accent-blue-hover: #3b82f6;
    --accent-blue-pressed: #2563eb;
    --status-success: #4ade80;
    --status-success-bg: rgba(34, 197, 94, 0.12);
    --status-error: #ef4444;
    --status-error-bg: rgba(239, 68, 68, 0.1);
    --status-warning: #f59e0b;
    --status-warning-bg: rgba(245, 158, 11, 0.12);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-default: #334155;
    --border-hover: #475569;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --cat-segment: #ef4444;
    --cat-field: #f59e0b;
    --cat-encoding: #a855f7;
    --cat-structural: #ec4899;
    --cat-boundary: #06b6d4;
    --cat-realworld: #22c55e;
    --cat-constraint: #3b82f6;
    --cat-chain: #f97316;
    --cat-mcar: #8b5cf6;
    --cat-mar: #6366f1;
    --cat-nmar: #7c3aed;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* === Header === */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid var(--border-default);
}
.header-left { display: flex; align-items: center; }
.header-center { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-svg { height: 32px; width: auto; }
.logo-brand { font-size: 18px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.logo-divider { width: 1px; height: 24px; background: var(--border-default); margin: 0 8px; }
.logo-product { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

/* Badges */
.badge {
    display: flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 500;
}
.badge--success {
    background: var(--status-success-bg);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--status-success);
}
.badge--ai {
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #a78bfa;
}
.badge--neutral {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}
.pulse-dot {
    width: 6px; height: 6px;
    background: var(--status-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
.ai-icon { font-size: 12px; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* === Control Bar === */
.control-bar {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-default);
    padding: 14px 24px;
}
.control-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.control-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.control-select {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    padding: 7px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
}
.control-select:focus { border-color: var(--accent-blue); outline: none; }
.control-spacer { flex: 1; }
.control-toggle {
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
}
.control-toggle:hover { color: var(--accent-blue); }

/* Presets */
.preset-group {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.preset-btn {
    padding: 7px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 150ms ease;
    border-right: 1px solid var(--border-default);
}
.preset-btn:last-child { border-right: none; }
.preset-btn:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.preset-btn.active { background: var(--accent-blue-hover); color: white; font-weight: 600; }
.preset-hint { display: block; font-size: 10px; opacity: 0.7; margin-top: 1px; }

.btn-generate {
    background: var(--accent-blue-hover);
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease;
}
.btn-generate:hover { background: var(--accent-blue); }

/* Advanced Panel */
.advanced-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-default);
}
.advanced-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.advanced-group { display: flex; flex-direction: column; gap: 4px; }
.adv-label { font-size: 11px; color: var(--text-muted); }
.stepper { display: flex; align-items: center; }
.stepper-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    width: 28px; height: 28px;
    cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
}
.stepper-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.stepper-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.stepper-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.stepper-input {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-left: none; border-right: none;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    width: 44px; height: 28px;
    text-align: center;
}
.stepper-input:focus { outline: none; }
.checkbox-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-secondary); cursor: pointer;
}
.sample-textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 8px 10px;
    width: 100%;
    min-height: 60px;
    resize: vertical;
}
.sample-textarea:focus { border-color: var(--accent-blue); outline: none; }

/* Info Banner */
.info-banner {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin: 12px 24px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--accent-blue);
}

/* === Main Layout === */
.main-layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px 48px;
    gap: 20px;
}
.results-zone { flex: 1; min-width: 0; }
.results-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.results-title { font-size: 14px; font-weight: 600; }
.results-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
}
.results-spacer { flex: 1; }
.btn-export {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}
.btn-export:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

/* Category Groups */
.category-group { margin-bottom: 20px; }
.category-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-default);
}
.category-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.category-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.category-count { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-muted); }
.category-explain {
    font-size: 11px; color: var(--text-muted); font-weight: 400;
    text-transform: none; letter-spacing: 0; margin-left: auto;
}

/* Result Cards */
.result-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
    border-left: 3px solid var(--border-default);
}
.result-card:hover { border-color: var(--border-hover); background: var(--bg-surface-hover); }
.result-body { flex: 1; min-width: 0; }
.result-desc { font-size: 13px; color: var(--text-primary); margin-bottom: 1px; }
.result-explain { font-size: 11px; color: var(--text-muted); }
.result-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 3px 5px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
}
.btn-icon:hover { color: var(--accent-blue); border-color: var(--border-default); }

/* Severity Badges */
.sev-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px; font-weight: 600;
    padding: 2px 6px; border-radius: var(--radius-sm);
    flex-shrink: 0; min-width: 26px; text-align: center;
}
.sev-0 { background: rgba(34,197,94,0.15); color: #4ade80; }
.sev-1 { background: rgba(34,197,94,0.15); color: #4ade80; }
.sev-2 { background: rgba(245,158,11,0.15); color: #fbbf24; }
.sev-3 { background: rgba(239,68,68,0.15); color: #f87171; }
.sev-4 { background: rgba(239,68,68,0.2); color: #ef4444; }
.sev-5 { background: rgba(168,85,247,0.2); color: #c084fc; }

/* Inline Diff */
.inline-diff {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin-top: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}
.d-ok { color: var(--text-muted); }
.d-bad { color: var(--status-error); background: rgba(239,68,68,0.1); padding: 1px 2px; border-radius: 2px; }
.d-add { color: var(--status-success); background: rgba(34,197,94,0.1); padding: 1px 2px; border-radius: 2px; }

/* === Sidebar === */
.sidebar { width: 280px; flex-shrink: 0; }
.sidebar-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 12px;
}
.sidebar-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 10px;
}
.sidebar-stat {
    float: right;
    font-family: 'JetBrains Mono', monospace;
    color: var(--status-success);
}
.sidebar-stat--error { color: var(--status-error); }

/* Donut */
.donut-container { display: flex; align-items: center; gap: 14px; }
.donut {
    width: 68px; height: 68px; border-radius: 50%;
    background: conic-gradient(var(--status-success) 0% 0%, var(--border-default) 0% 100%);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.donut-inner {
    width: 50px; height: 50px;
    background: var(--bg-surface);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px; font-weight: 700; color: var(--status-success);
}
.donut-stats { font-size: 12px; }
.donut-label { color: var(--text-secondary); }
.donut-detail { color: var(--text-muted); font-size: 11px; }

/* Category Checklist */
.cat-check {
    display: flex; align-items: center; gap: 7px;
    padding: 4px 0; font-size: 12px;
}
.cat-check-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.cat-check-name { flex: 1; color: var(--text-secondary); }
.cat-check-count { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-muted); }
.cat-check .check { color: var(--status-success); font-size: 11px; }

/* Severity Bars */
.sev-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; }
.sev-row-label { width: 68px; color: var(--text-secondary); font-size: 11px; }
.sev-row-bar { flex: 1; height: 4px; background: var(--border-default); border-radius: 2px; overflow: hidden; }
.sev-row-fill { height: 100%; border-radius: 2px; transition: width 300ms ease; }
.sev-row-count { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-muted); width: 22px; text-align: right; }

/* Blind Spots */
.blind-spot {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px; color: var(--text-muted);
    padding: 2px 7px;
    background: var(--status-error-bg);
    border-radius: var(--radius-sm);
    display: inline-block;
    margin: 2px;
}
.blind-advice { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* === Auth Nav === */
.nav-auth { display: flex; align-items: center; gap: 4px; }
.nav-auth-signin {
    color: var(--text-secondary); text-decoration: none; font-size: 13px;
    font-weight: 500; padding: 6px 14px; border-radius: var(--radius-md);
    transition: all 150ms ease;
}
.nav-auth-signin:hover { background: var(--bg-surface); color: var(--text-primary); }
.btn-sm { font-size: 13px; padding: 6px 16px; font-weight: 600; }
.nav-user { display: flex; align-items: center; gap: 8px; }
.nav-username { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
#nav-signout { font-size: 13px; color: var(--accent-blue); text-decoration: none; }
#nav-signout:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* === Auth Modals === */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; transition: opacity 200ms ease;
    pointer-events: none;
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal-overlay.hidden { display: none; }
.modal-content {
    background: var(--bg-surface); border: 1px solid var(--border-default);
    border-radius: var(--radius-lg); position: relative;
    transform: translateY(20px); transition: transform 200ms ease;
}
.modal-overlay.visible .modal-content { transform: translateY(0); }
.modal-auth { max-width: 420px; width: 90%; }
.modal-close {
    position: absolute; top: 12px; right: 16px; background: none;
    border: none; color: var(--text-secondary); font-size: 22px;
    cursor: pointer; width: 36px; height: 36px; display: flex;
    align-items: center; justify-content: center; border-radius: var(--radius-md);
}
.modal-close:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.auth-modal-header { padding: 28px 28px 12px; text-align: center; }
.auth-modal-header h2 { font-size: 20px; font-weight: 700; margin: 0 0 4px; color: var(--text-primary); }
.auth-modal-header p { color: var(--text-secondary); font-size: 13px; margin: 0; }
.auth-form { padding: 12px 28px 28px; }
.auth-form .form-group { margin-bottom: 14px; }
.auth-form label {
    display: block; font-size: 13px; font-weight: 500;
    margin-bottom: 5px; color: var(--text-primary);
}
.auth-form .optional { color: var(--text-muted); font-weight: 400; }
.auth-input {
    width: 100%; padding: 10px 14px; background: var(--bg-input);
    border: 1px solid var(--border-default); border-radius: var(--radius-md);
    color: var(--text-primary); font-family: inherit; font-size: 14px;
    outline: none; transition: border-color 150ms ease;
    box-sizing: border-box;
}
.auth-input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1); }
.password-wrapper { position: relative; }
.password-toggle {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 4px; border-radius: var(--radius-sm);
}
.password-toggle:hover { color: var(--text-secondary); }
.auth-error {
    background: var(--status-error-bg); color: var(--status-error);
    padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 12px;
}
.btn-full { width: 100%; }
.btn-primary {
    background: var(--accent-blue-hover); color: white; border: none;
    padding: 11px 16px; border-radius: var(--radius-md);
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background 150ms ease;
}
.btn-primary:hover { background: var(--accent-blue-pressed); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-links { text-align: center; margin-top: 16px; font-size: 13px; }
.auth-links a { color: var(--accent-blue); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-consent {
    font-size: 11px; color: var(--text-muted); text-align: center;
    margin-top: 12px; line-height: 1.4;
}
.auth-consent a { color: var(--accent-blue); text-decoration: none; }

/* === Toast Notifications === */
.auth-toast {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%) translateY(-20px);
    max-width: 360px; width: 90%; padding: 12px 16px;
    background: var(--bg-surface); border: 1px solid var(--border-default);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-size: 13px; z-index: 2000; cursor: pointer;
    opacity: 0; transition: opacity 200ms ease, transform 200ms ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.auth-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.auth-toast--success { border-left: 3px solid var(--status-success); }
.auth-toast--error { border-left: 3px solid var(--status-error); }

/* === Responsive === */
@media (max-width: 900px) {
    .main-layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .control-row { flex-wrap: wrap; }
    .preset-group { flex-wrap: wrap; }
    .advanced-row { flex-wrap: wrap; }
}

@media (max-width: 768px) {
    .logo-brand { display: none; }
    .logo-divider { display: none; }
    .header-center .badge span:not(.pulse-dot) { display: none; }
    .modal-auth { max-width: 100%; width: 100%; height: 100%; border-radius: 0; }
    .modal-overlay { align-items: stretch; }
    .modal-close { width: 44px; height: 44px; }
}
