/* Main Quiz Container */
.advanced-quiz-container {
    max-width: 1200px;
    margin: 20px auto;
    background: #f5f6f7;
    border-radius: 15px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Quiz Intro Screen */
.quiz-intro {
    padding: 40px 20px;
    text-align: center;
}

.quiz-meta {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
}

.quiz-meta-item {
    background: #f0f4ff;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.1rem;
}

.quiz-meta-item span {
    font-weight: bold;
    color: #236496;
}

.start-quiz-btn {
    padding: 15px 40px;
    background: #4a6bff;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.start-quiz-btn:hover {
    background: #3a5bff;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(74, 107, 255, 0.3);
}

.start-quiz-btn:active {
    transform: translateY(1px);
}

/* Quiz Content (initially hidden) */
.quiz-content {
    display: none;
}

/* Quiz Header */
.quiz-header {
    background: #236496;
    color: white;
    padding: 10px;
    text-align: center;
    position: relative;
}

/* Quiz Control Buttons Section - Separate from header */
.quiz-controls-wrapper {
    background: #1a4d73;
    padding: 10px 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    border-bottom: 2px solid #0f3460;
}

.quiz-controls-top {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s;
    font-size: 14px;
    white-space: nowrap;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.control-btn:active {
    transform: scale(0.95);
}

.quiz-title {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

/* Quiz Controls */
.quiz-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: #f0f4ff;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
    gap: 15px;
}

/* Category Navigation Section */
.category-navigation {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 0;
    border-top: 1px solid #ddd;
}

.category-nav-item {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    background: #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
    border: 2px solid transparent;
    font-weight: 600;
    line-height: 1.3;
}

.category-nav-item:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
}

.category-nav-item.active {
    background: #4a6bff;
    color: white;
    border-color: #3a5bff;
    box-shadow: 0 3px 6px rgba(74, 107, 255, 0.3);
}

.category-nav-item.completed {
    background: #4caf50;
    color: white;
    border-color: #45a049;
}

.category-nav-item.completed:hover {
    background: #45a049;
}

.category-nav-item.active.completed {
    background: linear-gradient(135deg, #4a6bff 0%, #4caf50 100%);
    border-color: #3a5bff;
}

.category-nav-name {
    font-size: 0.95rem;
    margin-bottom: 2px;
    display: block;
}

.category-nav-range {
    font-size: 0.8rem;
    opacity: 0.85;
    display: block;
}

.timer-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 8px 15px;
    border-radius: 30px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.timer {
    font-size: 1.2rem;
    font-weight: bold;
}

.timer.warning {
    color: #ff9800;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.progress-container {
    flex-grow: 1;
    margin: 0 20px;
}

.progress-bar {
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: #4a6bff;
    transition: width 0.3s ease;
}

.question-counter {
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

/* Quiz Body */
.quiz-body {
    display: flex;
    min-height: 500px;
}

.questions-container {
    flex: 1;
    padding: 10px;
}

.question-container {
    display: none;
}

.question-container.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

.question {
    font-size: 1.2rem;
    margin-bottom: 25px;
    font-weight: 600;
}

.options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 20px;
}

.option {
    padding: 2px 5px;
    background: #f8f9fa;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.option:hover {
    background: #e9ecef;
}

.option.selected {
    border-color: #4a6bff;
    background: #e3e8ff;
}

.option-letter {
    width: 30px;
    height: 30px;
    background: #ddd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.option.selected .option-letter {
    background: #4a6bff;
    color: white;
}

/* Navigation */
.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-top: 1px solid #eee;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 14px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 180px;
}

.btn-prev {
    background: #6c757d;
    color: white;
}

.btn-next {
    background: #4a6bff;
    color: white;
}

.btn-submit {
    background: #28a745;
    color: white;
}

.btn-bookmark {
    background: #ff9800;
    color: white;
    padding: 14px 25px;
}

.btn-bookmark.bookmarked {
    background: #f57c00;
}

.nav-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Question Navigation */
.question-navigation {
    width: 300px;
    padding: 20px;
    background: #f8f9fa;
    border-left: 1px solid #eee;
    display: flex;
    flex-direction: column;
    height: 500px;
}
.nav-title {
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.nav-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
    gap: 10px;
    overflow-y: auto;
    padding: 5px 5px 5px 5px;
}
/* Custom scrollbar for navigation */
.nav-items::-webkit-scrollbar {
    width: 8px;
}
.nav-items::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 10px;
}
.nav-items::-webkit-scrollbar-thumb {
    background: #4a6bff;
    border-radius: 10px;
}
.nav-items::-webkit-scrollbar-thumb:hover {
    background: #3a5bff;
}
.nav-item {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: #e0e0e0;
    position: relative;
}
.nav-item.answered {
    background: #4caf50;
    color: white;
}
.nav-item.unanswered {
    background: #dbdbdb;
    color: black;
}

.nav-item.bookmarked {
    background: #f57c00;
    color: white;
}
.nav-item.bookmarked::after {
    content: '🔖';
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 14px;
}
.nav-item.current {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px #4a6bff;
    z-index: 1;
}

/* Results - MODIFIED FOR FULL WIDTH */
.result-container {
    display: none;
    padding: 20px 0;
    animation: fadeIn 1s ease;
}

.score-card {
    background: white;
    padding: 30px 15px;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    text-align: center;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: conic-gradient(#4a6bff 0% 70%, #e0e0e0 70% 100%);
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-inner {
    width: 120px;
    height: 120px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
}

.score-text {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
    padding: 0 10px;
}

.stat {
    padding: 15px;
    border-radius: 8px;
    min-width: 120px;
}

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

.correct-stat {
    background: rgba(76, 175, 80, 0.1);
    color: #4caf50;
}

.incorrect-stat {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
}

.unanswered-stat {
    background: rgba(158, 158, 158, 0.1);
    color: #9e9e9e;
}

.score-stat {
    background: rgba(74, 107, 255, 0.1);
    color: #4a6bff;
}

.answers-review {
    margin-top: 20px;
    padding: 0 10px;
}

.answer-item {
    padding: 20px 15px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-radius: 0;
}

.answer-item.correct {
    border-left: 5px solid #4caf50;
}

.answer-item.incorrect {
    border-left: 5px solid #f44336;
}

.answer-item.unanswered {
    border-left: 5px solid #9e9e9e;
}

.question-text {
    font-weight: 600;
    margin-bottom: 10px;
}

.user-answer, .correct-answer {
    margin: 8px 0;
}

.correct-answer {
    color: #4caf50;
    font-weight: 600;
}

.explanation {
    margin-top: 10px;
    font-style: italic;
    color: #666;
}

.retake-btn {
    margin-top: 25px;
    padding: 12px 25px;
    width: calc(100% - 20px);
    max-width: 400px;
    background: #4a6bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    margin-left: 10px;
    margin-right: 10px;
}

.retake-btn:hover {
    background: #3a5bff;
    transform: translateY(-2px);
}

/* Question Image Styling */
.question-image {
    margin: 15px 0;
    text-align: center;
    max-width: 100%;
}

.question-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-height: 400px;
    object-fit: contain;
}

/* Responsive */
@media (max-width: 900px) {
    .quiz-body {
        flex-direction: column;
    }
    
    .question-navigation {
        width: 100%;
        border-left: none;
        border-top: 1px solid #eee;
        height: 350px;
    }
}

@media (max-width: 768px) {
    .question-image img {
        max-height: 250px;
    }
}

@media (max-width: 600px) {
    /* Reduce font sizes for mobile */
    .quiz-title {
        font-size: 1.1rem;
    }
    
    .quiz-controls-wrapper {
        padding: 8px 10px;
        gap: 8px;
    }
    
    .control-btn {
        min-width: 36px;
        height: 36px;
        font-size: 12px;
        padding: 0 8px;
    }
    
    .font-size-controls {
        padding: 4px 8px;
    }
    
    .font-size-btn {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .font-size-label {
        font-size: 10px;
        min-width: 45px;
    }
    
    .category-nav-item {
        min-width: 100%;
        padding: 6px 10px;
    }
    
    .category-nav-name {
        font-size: 0.85rem;
    }
    
    .category-nav-range {
        font-size: 0.75rem;
    }
    
    .question {
        font-size: 1rem;
    }
    
    .option {
        font-size: 0.9rem;
        padding: 8px 10px;
    }
    
    .option-letter {
        width: 25px;
        height: 25px;
        font-size: 0.85rem;
    }
    
    .timer {
        font-size: 1rem;
    }
    
    .question-counter {
        font-size: 0.9rem;
        min-width: 100px;
    }
    
    .quiz-meta-item {
        font-size: 0.9rem;
        padding: 10px 15px;
    }
    
    .start-quiz-btn {
        font-size: 1rem;
        padding: 12px 30px;
    }
    
    /* Fix navigation buttons for mobile */
    .navigation {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .nav-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
        min-width: 120px;
        flex: 1 1 45%;
    }
    
    .btn-bookmark {
        padding: 10px 15px;
        flex: 1 1 45%;
    }
    
    .btn-submit {
        flex: 1 1 100%;
    }
    
    .quiz-controls {
        flex-direction: column;
        gap: 15px;
        padding: 10px 15px;
    }
    
    .progress-container {
        width: 100%;
        margin: 10px 0;
    }
    
    .questions-container {
        padding: 15px;
    }
    
    .stats {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        padding: 0 10px;
    }
    
    .stat {
        width: 100%;
        max-width: 300px;
    }
    
    .quiz-meta {
        flex-direction: column;
        gap: 15px;
    }
    
    .score-text {
        font-size: 1.2rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .answer-item {
        padding: 15px 10px;
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .category-table {
        font-size: 0.85rem;
    }
    
    .category-table th,
    .category-table td {
        padding: 8px 6px;
    }
    
    .score-card {
        padding: 20px 10px;
    }
}

/* Dark Mode Styles */
.advanced-quiz-container.dark-mode {
    background: #1a1a2e;
    color: #eee;
}

.dark-mode .quiz-header {
    background: #0f3460;
}

.dark-mode .quiz-controls-wrapper {
    background: #0a2647;
    border-bottom-color: #051729;
}

.dark-mode .category-nav-item {
    background: #0f3460;
    color: #eee;
    border-color: #0a2647;
}

.dark-mode .category-nav-item:hover {
    background: #1a4d73;
}

.dark-mode .category-nav-item.active {
    background: #4a6bff;
    color: white;
    border-color: #3a5bff;
}

.dark-mode .category-nav-item.completed {
    background: #4caf50;
    color: white;
    border-color: #45a049;
}

.dark-mode .category-nav-item.active.completed {
    background: linear-gradient(135deg, #4a6bff 0%, #4caf50 100%);
}

.dark-mode .quiz-controls {
    background: #16213e;
    border-bottom-color: #0f3460;
}

.dark-mode .timer-container {
    background: #0f3460;
    color: #eee;
}

.dark-mode .progress-bar {
    background: #0f3460;
}

.dark-mode .question-navigation {
    background: #16213e;
    border-left-color: #0f3460;
}

.dark-mode .nav-item {
    background: #0f3460;
    color: #eee;
}

.dark-mode .nav-item.answered {
    background: #2d6a4f;
}

.dark-mode .nav-item.unanswered {
    background: #374151;
}

.dark-mode .nav-item.bookmarked {
    background: #d97706;
}

.dark-mode .questions-container {
    background: #1a1a2e;
}

.dark-mode .option {
    background: #16213e;
    border-color: #0f3460;
    color: #eee;
}

.dark-mode .option:hover {
    background: #0f3460;
}

.dark-mode .option.selected {
    background: #1e3a8a;
    border-color: #4a6bff;
}

.dark-mode .option-letter {
    background: #0f3460;
    color: #eee;
}

.dark-mode .option.selected .option-letter {
    background: #4a6bff;
}

.dark-mode .navigation {
    border-top-color: #0f3460;
}

.dark-mode .score-card {
    background: #16213e;
    color: #eee;
}

.dark-mode .score-inner {
    background: #16213e;
}

.dark-mode .answer-item {
    background: #16213e;
}

.dark-mode .quiz-intro {
    background: #1a1a2e;
    color: #eee;
}

.dark-mode .quiz-meta-item {
    background: #16213e;
    color: #eee;
}

.dark-mode .quiz-meta-item span {
    color: #60a5fa;
}

.dark-mode .category-results {
    background: #16213e;
}

.dark-mode .category-results h3 {
    color: #60a5fa;
}

.dark-mode .category-table th {
    background: #0f3460;
    border-color: #0a2647;
}

.dark-mode .category-table td {
    background: #1a1a2e;
    border-color: #0f3460;
    color: #eee;
}

.dark-mode .category-table tr:nth-child(even) td {
    background: #16213e;
}

.dark-mode .category-table tr:hover td {
    background: #0f3460;
}

.dark-mode .category-name {
    color: #60a5fa;
}

.dark-mode .category-legend {
    background: #0f3460;
}

.dark-mode .category-badge {
    background: #16213e;
    border-color: #60a5fa;
    color: #eee;
}

/* Fullscreen Mode */
.advanced-quiz-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    margin: 0;
    border-radius: 0;
    z-index: 9999;
    overflow-y: auto;
}

.fullscreen .quiz-body {
    min-height: calc(100vh - 150px);
}

/* Category/Subject Results Table */
.category-results {
    margin: 20px 0 0 0;
    background: white;
    padding: 20px 10px;
    border-radius: 0;
    box-shadow: none;
}

.category-results h3 {
    margin-bottom: 20px;
    color: #236496;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 5px;
}

.category-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    overflow-x: auto;
    display: block;
}

.category-table table {
    width: 100%;
    min-width: 600px;
}

.category-table th {
    background: #236496;
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    border: 1px solid #1a4d73;
}

.category-table td {
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.category-table tr:nth-child(even) td {
    background: #ffffff;
}

.category-table tr:hover td {
    background: #f0f4ff;
}

.category-name {
    font-weight: 600;
    color: #236496;
}

.category-accuracy {
    font-weight: 600;
}

.accuracy-high {
    color: #4caf50;
}

.accuracy-medium {
    color: #ff9800;
}

.accuracy-low {
    color: #f44336;
}

.category-score {
    font-weight: 600;
    color: #4a6bff;
}

/* Category badge in question navigation */
.nav-item-category {
    font-size: 0.65rem;
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    background: #4a6bff;
    color: white;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    max-width: 38px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    padding: 15px 10px;
    background: #f0f4ff;
    border-radius: 0;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: white;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 2px solid #236496;
}

.category-badge-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Font Size Controls */
.font-size-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 20px;
}

.font-size-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: bold;
}

.font-size-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.font-size-label {
    font-size: 12px;
    min-width: 60px;
    text-align: center;
}

/* Font Size Variations */
.advanced-quiz-container.font-small .question {
    font-size: 1rem;
}

.advanced-quiz-container.font-small .option {
    font-size: 0.85rem;
}

.advanced-quiz-container.font-large .question {
    font-size: 1.4rem;
}

.advanced-quiz-container.font-large .option {
    font-size: 1.1rem;
}

.advanced-quiz-container.font-xlarge .question {
    font-size: 1.6rem;
}

.advanced-quiz-container.font-xlarge .option {
    font-size: 1.3rem;
}