/* ============================================
   ZimLearn - Quiz & Exam Styles
   ============================================ */

/* ============================================
   Quiz Header
   ============================================ */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: 0 2px 8px var(--shadow);
}

.quiz-counter {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}

.quiz-timer {
    font-size: 16px;
    font-weight: 800;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
}

.quiz-timer.warning {
    color: var(--danger);
    animation: pulse 1s infinite;
}

.quiz-progress {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-alt));
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ============================================
   Question Card
   ============================================ */
.question-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 4px 20px var(--shadow-md);
    animation: slideUp 0.4s ease;
}

.question-number {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Question Image */
.question-image {
    text-align: center;
    margin-bottom: 16px;
}

.question-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 2px 12px var(--shadow);
    object-fit: contain;
}

.question-image-preview {
    margin-bottom: 8px;
    text-align: center;
}

.question-image-preview img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    margin-bottom: 8px;
    object-fit: contain;
}

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

.question-text {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 20px;
    color: var(--text);
}

.question-difficulty {
    display: flex;
    gap: 3px;
    margin-bottom: 8px;
}

.question-difficulty .star {
    font-size: 12px;
    color: var(--border);
}

.question-difficulty .star.filled {
    color: var(--warning);
}

/* ============================================
   Answer Options
   ============================================ */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    min-height: 52px;
    width: 100%;
}

.option-btn:active {
    transform: scale(0.98);
}

.option-label {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-light);
    flex-shrink: 0;
    border: 2px solid var(--border);
    transition: all 0.2s;
}

.option-text {
    flex: 1;
    font-weight: 500;
}

/* Selected state */
.option-btn.selected {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.08);
}

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

/* Correct answer */
.option-btn.correct {
    border-color: var(--success);
    background: rgba(46, 204, 113, 0.1);
    animation: bounceIn 0.4s ease;
}

.option-btn.correct .option-label {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* Wrong answer */
.option-btn.wrong {
    border-color: var(--danger);
    background: rgba(231, 76, 60, 0.1);
    animation: shake 0.5s ease;
}

.option-btn.wrong .option-label {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Disabled after answering */
.option-btn.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.option-btn.correct.disabled,
.option-btn.wrong.disabled {
    opacity: 1;
}

/* ============================================
   Explanation Box
   ============================================ */
.explanation-box {
    margin-top: 16px;
    padding: 14px 16px;
    background: rgba(108, 99, 255, 0.06);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-light);
    animation: fadeIn 0.3s ease;
}

.explanation-box strong {
    color: var(--primary);
}

.ref-toggle {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 12px;
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}
.ref-toggle::before { content: '\25B6 '; font-size: 9px; }
.ref-toggle.open::before { content: '\25BC '; }

.ref-content {
    margin-top: 8px;
    padding: 10px 12px;
    background: rgba(39, 174, 96, 0.06);
    border-left: 3px solid #27ae60;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-light);
    animation: fadeIn 0.2s ease;
}

/* ============================================
   Quiz Actions
   ============================================ */
.quiz-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.quiz-actions .btn {
    flex: 1;
}

/* ============================================
   Results Page
   ============================================ */
.results-card {
    text-align: center;
    padding: 24px 20px;
}

.results-score {
    font-size: 56px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 4px;
}

.results-total {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.results-grade {
    display: inline-block;
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 16px;
}

.results-grade.excellent {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
}

.results-grade.good {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary);
}

.results-grade.fair {
    background: rgba(241, 196, 15, 0.15);
    color: #D4AC0D;
}

.results-grade.poor {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0;
}

.results-stat {
    text-align: center;
}

.results-stat .value {
    font-size: 20px;
    font-weight: 700;
}

.results-stat .label {
    font-size: 11px;
    color: var(--text-light);
}

/* ============================================
   True/False Buttons
   ============================================ */
.tf-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tf-btn {
    padding: 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-family: inherit;
}

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

.tf-btn.selected { border-color: var(--primary); background: rgba(108,99,255,0.08); }
.tf-btn.correct { border-color: var(--success); background: rgba(46,204,113,0.1); color: var(--success); }
.tf-btn.wrong { border-color: var(--danger); background: rgba(231,76,60,0.1); color: var(--danger); animation: shake 0.5s; }

/* ============================================
   Fill-in-the-blank
   ============================================ */
.fillin-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: inherit;
    text-align: center;
    transition: border-color 0.2s;
}

.fillin-input:focus {
    outline: none;
    border-color: var(--primary);
}

.fillin-input.correct {
    border-color: var(--success);
    background: rgba(46,204,113,0.05);
}

.fillin-input.wrong {
    border-color: var(--danger);
    background: rgba(231,76,60,0.05);
}

/* ============================================
   Subject Mode Selection
   ============================================ */
.mode-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 16px;
}

.mode-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 12px var(--shadow);
    border: 2px solid transparent;
    text-decoration: none;
    color: var(--text);
}

.mode-card:active {
    transform: scale(0.98);
}

.mode-card .mode-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.mode-card .mode-info h4 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 2px;
}

.mode-card .mode-info p {
    font-size: 12px;
    color: var(--text-light);
}

/* ============================================
   Exam Mode Specifics
   ============================================ */
.exam-info-card {
    background: linear-gradient(135deg, var(--accent) 0%, #FF8E8E 100%);
    border-radius: var(--radius);
    padding: 20px;
    color: white;
    text-align: center;
    margin-bottom: 20px;
}

.exam-info-card h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.exam-info-card .exam-meta {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 16px;
}

.exam-info-card .exam-details {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 16px;
}

.exam-info-card .exam-detail {
    text-align: center;
}

.exam-info-card .exam-detail .value {
    font-size: 24px;
    font-weight: 800;
}

.exam-info-card .exam-detail .label {
    font-size: 11px;
    opacity: 0.85;
}

/* Timer for exam mode */
.exam-timer-bar {
    position: sticky;
    top: 0;
    background: var(--surface);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 50;
    border-bottom: 1px solid var(--border);
}

.exam-timer-bar .timer-text {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    min-width: 70px;
}

.exam-timer-bar .timer-text.critical {
    color: var(--danger);
    animation: pulse 1s infinite;
}

.exam-timer-bar .timer-progress {
    flex: 1;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.exam-timer-bar .timer-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 1s linear;
}

.exam-timer-bar .timer-fill.critical {
    background: var(--danger);
}

/* ============================================
   Exam Review Mode — suppress animations
   ============================================ */
.exam-review .option-btn.correct,
.exam-review .option-btn.wrong,
.exam-review .tf-btn.correct,
.exam-review .tf-btn.wrong {
    animation: none;
}

.exam-review .question-card {
    animation: none;
}

/* ============================================
   Tablet Portrait (768px+)
   ============================================ */
@media (min-width: 768px) {
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .question-card {
        padding: 28px;
    }

    .question-text {
        font-size: 19px;
    }

    .question-image img {
        max-height: 380px;
    }

    .options-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .option-btn {
        padding: 16px;
        font-size: 15px;
    }

    .explanation-box {
        padding: 18px 20px;
        font-size: 15px;
    }

    .exam-info-card {
        padding: 28px;
    }

    .exam-info-card h2 {
        font-size: 24px;
    }

    .exam-info-card .exam-detail .value {
        font-size: 28px;
    }

    .results-card {
        padding: 32px 24px;
    }

    .results-score {
        font-size: 64px;
    }

    .results-total {
        font-size: 18px;
    }

    .results-stat .value {
        font-size: 24px;
    }

    .flashcard {
        min-height: 280px;
    }

    .flashcard-front .question-text {
        font-size: 20px;
    }

    .flashcard-back .answer-text {
        font-size: 22px;
    }

    .quest-subject-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   Tablet Landscape (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    .question-card {
        padding: 32px;
    }

    .question-text {
        font-size: 20px;
    }

    .flashcard {
        min-height: 320px;
    }

    .flashcard-front .question-text {
        font-size: 22px;
    }

    .quest-subject-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
