/* quiz_style.css */

/* ... (ใช้ CSS เดิมส่วน Layout ได้เลย) ... */

/* เพิ่มเติมสำหรับ Solution Mode */
.choice-item.correct-answer {
    background-color: #dcfce7; /* สีเขียวอ่อน */
    border-color: #22c55e;
    color: #15803d;
    font-weight: 600;
}

.choice-item.wrong-selected {
    background-color: #fee2e2; /* สีแดงอ่อน */
    border-color: #ef4444;
    color: #b91c1c;
    opacity: 0.8;
}

.choice-item.disabled {
    pointer-events: none;
    cursor: default;
}

/* กล่องเฉลยเหตุผล */
.solution-box {
    margin-top: 20px;
    padding: 20px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    color: #0369a1;
    animation: fadeIn 0.5s ease;
}

.solution-box h4 {
    margin-top: 0;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Grid Legend เพิ่มเติม */
.dot.wrong { background: #ef4444; }
.dot.correct { background: #22c55e; }

/* Nav Grid ช่วงเฉลย */
.grid-item.is-correct { background: #22c55e; color: white; border-color: #22c55e; }
.grid-item.is-wrong { background: #ef4444; color: white; border-color: #ef4444; }

/* ซ่อน/แสดง */
.hidden { display: none !important; }

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

/* ... (CSS เดิมส่วนอื่นๆ คงไว้) ... */
/* นำ CSS จากครั้งที่แล้วมาต่อท้าย หรือใช้ไฟล์เดิมแล้วเพิ่มส่วนนี้เข้าไป */
/* Layout ปรับแต่ง */
.quiz-wrapper {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.quiz-container {
    flex: 3;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    min-height: 400px;
    position: relative;
}

.quiz-sidebar {
    flex: 1;
    min-width: 250px;
}

/* Header & Timer */
.quiz-header {
    background: white;
    padding: 15px 30px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

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

.timer-box {
    background: #1e293b;
    color: #fff;
    padding: 8px 16px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-box.warning {
    background: #ef4444;
    animation: pulse 1s infinite;
}

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

/* Progress Bar */
.progress-bar-container {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease;
}

/* Question Area */
.question-scenario {
    background: #f8fafc;
    padding: 15px;
    border-left: 4px solid #64748b;
    margin-bottom: 20px;
    font-style: italic;
    color: #475569;
}

.question-text {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 25px;
    color: #1e293b;
}

.choices-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice-item {
    padding: 15px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.choice-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.choice-item.selected {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.choice-item input[type="radio"] {
    accent-color: #3b82f6;
    transform: scale(1.2);
}

/* Controls */
.quiz-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

button {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }

.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-warning.active { background: #b45309; box-shadow: inset 0 3px 5px rgba(0,0,0,0.2); }

.btn-success { background: #22c55e; color: white; }
.btn-success:hover { background: #16a34a; }

/* Navigation Grid */
.nav-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.grid-item {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
    background: #f1f5f9;
    cursor: pointer;
    font-weight: 600;
    color: #64748b;
    border: 2px solid transparent;
}

.grid-item:hover { background: #e2e8f0; }
.grid-item.current { border-color: #3b82f6; color: #3b82f6; }
.grid-item.answered { background: #3b82f6; color: white; }
.grid-item.flagged { background: #f59e0b; color: white; position: relative; }
.grid-item.flagged::after {
    content: '\f024';
    font-family: "Font Awesome 6 Free";
    font-weight: 400;
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
}

.grid-legend {
    font-size: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: #64748b;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    background: #e2e8f0;
    margin-right: 4px;
}
.dot.current { border: 2px solid #3b82f6; background: transparent; }
.dot.answered { background: #3b82f6; }
.dot.flagged { background: #f59e0b; }

/* Modal */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
}

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

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.review-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
}
.review-item:last-child { border-bottom: none; }
.review-item span.label { font-weight: 600; color: #64748b; }
.review-item span.status.done { color: #22c55e; }
.review-item span.status.miss { color: #ef4444; font-weight: bold; }
.review-item span.status.flag { color: #f59e0b; }

/* Result Styles */
.result-content { text-align: center; padding: 40px; }
.result-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}
.score-box {
    font-size: 3rem;
    font-weight: 800;
    color: #3b82f6;
    margin: 20px 0;
}

@media (max-width: 768px) {
    .quiz-wrapper { flex-direction: column; }
    .quiz-sidebar { width: 100%; order: -1; }
    .question-grid { grid-template-columns: repeat(10, 1fr); }
}