:root {
    --bg-dark: #1e1e1e;
    --bg-panel: #2d2d2d;
    --text-light: #e0e0e0;
    --accent: #0078d7;
    --accent-hover: #106ebe;
    --success: #107c10;
    --warning: #d83b01;
    --score-5: #107c10;
    --score-4: #4caf50;
    --score-3: #ffeb3b;
    --score-2: #ff9800;
    --score-1: #f44336;
    --topic-btn-bg: #e69500;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body,
html {
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden;
}

.simulation-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    background: #000;
}

/* Header */
.app-header {
    height: 45px;
    background: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    border-bottom: 2px solid #444;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo-box {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    font-weight: bold;
    border-radius: 3px;
    font-size: 0.85rem;
    margin-right: 15px;
}

.exam-info {
    font-size: 0.9rem;
    color: #ccc;
}

.exam-info .value {
    color: white;
    font-weight: bold;
    margin-right: 10px;
}

.separator {
    margin: 0 8px;
    color: #555;
}

.header-right {
    display: flex;
    align-items: center;
}

.timer-box {
    font-weight: bold;
    background: #444;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.score-preview {
    font-size: 0.9rem;
    font-weight: bold;
    margin-left: 15px;
}

/* Body Layout */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* LEFT: Main Content (Video) */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: black;
    border-right: 1px solid #333;
    position: relative;
}

.main-stage {
    flex: 1;
    position: relative;
    background: black;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    cursor: pointer;
}

.overlay-content {
    text-align: center;
    color: white;
}

.flag-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    animation: popIn 0.3s;
    z-index: 5;
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.score-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    font-weight: bold;
    color: var(--score-5);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    opacity: 0;
    animation: scoreFade 2s forwards;
    z-index: 20;
}

@keyframes scoreFade {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -60%) scale(1);
    }
}

/* Timeline */
.timeline-bar {
    height: 16px;
    background: #222;
    position: relative;
    width: 100%;
    margin-top: auto;
}

.progress-track {
    width: 100%;
    height: 100%;
    background: #333;
    position: relative;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
}

.score-zones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.zone {
    position: absolute;
    top: 0;
    height: 100%;
    opacity: 0.7;
}

.timeline-flag {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 24px;
    background: white;
    z-index: 10;
    display: none;
}

.timeline-flag i {
    position: absolute;
    top: -14px;
    left: -6px;
    color: red;
    font-size: 12px;
}

/* Info Panel (Bottom) */
.info-panel {
    background: #fff;
    color: #333;
    padding: 12px 15px;
    border-top: 1px solid #ccc;
    min-height: 100px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.situation-info {
    font-weight: bold;
    font-size: 1.1rem;
    color: #333;
    text-transform: uppercase;
}

.status-info {
    display: flex;
    gap: 30px;
    font-size: 1rem;
}

.st-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.extra-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.note-text {
    font-size: 0.9rem;
    color: #666;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 6px 12px;
    border: 1px solid #ccc;
    background: white;
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.btn-sm:hover {
    background: #e0e0e0;
}

.btn-hd {
    background: #0078d7;
    color: white;
    border: none;
}

.btn-hd:hover {
    background: #0060ac;
}

.btn-hint {
    background: #17a2b8;
    color: white;
    border: none;
}

.btn-hint:hover {
    background: #138496;
}

/* RIGHT: Sidebar */
.sidebar {
    width: 380px;
    background: #fff;
    color: #333;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #ccc;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
}

.sidebar-section {
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
}

.sidebar-section.grid-section {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Grid scrolls */
.section-header {
    background: #f8f9fa;
    padding: 10px 15px;
    font-weight: bold;
    font-size: 0.95rem;
    color: #444;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    gap: 8px;
}

.questions-grid-container {
    padding: 10px;
    padding-right: 5px;
    /* space for scrollbar */
}

.chapter-group {
    margin-bottom: 20px;
}

.chapter-title {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 8px;
    color: #0078d7;
    cursor: default;
}

.q-grid-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.q-node {
    width: 32px;
    height: 32px;
    background: #e9ecef;
    border: 1px solid #ced4da;
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 3px;
    cursor: pointer;
    color: #495057;
    transition: all 0.1s;
}

.q-node:hover {
    background: #dee2e6;
    border-color: #adb5bd;
}

.q-node.active {
    background: #0078d7;
    color: white;
    border-color: #0078d7;
    font-weight: bold;
    transform: scale(1.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.q-node.done.score-5 {
    background: var(--score-5);
    color: white;
    border-color: var(--score-5);
}

.q-node.done.score-4 {
    background: var(--score-4);
    color: white;
    border-color: var(--score-4);
}

.q-node.done.score-3 {
    background: var(--score-3);
    color: white;
    border-color: var(--score-3);
}

.q-node.done.score-2 {
    background: var(--score-2);
    color: white;
    border-color: var(--score-2);
}

.q-node.done.score-1 {
    background: var(--score-1);
    color: white;
    border-color: var(--score-1);
}

.q-node.done.score-0 {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

/* Settings */
.section-label {
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 8px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.delay-options {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.btn-delay {
    flex: 1;
    padding: 6px 0;
    border: 1px solid #ced4da;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    border-radius: 3px;
    color: #495057;
    transition: 0.2s;
}

.btn-delay:hover {
    background: #e9ecef;
}

.btn-delay.active {
    background: #fd7e14;
    color: white;
    border-color: #fd7e14;
}

.control-row {
    display: flex;
    gap: 10px;
}

.nav-controls {
    display: flex;
    gap: 5px;
}

.btn-nav {
    width: 40px;
    height: 36px;
    background: #0078d7;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s;
}

.btn-nav:hover {
    background: #0060ac;
}

.btn-expand {
    flex: 1;
    height: 36px;
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: 0.2s;
}

.btn-expand:hover {
    background: #138496;
}

/* Topics */
.topic-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-topic {
    padding: 8px 10px;
    background: #FFC107;
    /* Yellow/Orange */
    color: #212529;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    flex: 1 1 30%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    transition: 0.2s;
}

.btn-topic:hover {
    filter: brightness(0.95);
}

.btn-topic.active {
    background: #d39e00;
    color: white;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-topic[data-score-diff="hard"] {
    flex: 1 1 100%;
}

/* Full width for score bars? or 3 cols */

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    width: 400px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   ADAPTER FOR thi-thu-mo-phong.html (Local 3-Column Layout)
   ========================================================================== */

.sim-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    height: 600px;
    /* Fixed height for simulator area */
    gap: 15px;
    padding: 10px;
    background: #e2e8f0;
}

/* LEFT COLUMN */
.sim-col-left {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sim-info-box {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.box-header {
    background: #0284c7;
    color: white;
    padding: 10px;
    font-weight: bold;
    font-size: 0.95rem;
}

.box-content {
    padding: 10px;
    font-size: 0.9rem;
    color: #334155;
    line-height: 1.5;
}

.info-line {
    margin-bottom: 5px;
}

/* CENTER COLUMN (VIDEO) */
.sim-col-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: black;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
}

.video-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

.sim-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

.sim-controls-bar {
    height: 20px;
    background: #333;
    position: relative;
}

.progress-track {
    width: 100%;
    height: 100%;
    background: #475569;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: #0284c7;
    width: 0%;
}

.flag-marker {
    position: absolute;
    top: -5px;
    width: 2px;
    height: 30px;
    background: red;
    z-index: 10;
    display: none;
}

.user-flag-alert {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    padding: 5px 15px;
    border-radius: 4px;
    font-weight: bold;
    display: none;
    z-index: 60;
}

/* RIGHT COLUMN (RESULTS) */
.sim-col-right {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: white;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.result-box-header {
    background: #f1f5f9;
    padding: 10px;
    font-weight: bold;
    color: #334155;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

.result-summary {
    padding: 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.res-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.res-val {
    font-weight: bold;
    color: #0f172a;
}

.q-table-wrapper {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
}

.q-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.q-table th {
    background: #e2e8f0;
    padding: 6px;
    text-align: center;
    position: sticky;
    top: 0;
}

.q-table td {
    border-bottom: 1px solid #f1f5f9;
    padding: 6px;
    text-align: center;
    cursor: pointer;
}

.q-table tr:hover {
    background: #f8fafc;
}

.q-table tr.active-row {
    background: #bae6fd !important;
}

/* Set Selector */
.set-selector {
    padding: 5px 0;
    border-top: 1px solid #e2e8f0;
}

.set-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-top: 5px;
}

.btn-set {
    padding: 4px;
    font-size: 0.8rem;
    border: 1px solid #cbd5e1;
    background: white;
    cursor: pointer;
}

.btn-set.active {
    background: #0284c7;
    color: white;
    border-color: #0284c7;
}

.btn-set.random-set {
    width: 100%;
    margin-bottom: 5px;
    background: #eab308;
    color: black;
    border: none;
    font-weight: bold;
}

.btn-set.random-set.active {
    background: #ca8a04;
    color: white;
}

/* Delay Controls */
.delay-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    margin-top: 5px;
}

.delay-opts button {
    padding: 2px 6px;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    background: white;
}

.delay-opts button.active {
    background: #64748b;
    color: white;
    border-color: #64748b;
}

#btnStart {
    width: 100%;
    padding: 10px;
    background: #0284c7;
    color: white;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 5px;
}

#btnStart:hover {
    background: #0369a1;
}

/* 
   PRO VERSION ENHANCEMENTS 
   ========================
*/

/* Dynamic Score Zones Container */
.score-zones-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.zone-bar {
    position: absolute;
    top: 0;
    height: 100%;
    opacity: 0.6;
}

.zone-bar:hover {
    opacity: 0.9;
}

/* Flag Animation */
.user-flag-alert {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.score-popup {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 2px 2px 0 #000;
}

.score-popup.animate-score {
    animation: scoreBounce 0.6s forwards;
}

@keyframes scoreBounce {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.4);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -100%) scale(1);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Active Row Highlight Pulse */
.active-row {
    background-color: #bae6fd !important;
    border-left: 4px solid #0284c7;
}

.row-done {
    background-color: #f0fdf4;
}

/* Review Mode Tag */
.review-tag {
    background: #e0f2fe;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 5px;
}

/* LOGIN MODAL */
.login-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-modal {
    background: white;
    width: 600px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.login-header {
    background: #e2e8f0;
    padding: 15px 20px;
    border-bottom: 1px solid #cbd5e1;
    text-align: center;
}

.login-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #334155;
}

.login-body {
    padding: 30px 40px;
}

.form-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.form-group label {
    width: 120px;
    font-weight: bold;
    color: #475569;
}

.form-group select,
.form-group input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 1rem;
}

.login-notes {
    background: #f8fafc;
    padding: 10px;
    margin: 20px 0;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.6;
}

.btn-enter {
    width: 100%;
    padding: 12px;
    background: #f59e0b;
    /* Orange */
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-enter:hover {
    background: #d97706;
}

/* EMERGENCY FIX FOR LAYOUT & MODAL */
.sim-container {
    display: flex !important;
    flex-direction: row !important;
    max-width: 1400px;
    margin: 0 auto;
    height: 600px;
    gap: 15px;
    padding: 10px;
    background: #e2e8f0;
}

.sim-col-left {
    width: 280px !important;
    display: flex !important;
    flex-direction: column !important;
}

.sim-col-center {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    background: black !important;
    position: relative !important;
    overflow: hidden !important;
    height: 100% !important;
}

.sim-col-right {
    width: 320px !important;
    display: flex !important;
    flex-direction: column !important;
}

.login-modal-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999 !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
}

.login-modal {
    background: white;
    width: 600px;
    border-radius: 8px;
    z-index: 10000 !important;
}