/* --- Cài đặt chung & Font chữ --- */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --secondary-hover: #5a6268;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --info-color: #17a2b8;
    --info-hover: #138496;
    --ai-color: #6f42c1; /* Màu tím cho nút AI */
    --ai-hover: #5a32a3;
    --success-bg: #d4edda;
    --error-bg: #f8d7da;
    --light-border: #dee2e6;
    --background-color: #f8f9fa;
    --text-color: #212529;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --border-radius: 8px;
}

body {
    font-family: 'Lexend', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    gap: 20px;
    min-height: 100vh;
}

/* --- Bố cục chính --- */
.quiz-container {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 24px;
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
}

.history-panel {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 24px;
	width: 100%;
    max-width: 450px;
}


/* --- Header & Tiêu đề --- */
.quiz-header {
    border-bottom: 1px solid var(--light-border);
    padding-bottom: 16px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

h1 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

h2, h3 {
    color: var(--primary-color);
    margin-top: 0;
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

#question-text {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* --- Khu vực chọn từ (Word Bank) --- */
.word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px;
    background-color: #f1f3f5;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.word {
    padding: 8px 16px;
    background-color: var(--card-bg);
    border: 1px solid var(--light-border);
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    font-weight: 500;
}

.word:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* --- Khu vực trả lời --- */
.answer-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.drop-area {
    border: 2px dashed var(--light-border);
    padding: 15px;
    min-height: 50px;
    border-radius: var(--border-radius);
    transition: border-color 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.drop-area.selected-area {
    border-color: var(--primary-color);
    background-color: #e9ecef;
}

/* --- Nút bấm --- */
.quiz-footer {
    margin-top: 24px;
    border-top: 1px solid var(--light-border);
    padding-top: 20px;
}

#controls {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); box-shadow: 0 2px 8px rgba(0, 123, 255, 0.4); }
.btn-secondary { background-color: var(--secondary-color); color: white; }
.btn-secondary:hover { background-color: var(--secondary-hover); }
.btn-info { background-color: var(--info-color); color: white; }
.btn-info:hover { background-color: var(--info-hover); }
.btn-ai { background-color: var(--ai-color); color: white; }
.btn-ai:hover { background-color: var(--ai-hover); }

/* --- Nút AI trong danh sách lịch sử --- */
.btn-inline {
    padding: 5px 10px;
    font-size: 0.8rem;
    margin-top: 8px;
}


/* --- Phản hồi từ Gemini --- */
.feedback-panel {
    margin-top: 20px;
    padding: 15px;
    background-color: #f1f3f5;
    border-left: 5px solid var(--ai-color);
    border-radius: var(--border-radius);
    line-height: 1.6;
}

.gemini-result-container {
    margin-top: 10px;
    padding: 12px;
    background-color: #f1f3f5;
    border-left: 4px solid var(--ai-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* --- Lịch sử & Thống kê --- */
.current-session-container ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
     overflow-y: auto;
    border: 1px solid var(--light-border);
    border-radius: var(--border-radius);
}
.current-session-container li {
    padding: 12px;
    border-bottom: 1px solid var(--light-border);
    font-size: 0.95rem;
    line-height: 1.5;
}
.current-session-container li:last-child {
    border-bottom: none;
}
#stats-table, #stats-table-progress {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
#stats-table th, #stats-table td,
#stats-table-progress th, #stats-table-progress td {
    border: 1px solid var(--light-border);
    padding: 8px 12px;
    text-align: left;
    font-size: 0.9rem;
    vertical-align: middle;
}
#stats-table th, #stats-table-progress th {
    background-color: #f1f3f5;
}
#stats-table tfoot td {
    font-weight: bold;
    background-color: #f8f9fa;
}


/* --- CSS CHO BIỂU ĐỒ --- */
.stats-chart-container {
    margin-top: 25px;
    border-top: 1px solid var(--light-border);
    padding-top: 20px;
}

#chart-wrapper {
    position: relative;
    height: 250px;
    width: 100%;
}

/* --- THANH TRẠNG THÁI (PROGRESS BAR) --- */
.progress-bar-container {
    width: 100%;
    background-color: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.progress-bar {
    height: 22px;
    line-height: 22px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    border-radius: 5px;
    white-space: nowrap;
    transition: width 0.6s ease;
    min-width: 28px;
}

.progress-bar.high { background-color: #28a745; }
.progress-bar.medium { background-color: #ffc107; color: #212529; }
.progress-bar.low { background-color: #dc3545; }


/* --- MODAL HƯỚNG DẪN SỬ DỤNG --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    animation: fadeIn 0.3s;
}

.modal-content h2 { margin-top: 0; margin-bottom: 20px; }
.modal-content h4 { margin-top: 15px; margin-bottom: 5px; color: #333; }
.modal-content ul { list-style-position: inside; padding-left: 10px; }
.modal-content li { margin-bottom: 8px; line-height: 1.6; }

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
}

@keyframes fadeIn {
    from {opacity: 0; transform: translateY(-20px);}
    to {opacity: 1; transform: translateY(0);}
}


/* --- Responsive cho thiết bị di động --- */
@media (max-width: 1200px) {
    body {
        flex-direction: column;
        align-items: center;
    }
    .quiz-container, .history-panel {
        max-width: 700px;
        width: 100%;
    }
}