:root {
    --primary-color: #c20b3e;
    --secondary-color: #4e2221;
    --bg-color: #ffffff;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --text-dark: #212529;
    --text-muted: #6c757d;
}

body {
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-dark);
}

.header-bar {
    background: var(--bg-color);
    border-bottom: 2px solid var(--border-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.test-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.timer-display {
    background: var(--light-bg);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timer-display i {
    font-size: 1rem;
}

.breadcrumb-nav {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.breadcrumb-nav a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    color: var(--primary-color);
}

.main-container {
    padding: 20px 0;
}

.question-map-column {
    transition: all 0.3s ease;
}

.question-map-column.collapsed {
    flex: 0 0 0;
    max-width: 0;
    overflow: hidden;
    padding: 0;
}

.question-column {
    transition: all 0.3s ease;
}

.question-column.expanded {
    flex: 0 0 50%;
    max-width: 50%;
}

.explanation-column {
    transition: all 0.3s ease;
}

.question-map-sidebar {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.question-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.question-map-header h5 {
    margin: 0;
    font-weight: 600;
    color: var(--text-dark);
}

.collapse-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

.expand-map-btn {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    padding: 15px 10px;
    cursor: pointer;
    z-index: 1030;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    width: 40px;
}

.expand-map-btn:hover {
    background: #a00932;
    padding-left: 15px;
}

.expand-map-btn i {
    font-size: 1.2rem;
}

.expand-map-btn span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.question-number {
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    background: var(--bg-color);
    color: var(--text-dark);
}

.question-number:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.question-number.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.question-number.answered {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.question-number.answered.correct {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.question-number.answered.incorrect {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.question-number.flagged {
    background: #ffc107;
    color: var(--text-dark);
    border-color: #ffc107;
}

.question-content-area {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    min-height: 600px;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.question-counter {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.question-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.action-btn i {
    margin-right: 5px;
}

.question-text {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 30px;
    color: var(--text-dark);
}

.question-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px 0;
}

.comprehension-text {
    background: var(--light-bg);
    padding: 20px;
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 1rem;
    line-height: 1.7;
}

.exhibit-content {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-option {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.answer-option:hover {
    border-color: var(--primary-color);
    background: rgba(194, 11, 62, 0.05);
}

.answer-option.selected {
    border-color: var(--primary-color);
    background: rgba(194, 11, 62, 0.1);
}

.answer-option.correct {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.answer-option.incorrect {
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

.option-label {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--light-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.answer-option.selected .option-label {
    background: var(--primary-color);
    color: white;
}

.answer-option.correct .option-label {
    background: #28a745;
    color: white;
}

.answer-option.incorrect .option-label {
    background: #dc3545;
    color: white;
}

.option-text {
    flex: 1;
    font-size: 1rem;
}

.explanation-panel {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.explanation-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.explanation-panel-header h5 {
    margin: 0;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 1rem;
}

.explanation-panel-header i {
    color: var(--primary-color);
}

#explanationContent {
    font-size: 0.95rem;
    line-height: 1.7;
}

.no-explanation {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.no-explanation i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.3;
}

.no-explanation p {
    margin: 0;
    font-size: 0.9rem;
}

.explanation-status {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.explanation-status.correct {
    background: #e7ffe7;
    color: #28a745;
    border: 1px solid #28a745;
}

.explanation-status.incorrect {
    background: #ffe7e7;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.explanation-answer {
    background: var(--light-bg);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 600;
}

.explanation-text {
    color: var(--text-dark);
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.nav-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-previous {
    background: var(--light-bg);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn-previous:hover {
    background: var(--secondary-color);
    color: white;
}

.btn-next {
    background: var(--primary-color);
    color: white;
}

.btn-next:hover {
    background: #a00932;
}

.btn-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-submit {
    background: #28a745;
    color: white;
    font-weight: 600;
    animation: pulse 2s infinite;
}

.btn-submit:hover {
    background: #218838;
    transform: scale(1.05);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
}

/* Calculator Styles */
.calculator-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1050;
    display: none;
}

.calculator-popup.show {
    display: block;
}

.calculator-header {
    background: var(--primary-color);
    color: white;
    padding: 12px 15px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.calculator-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}

.calculator-body {
    padding: 15px;
}

.calculator-display {
    background: var(--light-bg);
    padding: 15px;
    border-radius: 8px;
    text-align: right;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 15px;
    min-height: 50px;
    word-wrap: break-word;
}

.calculator-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.calc-btn {
    padding: 15px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.calc-btn:hover {
    background: var(--light-bg);
}

.calc-btn.operator {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.calc-btn.operator:hover {
    background: #a00932;
}

.calc-btn.equals {
    background: var(--secondary-color);
    color: white;
    grid-column: span 2;
}

.calc-btn.clear {
    background: #dc3545;
    color: white;
}

.calculator-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(194, 11, 62, 0.4);
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 1040;
    transition: all 0.2s;
}

.calculator-toggle:hover {
    background: #a00932;
    transform: scale(1.1);
}

/* Modal Styles */
.modal-header {
    background: var(--primary-color);
    color: white;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: #a00932;
    border-color: #a00932;
}

/* Notes Section */
.notes-section {
    background: #fff9e6;
    border: 1px solid #ffd700;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
}

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.notes-header h6 {
    margin: 0;
    color: var(--secondary-color);
    font-weight: 600;
}

.notes-textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    resize: vertical;
    min-height: 80px;
}

.save-note-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    margin-top: 10px;
    cursor: pointer;
}

.save-note-btn:hover {
    background: #a00932;
}

/* Responsive Design */
@media (max-width: 992px) {
    .question-map-column,
    .explanation-column {
        position: static;
        margin-bottom: 20px;
    }
    
    .question-map-sidebar,
    .explanation-panel {
        position: static;
        max-height: none;
    }
    
    .question-grid {
        grid-template-columns: repeat(10, 1fr);
    }
    
    .question-map-column.collapsed {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 0 15px;
    }
    
    .question-column.expanded {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .expand-map-btn {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .question-content-area {
        padding: 20px;
    }
    
    .question-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .expand-map-btn {
        font-size: 0.7rem;
        padding: 12px 8px;
    }
    
    .expand-map-btn i {
        font-size: 1rem;
    }
    
    .navigation-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-btn {
        width: 100%;
    }
    
    .calculator-popup {
        right: 10px;
        bottom: 10px;
        left: 10px;
    }
    
    .calculator-toggle {
        right: 15px;
        bottom: 15px;
    }
}

@media (max-width: 576px) {
    .question-actions {
        flex-wrap: wrap;
    }
    
    .action-btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-overlay.show {
    display: flex;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* Completion Overlay */
.completion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.completion-card {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.completion-header {
    text-align: center;
    padding: 40px 30px 20px;
    border-bottom: 2px solid var(--border-color);
}

.completion-header i {
    font-size: 4rem;
    margin-bottom: 15px;
}

.completion-header h2 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
}

.completion-body {
    padding: 30px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    text-align: center;
    padding: 20px 10px;
    background: var(--light-bg);
    border-radius: 12px;
    transition: transform 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-5px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.completion-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.completion-actions .btn {
    padding: 12px 30px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.completion-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .result-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .completion-actions {
        flex-direction: column;
    }
    
    .completion-actions .btn {
        width: 100%;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}
