/* ═══════════════════════════════════════════════════════════════
   DEFINITIVE HDR — Shared Design System
   ═══════════════════════════════════════════════════════════════ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

/* ── Design Tokens ── */
:root {
    --bg-body: #0c0c0f;
    --bg-sidebar: #111114;
    --bg-card: #111114;
    --bg-input: #0c0c0f;
    --bg-hover: #16161a;
    --bg-active: #1a1a20;
    --border: #1e1e24;
    --border-hover: #2a2a32;
    --text-primary: #fff;
    --text-secondary: #e0e0e0;
    --text-muted: #666;
    --text-faint: #444;
    --text-dim: #555;
    --accent: #4A90D9;
    --accent-hover: #3a7bc8;
    --green: #5cb85c;
    --yellow: #d4a84b;
    --orange: #e8a040;
    --red: #d9534f;
    --purple: #b85cc8;
    --sidebar-width: 220px;
    --sidebar-collapsed: 56px;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 10px;
    --radius-sm: 7px;
    --radius-xs: 5px;
}

/* ── Body ── */
body {
    background: var(--bg-body);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    min-height: 100vh;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR — Collapsible
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    min-height: 68px;
}
.logo { display: flex; flex-direction: column; white-space: nowrap; overflow: hidden; }
.logo h1 { font-size: 15px; font-weight: 700; color: var(--text-primary); letter-spacing: 0.5px; }
.logo span { font-size: 10px; color: var(--accent); letter-spacing: 2px; text-transform: uppercase; font-weight: 600; }
.sidebar.collapsed .logo { opacity: 0; width: 0; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 20px 0; }

.sidebar-toggle {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 18px; padding: 4px;
    border-radius: 4px; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }

.nav { padding: 12px 0; flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav-section {
    padding: 16px 20px 6px; font-size: 10px; color: var(--text-faint);
    letter-spacing: 1.5px; text-transform: uppercase; font-weight: 600;
    white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .nav-section { opacity: 0; height: 0; padding: 0; margin: 0; }

.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: var(--text-muted); text-decoration: none;
    font-size: 13px; font-weight: 500; transition: all 0.15s;
    border-left: 2px solid transparent; white-space: nowrap;
}
.nav a:hover { color: var(--text-secondary); background: var(--bg-hover); }
.nav a.active { color: var(--text-primary); border-left-color: var(--accent); background: var(--bg-active); }

.nav-icon {
    width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.nav-label { overflow: hidden; transition: opacity 0.2s; }
.sidebar.collapsed .nav-label { opacity: 0; width: 0; }
.sidebar.collapsed .nav a { padding: 10px 0; justify-content: center; border-left-width: 0; }
.sidebar.collapsed .nav a.active { background: var(--bg-active); border-left-width: 0; }

/* ── Sidebar version tag ── */
.sidebar-footer {
    padding: 12px 20px; border-top: 1px solid var(--border);
    font-size: 10px; color: var(--text-faint); white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .sidebar-footer { opacity: 0; }

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════ */
.main {
    margin-left: var(--sidebar-width); padding: 32px 40px;
    min-height: 100vh; transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-collapsed); }

/* ── Page Header ── */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 32px;
}
.page-header h2 { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.page-header-sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* ── Cards ── */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
}
.card h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.card p.sub { font-size: 13px; color: var(--text-dim); margin-bottom: 20px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 14px; color: var(--text-secondary);
    font-size: 13px; font-family: var(--font-sans); outline: none;
    transition: border-color 0.15s; height: 42px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { height: auto; min-height: 80px; resize: vertical; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Buttons ── */
.btn {
    border: none; border-radius: var(--radius-sm); padding: 12px 28px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all 0.15s; font-family: var(--font-sans);
}
.btn-primary { background: var(--accent); color: var(--text-primary); width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #1e1e24; color: var(--text-dim); cursor: not-allowed; }

.btn-success { background: var(--green); color: var(--text-primary); width: 100%; }
.btn-success:hover { background: #4cae4c; }
.btn-success:disabled { background: #1e1e24; color: var(--text-dim); cursor: not-allowed; }

.btn-sm { padding: 8px 16px; font-size: 12px; border-radius: 6px; }
.btn-outline { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: white; }
.btn-outline:disabled { border-color: var(--text-dim); color: var(--text-dim); cursor: not-allowed; }

.btn-ghost {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    padding: 8px 16px; font-size: 12px;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }

/* ── Drop Zones ── */
.drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 40px; text-align: center; cursor: pointer;
    transition: all 0.15s; margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: rgba(74,144,217,0.06); }
.drop-zone h4 { font-size: 14px; color: var(--text-muted); margin-bottom: 6px; }
.drop-zone p { font-size: 12px; color: var(--text-dim); }
.drop-zone input { display: none; }
.file-count { font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 8px; }

/* ── Badges ── */
.badge {
    padding: 4px 10px; border-radius: 12px; font-size: 11px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    display: inline-block;
}
.badge-pending { background: #1e1e16; color: var(--yellow); }
.badge-processing { background: #12161f; color: var(--accent); }
.badge-completed, .badge-ready { background: #101a10; color: var(--green); }
.badge-needs_review { background: #1a1610; color: var(--orange); }
.badge-failed { background: #1a1010; color: var(--red); }

/* ── Section Title ── */
.section-title {
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px;
}

/* ── Status Pill ── */
.status-pill {
    display: flex; align-items: center; gap: 6px;
    background: #141a14; border: 1px solid #1e2e1e;
    padding: 8px 14px; border-radius: 20px;
    font-size: 12px; color: var(--green); font-weight: 500;
}
.status-dot {
    width: 7px; height: 7px; background: var(--green);
    border-radius: 50%; animation: pulse 2s infinite;
}

/* ── Empty State ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); font-size: 14px; }

/* ── Progress Bar ── */
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }

/* ── QC Results ── */
.qc-result { margin-top: 10px; border-radius: 6px; padding: 12px; font-size: 12px; }
.qc-pass { background: #0e160e; border: 1px solid #1e2e1e; }
.qc-fix { background: #16140e; border: 1px solid #2e2a1e; }
.qc-rerun { background: #160e0e; border: 1px solid #2e1e1e; }
.qc-verdict-label { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.qc-pass .qc-verdict-label { color: var(--green); }
.qc-fix .qc-verdict-label { color: var(--yellow); }
.qc-rerun .qc-verdict-label { color: var(--red); }
.qc-summary { color: #aaa; margin-bottom: 8px; line-height: 1.5; }
.qc-instructions {
    color: var(--text-secondary); background: #08080a; border-radius: 4px;
    padding: 8px; margin-top: 6px; line-height: 1.6;
    font-family: var(--font-mono); font-size: 11px;
}
.qc-confidence { font-size: 10px; color: var(--text-dim); margin-top: 6px; }

/* ── Filter Bar ── */
.filter-bar {
    display: flex; gap: 4px; margin-bottom: 16px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; padding: 4px;
}
.filter-btn {
    padding: 8px 18px; border: none; border-radius: 6px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    background: transparent; color: var(--text-muted);
    transition: all 0.15s; font-family: var(--font-sans);
}
.filter-btn:hover { color: var(--text-secondary); }
.filter-btn.active { background: var(--accent); color: white; }
.filter-btn .filter-count {
    font-size: 10px; background: var(--red); color: white;
    border-radius: 8px; padding: 1px 6px; margin-left: 4px; font-weight: 700;
}

/* ── Toggle Buttons ── */
.toggle-btn {
    padding: 6px 12px; font-size: 12px; background: var(--bg-body);
    border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-muted); cursor: pointer; transition: all 0.15s;
    font-family: var(--font-sans); position: relative; overflow: hidden;
}
.toggle-btn:hover { border-color: var(--border-hover); color: #ccc; }
.toggle-btn.active { background: #12161f; border-color: var(--accent); color: var(--text-primary); }

/* ── Animations ── */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes shimmer { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulsing { animation: pulse 1.5s ease-in-out infinite; }

/* ── Mono values ── */
.mono { font-family: var(--font-mono); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a32; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a42; }

/* ── Detect Card (batch) ── */
.detect-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px; position: relative;
    transition: border-color 0.15s;
}
.detect-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.detect-card.skipped { opacity: 0.3; }
.detect-card.skipped img { filter: grayscale(1); }
.detect-card img { width: 100%; border-radius: 4px; border: 1px solid var(--border); }
.detect-card .dc-filename { font-size: 10px; color: var(--text-dim); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detect-card .dc-room { font-size: 12px; font-weight: 600; margin-top: 4px; display: flex; justify-content: space-between; align-items: center; }
.detect-card .dc-room .room-label { color: var(--accent); }
.detect-card .dc-room .confidence { font-size: 10px; color: var(--text-dim); }
.detect-card .dc-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.detect-card select {
    width: 100%; background: var(--bg-body); border: 1px solid var(--border);
    border-radius: 5px; padding: 6px 8px; color: var(--text-secondary);
    font-size: 11px; margin-top: 6px; font-family: var(--font-sans);
}
.detect-card .dc-skip {
    position: absolute; top: 6px; right: 6px;
    background: rgba(0,0,0,0.6); color: var(--text-muted);
    border: none; border-radius: 4px; padding: 2px 6px;
    font-size: 10px; cursor: pointer;
}
.detect-card .dc-skip:hover { color: var(--red); }

.detect-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }

/* ── Summary Tags ── */
.summary-bar { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.summary-tag { font-size: 11px; padding: 4px 10px; border-radius: 12px; font-weight: 600; }
.summary-tag.ext { background: #12161f; color: var(--accent); }
.summary-tag.stg { background: #101a10; color: var(--green); }
.summary-tag.skip { background: #1e1e24; color: var(--text-muted); }

/* ── Step Indicator ── */
.step-indicator { display: flex; gap: 24px; margin-bottom: 24px; }
.step { font-size: 12px; font-weight: 600; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.step.active { color: var(--accent); }
.step.done { color: var(--green); }
.step-num {
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; border: 2px solid var(--text-faint);
}
.step.active .step-num { border-color: var(--accent); color: var(--accent); }
.step.done .step-num { border-color: var(--green); color: var(--green); }

/* ── Auto-Pilot Toggle ── */
.autopilot-bar {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 12px; padding: 12px 16px;
    background: #0e160e; border: 1px solid #1e2e1e; border-radius: 8px;
}
.autopilot-bar.off { background: var(--bg-card); border-color: var(--border); }
.toggle-switch { position: relative; width: 44px; height: 24px; cursor: pointer; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: #2a2a32; border-radius: 12px; transition: background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--green); }
.toggle-knob {
    position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
    background: white; border-radius: 50%; transition: transform 0.2s;
}
.toggle-switch input:checked ~ .toggle-knob { transform: translateX(20px); }
.autopilot-label { font-size: 13px; font-weight: 600; color: var(--green); }
.autopilot-bar.off .autopilot-label { color: var(--text-muted); }
.autopilot-desc { font-size: 11px; color: var(--text-muted); }
