/* =========================================
   EXAM PAGE STYLES - Minecraft Theme
   ========================================= */

/* Allow scrolling on exam page */
body.exam-page {
    overflow-y: auto;
    overflow-x: hidden;
}

/* ---- Panel Base ---- */
.exam-panel {
    position: relative;
    width: 90%;
    max-width: 860px;
    margin: 100px auto 40px;
    background-color: #c6c6c6;
    border: 2px solid #000;
    box-shadow:
        inset 2px 2px 0 #fff,
        inset -2px -2px 0 #555,
        4px 4px 0 #000;
    padding: 24px;
    z-index: 5;
}

.panel-title {
    margin: 0 0 20px;
    font-size: 2rem;
    color: #000;
    text-align: center;
    text-shadow: none;
    border-bottom: 2px solid #888;
    padding-bottom: 10px;
}

/* ---- Registration ---- */
.reg-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 1.3rem;
    color: #333;
    text-shadow: none;
}

.name-input {
    font-family: 'VT323', monospace;
    font-size: 1.4rem;
    padding: 10px 14px;
    background: #fff;
    color: #000;
    border: 2px solid #000;
    border-top-color: #555;
    border-left-color: #555;
    border-right-color: #fff;
    border-bottom-color: #fff;
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.15);
    outline: none;
}

.name-input:focus {
    border-color: #5b8c28;
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.15), 0 0 0 2px rgba(91, 140, 40, 0.3);
}

.name-input::placeholder {
    color: #aaa;
}

/* Camera */
.camera-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.camera-preview-wrapper {
    width: 240px;
    height: 240px;
    background: #000;
    border: 2px solid #555;
    border-top-color: #555;
    border-left-color: #555;
    border-right-color: #fff;
    border-bottom-color: #fff;
    overflow: hidden;
    position: relative;
}

.camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.captured-photo {
    position: absolute;
    top: 0;
    left: 0;
}

.camera-controls {
    display: flex;
    gap: 10px;
}

.capture-btn {
    background-color: #5b8c28 !important;
    font-size: 1.2rem;
}

.capture-btn:hover {
    background-color: #6aa830 !important;
}

.retake-btn {
    background-color: #8b8b8b !important;
    font-size: 1.1rem;
}

.start-exam-btn {
    width: 100%;
    font-size: 1.5rem;
    padding: 14px;
    margin-top: 10px;
}

/* ---- Exam Panel ---- */
#exam-panel {
    padding-bottom: 80px; /* Space for submit bar */
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #8b8b8b;
    border: 2px solid #555;
    border-bottom-color: #fff;
    border-right-color: #fff;
    padding: 8px 14px;
    margin-bottom: 20px;
}

.student-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.student-thumb {
    width: 40px;
    height: 40px;
    border: 2px solid #000;
    object-fit: cover;
    image-rendering: pixelated;
}

.student-name {
    font-size: 1.3rem;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

.exam-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.4rem;
    color: #ffaa00;
    text-shadow: 1px 1px 0 #000;
}

.timer-icon {
    font-size: 1.2rem;
}

/* Questions Container */
.exam-questions-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Knowledge Point Section */
.kp-section {
    border: 2px solid #000;
    box-shadow: 2px 2px 0 #000;
    background: rgba(0, 0, 0, 0.05);
}

.kp-header {
    background: #8b8b8b;
    border-bottom: 2px solid #555;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.kp-number {
    background: #ffaa00;
    color: #000;
    font-size: 1.1rem;
    padding: 2px 8px;
    border: 1px solid #000;
    font-weight: bold;
}

.kp-title {
    font-size: 1.4rem;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    margin: 0;
}

.kp-description {
    font-size: 1rem;
    color: #ddd;
    text-shadow: 1px 1px 0 #000;
    margin: 0;
    margin-left: auto;
}

.kp-questions {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Question Card */
.question-card {
    background: #fff;
    border: 2px solid #000;
    box-shadow:
        inset 1px 1px 0 #fff,
        inset -1px -1px 0 #ddd,
        2px 2px 0 rgba(0, 0, 0, 0.2);
    padding: 14px;
    color: #000;
}

.question-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.question-number {
    background: #000;
    color: #ffaa00;
    padding: 2px 8px;
    font-size: 1rem;
    border: 1px solid #ffaa00;
}

.question-points {
    font-size: 1rem;
    color: #555;
}

.question-sentence {
    font-size: 1.5rem;
    margin: 10px 0;
    line-height: 1.6;
    color: #000;
    text-shadow: none;
}

.question-sentence .blank {
    display: inline-block;
    min-width: 80px;
    border-bottom: 3px solid #000;
    text-align: center;
    margin: 0 4px;
    padding: 0 4px;
    color: #333;
    font-weight: bold;
}

.question-sentence .blank.answered {
    border-bottom-color: #5b8c28;
    color: #5b8c28;
}

.question-hint {
    font-size: 1.1rem;
    color: #777;
    font-style: italic;
    margin-bottom: 10px;
}

/* Option Group */
.option-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.option-btn {
    border: 2px solid #000;
    border-top-color: #fff;
    border-left-color: #fff;
    border-right-color: #555;
    border-bottom-color: #555;
    background-color: #8b8b8b;
    color: #fff;
    padding: 6px 16px;
    font-size: 1.2rem;
    cursor: pointer;
    font-family: 'VT323', monospace;
    text-shadow: 1px 1px 0 #000;
    box-shadow: 2px 2px 0 #000;
    transition: transform 0.1s, background-color 0.1s;
}

.option-btn:hover {
    background-color: #9b9b9b;
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 #000;
}

.option-btn.selected {
    background-color: #5b8c28;
    border-top-color: #555;
    border-left-color: #555;
    border-right-color: #fff;
    border-bottom-color: #fff;
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

/* Submit Bar */
.submit-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.9);
    border-top: 2px solid #555;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    gap: 16px;
}

.exam-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.exam-progress-bar-bg {
    flex: 1;
    height: 18px;
    background: #555;
    border: 2px solid #888;
    box-shadow: inset 2px 2px 0 #333;
    max-width: 400px;
}

.exam-progress-bar {
    height: 100%;
    width: 0%;
    background: #5b8c28;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
    white-space: nowrap;
}

.submit-btn {
    font-size: 1.3rem;
    padding: 10px 30px;
    white-space: nowrap;
}

/* ---- Grading Panel ---- */
.grading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 40px 20px;
}

.grading-title {
    font-size: 2rem;
    color: #000;
    text-shadow: none;
    margin: 0;
    text-align: center;
}

.grading-animation {
    display: flex;
    gap: 16px;
}

.grading-block {
    width: 40px;
    height: 40px;
    border: 2px solid #000;
    image-rendering: pixelated;
}

.grading-block.block-1 {
    background: #5b8c28;
    animation: gradingBounce 0.8s ease-in-out infinite;
}

.grading-block.block-2 {
    background: #ffaa00;
    animation: gradingBounce 0.8s ease-in-out 0.2s infinite;
}

.grading-block.block-3 {
    background: #64d4d2;
    animation: gradingBounce 0.8s ease-in-out 0.4s infinite;
}

@keyframes gradingBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.grading-bar-bg {
    width: 80%;
    max-width: 500px;
    height: 22px;
    background: #555;
    border: 2px solid #888;
    box-shadow: inset 2px 2px 0 #333;
}

.grading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #5b8c28, #6aa830);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
    transition: width 0.5s ease;
}

.grading-subtext {
    font-size: 1.2rem;
    color: #555;
    text-shadow: none;
}

/* ---- Results Panel ---- */
.results-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #888;
}

.result-photo {
    width: 80px;
    height: 80px;
    border: 3px solid #000;
    box-shadow: 2px 2px 0 #000;
    object-fit: cover;
    image-rendering: pixelated;
}

.result-name {
    margin: 0;
    font-size: 1.8rem;
    color: #000;
    text-shadow: none;
}

.result-date {
    margin: 4px 0 0;
    font-size: 1rem;
    color: #666;
    text-shadow: none;
}

/* Score Display */
.score-display {
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
}

.score-label {
    font-size: 1.4rem;
    color: #555;
    text-shadow: none;
    margin-bottom: 4px;
}

.score-number {
    font-size: 6rem;
    line-height: 1;
    color: #000;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.15);
    animation: scoreReveal 1s ease-out;
}

.score-total {
    font-size: 1.8rem;
    color: #888;
    text-shadow: none;
}

.score-display.score-pass .score-number {
    color: #5b8c28;
    text-shadow: 3px 3px 0 rgba(91, 140, 40, 0.2);
}

.score-display.score-fail .score-number {
    color: #db382c;
    text-shadow: 3px 3px 0 rgba(219, 56, 44, 0.2);
}

@keyframes scoreReveal {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    60% {
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Reward Banner */
.reward-banner {
    background: linear-gradient(135deg, #ffaa00, #fcee4b, #ffaa00);
    border: 3px solid #000;
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.5),
        4px 4px 0 #000;
    padding: 16px 20px;
    text-align: center;
    margin-bottom: 20px;
    animation: celebrationPulse 1.5s ease-in-out infinite;
}

.reward-text {
    font-size: 1.6rem;
    color: #000;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
    margin: 0;
}

@keyframes celebrationPulse {
    0%, 100% {
        box-shadow:
            inset 2px 2px 0 rgba(255, 255, 255, 0.5),
            4px 4px 0 #000;
    }
    50% {
        box-shadow:
            inset 2px 2px 0 rgba(255, 255, 255, 0.5),
            4px 4px 0 #000,
            0 0 20px rgba(255, 170, 0, 0.6);
    }
}

/* Results Breakdown */
.results-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.question-result {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    background: #fff;
}

.result-icon {
    font-size: 1.4rem;
    min-width: 28px;
    text-align: center;
    line-height: 1;
    padding-top: 2px;
}

.result-correct .result-icon {
    color: #5b8c28;
}

.result-wrong .result-icon {
    color: #db382c;
}

.result-detail {
    flex: 1;
}

.result-question-text {
    font-size: 1.1rem;
    color: #000;
    text-shadow: none;
    margin-bottom: 4px;
}

.result-answer {
    font-size: 1rem;
    color: #555;
    text-shadow: none;
}

.result-answer .correct-answer {
    color: #5b8c28;
    font-weight: bold;
}

.result-answer .wrong-answer {
    color: #db382c;
    text-decoration: line-through;
}

.result-explanation {
    font-size: 0.95rem;
    color: #777;
    text-shadow: none;
    margin-top: 4px;
    font-style: italic;
}

/* AI Feedback */
.ai-feedback {
    background: #fff3cd;
    border: 2px solid #e0a800;
    padding: 14px;
    margin-bottom: 20px;
}

.ai-feedback h3 {
    margin: 0 0 8px;
    font-size: 1.3rem;
    color: #856404;
    text-shadow: none;
}

.ai-feedback-text {
    font-size: 1.1rem;
    color: #856404;
    text-shadow: none;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Result Actions */
.results-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding-top: 16px;
    border-top: 2px solid #888;
}

.cert-download-btn {
    background: linear-gradient(180deg, #ffcc00, #ffaa00) !important;
    color: #000 !important;
    text-shadow: none !important;
    font-size: 1.3rem;
    padding: 10px 24px;
    border-top-color: #fff !important;
    border-left-color: #fff !important;
    border-right-color: #555 !important;
    border-bottom-color: #555 !important;
}

.cert-download-btn:hover {
    background: linear-gradient(180deg, #ffdd33, #ffbb33) !important;
}

.retake-exam-btn {
    background-color: #db382c !important;
    font-size: 1.3rem;
    padding: 10px 24px;
}

.retake-exam-btn:hover {
    background-color: #e55347 !important;
}

.back-practice-btn {
    text-decoration: none;
    font-size: 1.3rem;
    padding: 10px 24px;
    display: inline-block;
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 600px) {

    .exam-panel {
        width: 95%;
        margin-top: 80px;
        padding: 14px;
    }

    .panel-title {
        font-size: 1.5rem;
    }

    /* Registration */
    .camera-preview-wrapper {
        width: 180px;
        height: 180px;
    }

    .start-exam-btn {
        font-size: 1.3rem;
    }

    /* Exam */
    .exam-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .kp-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .kp-description {
        margin-left: 0;
    }

    .question-sentence {
        font-size: 1.2rem;
    }

    .option-btn {
        font-size: 1rem;
        padding: 5px 12px;
    }

    .submit-bar {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }

    .exam-progress {
        width: 100%;
    }

    .exam-progress-bar-bg {
        max-width: none;
    }

    .submit-btn {
        width: 100%;
    }

    /* Results */
    .results-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .score-number {
        font-size: 4rem;
    }

    .reward-text {
        font-size: 1.2rem;
    }

    .results-actions {
        flex-direction: column;
    }

    .retake-exam-btn,
    .back-practice-btn {
        width: 100%;
        text-align: center;
    }

    /* Header adjustments for exam (reuse grammar mobile styles) */
    header {
        position: relative;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        padding-top: 5px;
        padding-bottom: 5px;
        background: rgba(46, 46, 46, 0.95);
        z-index: 100;
    }

    .title-group {
        order: 1;
        padding: 2px 10px;
        width: 100%;
        max-width: 300px;
    }

    #main-title {
        font-size: 1.4rem;
    }

    #sub-title {
        font-size: 0.7rem;
    }

    .back-home-btn {
        position: static;
        order: 2;
        padding: 4px 8px;
        font-size: 0.9rem;
    }

    .lang-switcher {
        position: static;
        order: 3;
        gap: 5px;
    }

    .back-home-btn .text {
        display: none;
    }
}
