/* --- Variables & Reset --- */
:root {
    --bg-body: #000000;
    --bg-card: #1c1c1e;
    --bg-elevated: #2c2c2e;
    --border-color: #38383a;
    --text-primary: #ffffff;
    --text-secondary: #98989d;
    --accent-blue: #0a84ff;
    --accent-green: #30d158;
    --accent-red: #ff453a;
    --accent-orange: #ff9f0a;
    --input-bg: rgba(255, 255, 255, 0.1);
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
}

/* --- Login Screen --- */
.login-screen {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; width: 100%;
}
.login-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 20px; padding: 40px 30px; width: 320px;
    display: flex; flex-direction: column; align-items: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.login-input {
    background: var(--input-bg); border: 1px solid var(--border-color);
    border-radius: 12px; color: #fff; padding: 12px 16px; font-size: 1rem;
    width: 100%; text-align: center; transition: all 0.2s;
}
.login-input:focus {
    background: rgba(255,255,255,0.15); border-color: var(--accent-blue);
    outline: none; box-shadow: 0 0 15px rgba(10, 132, 255, 0.2);
}
.login-input::placeholder { color: var(--text-secondary); }

/* Test Selection */
.tests-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 20px; padding: 40px 30px; width: 420px; max-width: 95vw;
    display: flex; flex-direction: column; align-items: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.test-grid {
    display: flex; flex-direction: column; gap: 10px; width: 100%;
}
.test-card {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px; padding: 16px 20px; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    transition: all 0.2s;
}
.test-card:hover {
    background: rgba(10, 132, 255, 0.1); border-color: var(--accent-blue);
    transform: translateY(-1px);
}
.test-number { font-weight: 700; font-size: 1.05rem; color: #fff; }
.test-info { font-size: 0.85rem; color: var(--text-secondary); }

/* --- Navbar --- */
.ios-navbar {
    background-color: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 0 1rem;
    z-index: 1000;
    height: 54px;
    display: flex; align-items: center; justify-content: space-between;
}

.brand-section { display: flex; align-items: center; gap: 10px; }
.brand-text { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.badge-role {
    background: rgba(255,255,255,0.15); color: #ddd;
    padding: 2px 8px; border-radius: 6px;
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
}

.batch-progress {
    background: #2c2c2e; border-radius: 100px; padding: 4px 16px;
    display: flex; align-items: center; gap: 12px; font-size: 0.85rem;
    border: 1px solid rgba(255,255,255,0.1);
    position: absolute; left: 50%; transform: translateX(-50%);
    white-space: nowrap;
}
.progress-label { color: var(--text-secondary); margin-right: 4px; }
.progress-val { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- Workspace --- */
.main-workspace { flex: 1; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.player-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background-color: #333; height: 100%; width: 100%; }

.video-viewport {
    position: relative; overflow: hidden; background: #000;
    display: flex; align-items: center; justify-content: center; cursor: grab;
}
.video-viewport:active { cursor: grabbing; }
.panzoom-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

.viewport-label {
    position: absolute; top: 12px; left: 12px;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
    padding: 2px 8px; border-radius: 6px;
    font-size: 0.75rem; font-weight: 700;
    border: 1px solid rgba(255,255,255,0.1); z-index: 10;
}
.text-rest { color: var(--accent-green); }
.text-stress { color: var(--accent-red); }

/* --- HUD --- */
.hud-wrapper {
    position: absolute; bottom: 55px; left: 0; right: 0; z-index: 100;
    display: flex; justify-content: center; align-items: flex-end;
    pointer-events: none;
}
.hud-center-stack {
    position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
    z-index: 105; pointer-events: auto;
    display: flex; flex-direction: column; align-items: center;
}
.hud-decision-layer {
    display: flex; justify-content: center; align-items: center;
    gap: 510px; width: 100%; pointer-events: none; z-index: 110;
    padding-bottom: 2px; height: 48px;
}
.hud-side-group { display: flex; align-items: center; pointer-events: auto; }

.btn-decision {
    height: 48px; padding: 0 24px; border-radius: 24px; border: none;
    font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4); transition: 0.2s; color: #fff; cursor: pointer;
    white-space: nowrap;
}
.btn-decision:active { transform: scale(0.96); }

.btn-dx-pos { background: rgba(255, 159, 10, 0.2); border: 1px solid var(--accent-orange); color: var(--accent-orange); }
.btn-dx-pos:hover { background: var(--accent-orange); color: #000; }
.btn-dx-neg { background: rgba(255,255,255,0.1); border: 1px solid var(--text-secondary); color: var(--text-primary); }
.btn-dx-neg:hover { background: #fff; color: #000; }

.kbd-badge {
    font-size: 0.65rem; opacity: 0.7; font-family: monospace;
    background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 4px;
    margin-left: 6px;
}
.btn-decision .kbd-badge { border: 1px solid rgba(255,255,255,0.2); color: #fff; }

.hud-pill {
    background: rgba(28, 28, 30, 0.85); backdrop-filter: blur(15px);
    border: 1px solid rgba(255,255,255,0.15); border-radius: 100px;
    padding: 6px 16px; display: flex; align-items: center; gap: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); pointer-events: auto;
    height: 48px;
}
.hud-group { display: flex; align-items: center; gap: 8px; border-right: 1px solid rgba(255,255,255,0.1); padding-right: 12px; }
.hud-group:last-child { border-right: none; padding-right: 0; }

.hud-btn {
    background: transparent; border: 1px solid transparent; color: #fff; opacity: 0.7;
    font-size: 0.85rem; padding: 2px 6px; border-radius: 4px; transition: 0.2s;
    display: flex; align-items: center; gap: 4px;
}
.hud-btn:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.hud-btn.active { color: var(--accent-blue); opacity: 1; font-weight: 600; background: rgba(10, 132, 255, 0.15); }

.slider-group { display: flex; flex-direction: column; gap: 2px; }
.slider-row { display: flex; align-items: center; gap: 6px; }
.slider-icon { font-size: 0.7rem; color: var(--text-secondary); width: 12px; text-align: center; }
.compact-range { -webkit-appearance: none; appearance: none; background: transparent; width: 60px; cursor: pointer; }
.compact-range:focus { outline: none; }
.compact-range::-webkit-slider-runnable-track { width: 100%; height: 3px; background: rgba(255,255,255,0.2); border-radius: 2px; }
.compact-range::-webkit-slider-thumb { -webkit-appearance: none; height: 10px; width: 10px; border-radius: 50%; background: #fff; margin-top: -3.5px; }

/* --- Overlays --- */
.overlay-panel {
    position: absolute; bottom: 140px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: rgba(28, 28, 30, 0.95); backdrop-filter: blur(20px);
    border: 1px solid var(--border-color); border-radius: 20px;
    padding: 20px; width: 95%; max-width: 700px;
    opacity: 0; pointer-events: none; transition: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex; flex-direction: column; gap: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6); max-height: 65vh; overflow-y: auto; z-index: 150;
}
.overlay-panel.active { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

.segments-container { display: flex; justify-content: center; gap: 15px; }
.seg-column { display: flex; flex-direction: column; gap: 8px; max-width: 320px; width: 100%; }
.seg-wrapper { display: flex; flex-direction: column; gap: 6px; }
.seg-btn {
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary); border-radius: 8px; padding: 6px 10px;
    display: flex; align-items: center; gap: 10px; cursor: pointer; transition: 0.1s;
    min-height: 42px;
}
.seg-btn:hover { background: rgba(255,255,255,0.15); }
.seg-btn.selected { background: rgba(255, 159, 10, 0.15); color: var(--accent-orange); border-color: var(--accent-orange); }
.seg-id {
    font-size: 0.75rem; font-weight: 800; width: 20px; height: 20px; border-radius: 50%;
    border: 1px solid var(--text-secondary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.seg-btn.selected .seg-id { background: var(--accent-orange); color: #000; border-color: var(--accent-orange); }
.seg-name { font-size: 0.7rem; line-height: 1.1; font-weight: 500; }

/* --- SVG Segment Diagrams --- */
.svg-holder {
    width: 100%; max-height: 180px; display: flex; align-items: center; justify-content: center;
    margin-bottom: 8px;
}
.svg-holder object {
    width: 100%; max-height: 170px; pointer-events: auto;
}

/* --- Feedback Overlay --- */
.feedback-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); z-index: 300;
    display: none; align-items: center; justify-content: center;
}
.feedback-overlay.active { display: flex; }
.feedback-card {
    background: var(--bg-card); border-radius: 24px; padding: 40px 50px;
    text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    border: 2px solid var(--border-color); transition: border-color 0.3s;
}
.feedback-card.correct { border-color: var(--accent-green); }
.feedback-card.wrong { border-color: var(--accent-red); }
.feedback-icon { font-size: 3rem; margin-bottom: 10px; }
.feedback-text { font-size: 1.1rem; color: var(--text-secondary); }

/* Feedback Segments Comparison */
.feedback-card {
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    min-width: 520px;
    padding: 36px 40px;
}
.feedback-segments { margin-top: 20px; }
.feedback-seg-row {
    display: flex;
    gap: 24px;
    justify-content: center;
}
.feedback-seg-col {
    flex: 1;
    max-width: 280px;
    text-align: center;
}
.feedback-seg-label {
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}
.fb-label-gold { color: var(--accent-green); }
.fb-label-user { color: var(--accent-blue); }
.feedback-svg-holder {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px;
    min-height: 140px;
}
.feedback-seg-legend {
    margin-top: 8px;
    font-size: 0.78rem;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.fb-leg-correct {
    color: #30d158;
    font-weight: 600;
}
.fb-leg-correct::before { content: "\25CF "; }
.fb-leg-wrong {
    color: #ff453a;
    font-weight: 600;
}
.fb-leg-wrong::before { content: "\25CF "; }
.fb-leg-missed {
    color: #ff9f0a;
    font-weight: 600;
}
.fb-leg-missed::before { content: "\25CB "; }

/* --- Drawer --- */
.analysis-drawer {
    position: fixed; bottom: 0; left: 0; right: 0;
    background-color: var(--bg-card); border-top: 1px solid var(--border-color);
    border-radius: 20px 20px 0 0; box-shadow: 0 -5px 30px rgba(0,0,0,0.5); z-index: 200;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform: translateY(calc(100% - 48px)); height: 60vh;
    display: flex; flex-direction: column;
}
.analysis-drawer.open { transform: translateY(0); }

.drawer-handle-area {
    height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
    cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05); background: rgba(255,255,255,0.02);
}
.drawer-handle-area:hover { background: rgba(255,255,255,0.05); }
.drawer-indicator { width: 40px; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; position: absolute; left: 50%; transform: translateX(-50%); top: 8px; }

.analysis-content { flex: 1; padding: 20px; overflow-y: auto; color: #ccc; font-size: 0.9rem; }
.fade-hidden { display: none !important; }

/* Stats */
.stat-card {
    background: rgba(255,255,255,0.05); border-radius: 12px; padding: 15px;
    text-align: center; border: 1px solid rgba(255,255,255,0.05);
}
.stat-val { font-size: 1.8rem; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 0.75rem; color: #888; text-transform: uppercase; margin-top: 5px; }

.leaderboard-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.leader-pill {
    background: #333; padding: 6px 14px; border-radius: 20px;
    display: flex; align-items: center; gap: 10px;
    font-size: 0.9rem; border: 1px solid #444;
}
.leader-score { color: #fff; font-weight: 700; }
.leader-name { color: #aaa; }
.leader-pill.is-me { border-color: var(--accent-blue); background: rgba(10, 132, 255, 0.15); }

/* Case grid in drawer */
.batch-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 8px; padding-bottom: 20px;
}
.case-cell {
    width: 56px; height: 56px; border-radius: 10px;
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 600; color: var(--text-secondary);
    cursor: pointer; transition: 0.2s;
}
.case-cell:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }
.case-cell.answered-correct { border-color: var(--accent-green); color: var(--accent-green); background: rgba(48, 209, 88, 0.1); }
.case-cell.answered-wrong { border-color: var(--accent-red); color: var(--accent-red); background: rgba(255, 69, 58, 0.1); }
.case-cell.active { border-color: var(--accent-blue); box-shadow: 0 0 10px rgba(10, 132, 255, 0.3); }

/* --- Mode Selection Modal --- */
.mode-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8); z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
.mode-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 20px; padding: 40px 30px; width: 420px; max-width: 95vw;
    display: flex; flex-direction: column; align-items: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.mode-buttons { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.mode-btn {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px; padding: 20px; cursor: pointer;
    display: flex; align-items: center; gap: 16px;
    transition: all 0.2s; color: #fff;
}
.mode-btn:hover {
    background: rgba(10, 132, 255, 0.1); border-color: var(--accent-blue);
    transform: translateY(-1px);
}
.mode-btn i { font-size: 1.8rem; flex-shrink: 0; }
.mode-btn-training i { color: var(--accent-green); }
.mode-btn-testing i { color: var(--accent-orange); }
.mode-btn-title { font-weight: 700; font-size: 1.05rem; display: block; }
.mode-btn-desc { font-size: 0.8rem; color: var(--text-secondary); display: block; }

/* Mode badge in navbar */
.mode-badge {
    padding: 2px 8px; border-radius: 6px;
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-left: 6px;
}
.mode-badge.training { background: rgba(48, 209, 88, 0.2); color: var(--accent-green); }
.mode-badge.testing { background: rgba(255, 159, 10, 0.2); color: var(--accent-orange); }

/* --- Results Overlay (Testing mode) --- */
.results-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); z-index: 400;
    display: flex; align-items: center; justify-content: center;
    overflow-y: auto; padding: 20px;
}
.results-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 20px; padding: 36px 40px;
    max-width: 700px; width: 100%; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.results-header { text-align: center; margin-bottom: 24px; }
.results-stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
    margin-bottom: 24px;
}
.results-stat {
    background: rgba(255,255,255,0.05); border-radius: 12px; padding: 14px;
    text-align: center; border: 1px solid rgba(255,255,255,0.05);
}
.results-stat-val { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.results-stat-label { font-size: 0.7rem; color: #888; text-transform: uppercase; margin-top: 4px; }

.results-table-wrap { max-height: 40vh; overflow-y: auto; margin-bottom: 20px; border-radius: 12px; }
.results-table {
    width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.results-table thead { position: sticky; top: 0; z-index: 1; }
.results-table th {
    background: var(--bg-elevated); color: var(--text-secondary);
    padding: 10px 12px; text-align: left; font-weight: 600;
    border-bottom: 1px solid var(--border-color); font-size: 0.75rem;
    text-transform: uppercase;
}
.results-table td {
    padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text-primary);
}
.results-table tr:hover td { background: rgba(255,255,255,0.03); }
.results-table .result-correct { color: var(--accent-green); font-weight: 700; }
.results-table .result-wrong { color: var(--accent-red); font-weight: 700; }

.results-actions {
    display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}
