/**
 * Mock Exam Styles
 * Professional, mobile-first design for mock examination interface
 * @since 7.3.8
 */

/* ========================================================================
   CONTAINER AND LAYOUT
   ======================================================================== */

#nm-mock-exam-container {
    max-width: 900px;
    margin: 40px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.nm-exam-screen {
    display: none;
}

.nm-exam-screen.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================================================
   START SCREEN
   ======================================================================== */

#nm-exam-start-screen {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.nm-exam-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 40px 30px;
    text-align: center;
}

.nm-exam-header h1 {
    margin: 0 0 30px 0;
    font-size: 32px;
    font-weight: 700;
}

.nm-exam-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    max-width: 700px;
    margin: 0 auto;
}

.nm-exam-info-item {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.nm-exam-icon {
    font-size: 32px;
}

.nm-exam-info-item strong {
    display: block;
    font-size: 18px;
    margin-bottom: 4px;
}

.nm-exam-info-item p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.nm-exam-instructions {
    padding: 30px;
    background: #f9fafb;
}

.nm-exam-instructions h3 {
    margin: 0 0 20px 0;
    color: #1f2937;
    font-size: 20px;
}

.nm-exam-instructions ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nm-exam-instructions li {
    padding: 12px 0 12px 35px;
    position: relative;
    color: #4b5563;
    line-height: 1.6;
}

.nm-exam-instructions li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #10b981;
    font-weight: bold;
    font-size: 18px;
}

#nm-start-exam-btn {
    display: block;
    margin: 30px auto;
    padding: 18px 50px;
    font-size: 18px;
    font-weight: 600;
}

/* ========================================================================
   QUESTION SCREEN
   ======================================================================== */

#nm-exam-question-screen {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.nm-exam-top-bar {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nm-exam-timer {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    color: #dc2626;
}

.nm-timer-icon {
    font-size: 28px;
}

.nm-exam-progress {
    font-size: 18px;
    font-weight: 600;
    color: #6b7280;
}

/* ✅ MODIFIED v7.3.12: Responsive question wrapper with vh-based scrolling for long content */
.nm-exam-question-wrapper {
    padding: 40px 30px;
    min-height: 300px;
    max-height: calc(100vh - 280px);
    /* ✅ v7.3.12: Deduct top bar (~110px) + nav (~80px) + margins (~90px) */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.nm-exam-question {
    margin-bottom: 30px;
}

.nm-exam-question-number {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 10px;
    font-weight: 600;
}

/* ✅ MODIFIED v7.3.12: Added word wrapping for long questions */
.nm-exam-question-text {
    font-size: 20px;
    color: #1f2937;
    font-weight: 600;
    line-height: 1.6;
    margin: 0 0 30px 0;
    word-wrap: break-word;
    /* ✅ v7.3.12: Break long words */
    overflow-wrap: break-word;
    /* ✅ v7.3.12: Modern word breaking */
}

.nm-exam-options {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nm-exam-option {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.nm-exam-option:hover {
    background: #f3f4f6;
    border-color: #667eea;
}

.nm-exam-option.selected {
    background: #EEF2FF;
    border-color: #667eea;
    border-width: 2px;
}

.nm-exam-option-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #e5e7eb;
    border-radius: 50%;
    font-weight: 700;
    color: #4b5563;
    flex-shrink: 0;
}

.nm-exam-option.selected .nm-exam-option-label {
    background: #667eea;
    color: #fff;
}

.nm-exam-option-text {
    flex: 1;
    font-size: 16px;
    color: #374151;
}

.nm-exam-navigation {
    background: #f9fafb;
    border-top: 2px solid #e5e7eb;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

/* ========================================================================
   BUTTONS
   ======================================================================== */

.nm-exam-btn-primary,
.nm-exam-btn-secondary,
.nm-exam-btn-flag {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
}

.nm-exam-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.nm-exam-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.nm-exam-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.nm-exam-btn-secondary {
    background: #fff;
    color: #4b5563;
    border: 2px solid #e5e7eb;
}

.nm-exam-btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.nm-exam-btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nm-exam-btn-flag {
    background: #fff;
    color: #f59e0b;
    border: 2px solid #fbbf24;
}

.nm-exam-btn-flag:hover {
    background: #fffbeb;
}

.nm-exam-btn-flag.flagged {
    background: #fef3c7;
    border-color: #f59e0b;
}

/* ========================================================================
   RESULTS SCREEN
   ======================================================================== */

#nm-exam-results-screen {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 40px 30px;
}

.nm-exam-results-header {
    text-align: center;
    margin-bottom: 40px;
}

.nm-exam-results-header h2 {
    margin: 0 0 30px 0;
    font-size: 32px;
    color: #1f2937;
}

.nm-score-circle {
    width: 200px;
    height: 200px;
    margin: 0 auto 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.nm-score-percentage {
    font-size: 48px;
    font-weight: 700;
}

.nm-score-label {
    font-size: 16px;
    opacity: 0.9;
}

.nm-pass-status {
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    display: inline-block;
}

.nm-pass-status.pass {
    background: #d1fae5;
    color: #065f46;
}

.nm-pass-status.fail {
    background: #fee2e2;
    color: #991b1b;
}

.nm-exam-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.nm-exam-stat {
    background: #f9fafb;
    padding: 25px;
    border-radius: 8px;
    text-align: center;
}

.nm-stat-value {
    display: block;
    font-size: 36px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.nm-stat-label {
    display: block;
    font-size: 14px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nm-exam-review {
    margin-bottom: 30px;
}

.nm-exam-review h3 {
    font-size: 24px;
    margin: 0 0 20px 0;
    color: #1f2937;
}

.nm-review-item {
    background: #f9fafb;
    border-left: 4px solid #e5e7eb;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 4px;
}

.nm-review-item.correct {
    border-left-color: #10b981;
    background: #ecfdf5;
}

.nm-review-item.incorrect {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.nm-review-question {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 10px;
}

.nm-review-answer {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 5px;
}

.nm-review-answer strong {
    color: #1f2937;
}

.nm-review-explanation {
    margin-top: 10px;
    padding: 12px;
    background: #fff;
    border-radius: 4px;
    font-size: 14px;
    color: #4b5563;
    line-height: 1.6;
}

.nm-exam-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========================================================================
   MOBILE RESPONSIVE
   ======================================================================== */

@media (max-width: 768px) {
    #nm-mock-exam-container {
        margin: 20px 10px;
    }

    .nm-exam-header {
        padding: 30px 20px;
    }

    .nm-exam-header h1 {
        font-size: 24px;
    }

    .nm-exam-info {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .nm-exam-info-item {
        padding: 15px;
    }

    .nm-exam-instructions {
        padding: 20px;
    }

    .nm-exam-question-wrapper {
        padding: 25px 20px;
    }

    .nm-exam-question-text {
        font-size: 18px;
    }

    .nm-exam-navigation {
        flex-direction: column;
    }

    .nm-exam-btn-primary,
    .nm-exam-btn-secondary,
    .nm-exam-btn-flag {
        width: 100%;
    }

    .nm-score-circle {
        width: 160px;
        height: 160px;
    }

    .nm-score-percentage {
        font-size: 40px;
    }

    .nm-exam-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .nm-exam-top-bar {
        flex-direction: column;
        gap: 10px;
        padding: 15px 20px;
    }

    .nm-exam-timer {
        font-size: 20px;
    }

    .nm-exam-option {
        padding: 15px;
    }
}

/* ========================================================================
   DARK MODE SUPPORT
   ======================================================================== */

html.dark-mode #nm-mock-exam-container {
    color: #e5e7eb;
}

html.dark-mode #nm-exam-start-screen,
html.dark-mode #nm-exam-question-screen,
html.dark-mode #nm-exam-results-screen {
    background: #1f2937;
}

html.dark-mode .nm-exam-instructions {
    background: #111827;
}

html.dark-mode .nm-exam-instructions h3,
html.dark-mode .nm-exam-question-text,
html.dark-mode .nm-exam-results-header h2 {
    color: #f3f4f6;
}

html.dark-mode .nm-exam-instructions li {
    color: #d1d5db;
}

html.dark-mode .nm-exam-top-bar,
html.dark-mode .nm-exam-navigation {
    background: #111827;
    border-color: #374151;
}

html.dark-mode .nm-exam-option {
    background: #111827;
    border-color: #374151;
    color: #e5e7eb;
}

html.dark-mode .nm-exam-option:hover {
    background: #1f2937;
}

html.dark-mode .nm-exam-option.selected {
    background: #1e1b4b;
    border-color: #667eea;
}

html.dark-mode .nm-exam-stat,
html.dark-mode .nm-review-item {
    background: #111827;
}

html.dark-mode .nm-stat-value,
html.dark-mode .nm-review-question {
    color: #f3f4f6;
}

html.dark-mode .nm-review-explanation {
    background: #1f2937;
}

/* ✅ NEW v7.3.9: Fixed option text readability */
html.dark-mode .nm-exam-option-text {
    color: #e5e7eb !important;
    /* Ensure answer text is readable */
}

html.dark-mode .nm-exam-option-label {
    background: #374151;
    color: #e5e7eb;
}

html.dark-mode .nm-exam-option.selected .nm-exam-option-label {
    background: #667eea;
    color: #fff;
}

/* ✅ NEW v7.3.9: Fixed button hover states */
html.dark-mode .nm-exam-btn-secondary {
    background: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

html.dark-mode .nm-exam-btn-secondary:hover {
    background: #4b5563;
    color: #fff !important;
    /* Readable white text on hover */
    border-color: #6b7280;
}

html.dark-mode .nm-exam-btn-flag {
    background: #374151;
    color: #fbbf24;
    border-color: #f59e0b;
}

html.dark-mode .nm-exam-btn-flag:hover {
    background: #78350f;
    color: #fff !important;
    /* Readable white text on hover */
}

html.dark-mode .nm-exam-btn-flag.flagged {
    background: #78350f;
    border-color: #f59e0b;
    color: #fff;
}

/* ✅ NEW v7.3.9: Fixed review answer text */
html.dark-mode .nm-review-answer {
    color: #d1d5db !important;
}

html.dark-mode .nm-review-answer strong {
    color: #f3f4f6 !important;
}

html.dark-mode .nm-review-explanation {
    background: #1f2937;
    color: #d1d5db !important;
}

html.dark-mode .nm-exam-question-number,
html.dark-mode .nm-exam-progress,
html.dark-mode .nm-stat-label {
    color: #9ca3af;
}