/* ===== BIẾN MÀU CHO THEME ===== */
:root {
    /* Dark Mode (mặc định) */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
    --background: #0f172a;
    --surface: #1e293b;
    --card: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
    --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --local-color: #3b82f6;
    --remote-color: #10b981;
    --accent-purple: #8B5CF6;
    --accent-blue: #3B82F6;
    --accent-green: #10B981;
    --accent-orange: #F97316;
    --accent-pink: #EC4899;
    --gradient-titziy: linear-gradient(135deg, #8B5CF6, #EC4899, #F97316);
}
.light-mode {
    /* Light Mode Variables */
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #ffb3419a;
    --secondary-hover: #4b5563;
    --background: #0080ff77;
    --surface: #ffffff;
    --card: #9fe4666e;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --success: #059669;
    --error: #dc2626;
    --warning: #d97706;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.08);
    --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --local-color: #2563eb;
    --remote-color: #059669;
    --accent-purple: #7c3aed;
    --accent-blue: #2563eb;
    --accent-green: #059669;
    --accent-orange: #ea580c;
    --accent-pink: #db2777;
    --gradient-titziy: linear-gradient(135deg, #7c3aed, #db2777, #ea580c);
}

/* ===== NÚT ĐÓNG MODAL MỚI - SIÊU ĐƠN GIẢN ===== */
.close-btn-new {
    /* VỊ TRÍ */
    position: absolute !important;
    top: 15px !important;
    right: 20px !important;
    z-index: 9999 !important;
    
    /* KÍCH THƯỚC LỚN ĐỂ DỄ BẤM */
    width: 50px !important;
    height: 50px !important;
    
    /* HIỂN THỊ */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* MÀU SẮC */
    background: var(--error) !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    
    /* CHỮ */
    font-size: 24px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    
    /* HIỆU ỨNG */
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3) !important;
}

/* HOVER EFFECT */
.close-btn-new:hover {
    background: #dc2626 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4) !important;
}

/* ACTIVE EFFECT */
.close-btn-new:active {
    transform: scale(0.95) !important;
}

/* TRÊN MOBILE */
@media (max-width: 768px) {
    .close-btn-new {
        top: 10px !important;
        right: 10px !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 20px !important;
    }
}

/* ===== NÚT CHUYỂN ĐỔI THEME ===== */
.theme-switcher {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
}

.theme-toggle-btn {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 50px;
    padding: 10px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
    font-family: 'Poppins', sans-serif;
}

.theme-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
    border-color: var(--primary-color);
}

.theme-toggle-btn i {
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-toggle-btn .fa-sun {
    color: #f59e0b;
}

.theme-toggle-btn .fa-moon {
    color: #6366f1;
}

/* Ẩn icon không cần thiết */
.dark-mode .theme-toggle-btn .fa-sun {
    display: none;
}

.dark-mode .theme-toggle-btn .fa-moon {
    display: inline-block;
}

.light-mode .theme-toggle-btn .fa-sun {
    display: inline-block;
}

.light-mode .theme-toggle-btn .fa-moon {
    display: none;
}

.theme-text {
    font-size: 0.9rem;
}

/* ===== BỘ NHỚ AI INDICATOR ===== */
.ai-memory-indicator {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: rgba(139, 92, 246, 0.9);
    border: 1px solid #8B5CF6;
    border-radius: 10px;
    padding: 10px 15px;
    font-size: 0.75rem;
    color: white;
    z-index: 999;
    max-width: 250px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    display: none;
    transition: all 0.3s ease;
}

.ai-memory-indicator.visible {
    display: block;
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-memory-count {
    font-weight: bold;
    margin-right: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.ai-memory-preview {
    font-size: 0.7rem;
    opacity: 0.9;
    line-height: 1.3;
    margin-top: 4px;
    display: block;
}

/* ===== NÚT AI ASSISTANT ===== */
.ai-assistant-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
}

.ai-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B6B, #4ECDC4);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(255, 107, 107, 0.4);
}

.ai-toggle-btn:active {
    transform: scale(0.95);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: all 0.3s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    animation: fadeIn 0.5s ease;
}

.page {
    display: none;
    min-height: 100vh;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.page.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background: var(--card);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px var(--shadow);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px var(--shadow);
}

/* === GIAO DIỆN ĐẸP PAGE 1 === */

/* Container chính */
#page1 .container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* === HEADER TÍTZİY NỔI BẬT === */
.info-section {
    text-align: center;
    margin-bottom: 30px;
    padding: 40px !important;
    background: linear-gradient(135deg, var(--surface), var(--card));
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.info-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 24px;
    padding: 2px;
    background: var(--gradient-titziy);
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: 0;
}

.main-title {
    font-size: 3.5rem;
    font-weight: 900;
    background: var(--gradient-titziy);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    line-height: 1.2;
    letter-spacing: 2px;
    text-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
    position: relative;
    z-index: 1;
    animation: glow 3s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow: 0 0 10px rgba(139, 92, 246, 0.3),
                     0 0 20px rgba(139, 92, 246, 0.2),
                     0 0 30px rgba(139, 92, 246, 0.1);
    }
    to {
        text-shadow: 0 0 20px rgba(236, 72, 153, 0.4),
                     0 0 30px rgba(236, 72, 153, 0.3),
                     0 0 40px rgba(236, 72, 153, 0.2);
    }
}

.project-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.project-subtitle {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
    font-size: 1rem;
}

/* Card spacing đẹp */
#page1 .card {
    margin-bottom: 25px;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 32px var(--shadow);
}

/* MÀU SẮC PHÂN CHIA CHỨC NĂNG */
.user-input-section {
    border-top: 4px solid var(--accent-pink);
}

.lesson-type-card {
    border-top: 4px solid var(--accent-blue);
}

.subject-card {
    border-top: 4px solid var(--accent-purple);
}

.settings-card {
    border-top: 4px solid var(--accent-green);
}

h1 {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 8px;
    font-size: 2.5rem;
    font-weight: 700;
}

h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.4rem;
    font-weight: 600;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.header-section {
    text-align: center;
    margin-bottom: 30px;
}

.input-section {
    margin-bottom: 0;
}

.input-section label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
}

input[type="text"], textarea {
    width: 100%;
    padding: 16px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="text"]::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

.btn-primary, .btn-secondary {
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.config-section {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.config-option {
    display: flex;
    align-items: center;
    padding: 10px 0;
}

.config-option input {
    display: none;
}

.config-option label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.3s ease;
    font-size: 1rem;
}

.checkmark {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 6px;
    margin-right: 12px;
    position: relative;
    transition: all 0.3s ease;
}

.config-option input:checked + label .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.config-option input:checked + label .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.action-section {
    text-align: center;
    margin-top: 40px;
}

.action-section button {
    margin: 0 10px;
    padding: 18px 40px !important;
    font-size: 1.1rem !important;
    border-radius: 16px !important;
}

/* === DANH SÁCH MÔN HỌC ĐẸP === */
.compact-subject-list {
    max-height: 300px;
    min-height: 200px;
    overflow-y: auto;
    border: 2px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    padding: 0;
}

.compact-subject-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
}

.compact-subject-item:last-child {
    border-bottom: none;
}

.compact-subject-item:hover {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--primary-color);
    transform: translateX(5px);
}

.compact-subject-item.selected {
    background: rgba(99, 102, 241, 0.2);
    border-left: 4px solid var(--primary-color);
    font-weight: 600;
}

.subject-select-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    cursor: pointer;
    padding: 4px 0;
}

.subject-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.subject-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 1rem;
}

.subject-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: var(--card);
    padding: 6px 12px;
    border-radius: 8px;
    min-width: 70px;
    text-align: center;
}

.subject-actions-area {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

.subject-export-btn,
.subject-settings-btn,
.subject-delete-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.subject-export-btn:hover {
    background: var(--success);
    transform: scale(1.05);
}

.subject-settings-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.subject-delete-btn:hover {
    background: var(--error);
    transform: scale(1.05);
}

/* Scrollbar cho danh sách môn học */
.compact-subject-list::-webkit-scrollbar {
    width: 6px;
}

.compact-subject-list::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 3px;
}

.compact-subject-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.compact-subject-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* === STYLE CHO CHỌN LOẠI BÀI HỌC === */
.lesson-type-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.lesson-type-option {
    flex: 1;
    padding: 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.lesson-type-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.lesson-type-option.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.2);
}

.type-icon {
    font-size: 2rem;
    flex-shrink: 0;
    padding: 12px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lesson-type-option[data-type="local"] .type-icon {
    background: rgba(59, 130, 246, 0.1);
    color: var(--local-color);
}

.lesson-type-option[data-type="remote"] .type-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--remote-color);
}

.type-info {
    flex: 1;
    min-width: 0;
}

.type-info h3 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.type-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* === STYLE CHO PHÂN LOẠI MÔN HỌC === */
.subject-section {
    display: none;
    margin-bottom: 20px;
}

.subject-section.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.subject-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.subject-section-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.subject-count {
    background: var(--primary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Remote info box */
.remote-info {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
}

.remote-info p {
    margin: 5px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Style riêng cho từng loại môn học */
#localSubjectList .compact-subject-item {
    border-left: 4px solid var(--local-color);
}

#remoteSubjectList .compact-subject-item {
    border-left: 4px solid var(--remote-color);
}

#remoteSubjectList .subject-actions-area {
    opacity: 0.6;
}

#remoteSubjectList .subject-settings-btn,
#remoteSubjectList .subject-delete-btn {
    cursor: not-allowed;
    background: var(--secondary-color);
}

#remoteSubjectList .subject-settings-btn:hover,
#remoteSubjectList .subject-delete-btn:hover {
    background: var(--secondary-color);
    transform: none;
}

/* === ẨN/HIỆN NÚT THEO TAB === */
.local-actions,
.remote-actions {
    display: none;
}

.subject-section.active .local-actions,
.subject-section.active .remote-actions {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Đảm bảo action-section trong card không bị ảnh hưởng */
.card .action-section {
    margin-top: 15px;
}

/* === NÚT BẮT ĐẦU LÀM BÀI === */
#startBtn {
    background: linear-gradient(135deg, var(--accent-orange), #8b5cf6);
    color: white;
    border: none;
    padding: 18px 20px !important;
    border-radius: 16px !important;
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    box-shadow: 0 8px 25px rgba(251, 146, 60, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#startBtn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

#startBtn:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(251, 146, 60, 0.4);
}

#startBtn:hover::before {
    left: 100%;
}

/* === MODAL AI ASSISTANT === */
#aiAssistantModal .modal-content {
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    background: var(--card);
    margin: 10% auto;
    border-radius: 20px;
    box-shadow: 0 20px 60px var(--shadow);
    border: 1px solid var(--border);
    animation: slideUp 0.4s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#aiAssistantModal .modal-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #FF6B6B, #4ECDC4);
    color: white;
    flex-shrink: 0;
}

#aiAssistantModal .modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    padding-right: 60px;
}

#aiAssistantModal .modal-header h3 i {
    margin-right: 10px;
}

#aiAssistantModal .modal-body {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: calc(80vh - 70px);
}

/* AI Configuration Section */
.ai-config-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.ai-config-section h4 {
    color: var(--text-primary);
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-api-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.ai-api-input:focus {
    outline: none;
    border-color: #4ECDC4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

.ai-api-input::placeholder {
    color: var(--text-muted);
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.85rem;
}

.api-status .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--error);
}

.api-status .status-dot.connected {
    background: var(--success);
}

/* AI Chat Interface */
.ai-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

.ai-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #FF6B6B, #4ECDC4);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message.assistant {
    align-self: flex-start;
    background: var(--card);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.ai-message.system {
    align-self: center;
    background: rgba(78, 205, 196, 0.1);
    color: #4ECDC4;
    font-size: 0.85rem;
    text-align: center;
    border-radius: 12px;
    padding: 8px 12px;
}

.ai-chat-input-container {
    padding: 15px;
    border-top: 1px solid var(--border);
    background: var(--card);
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

#aiChatInput {
    flex: 1;
    padding: 12px 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    resize: none;
    min-height: 50px;
    max-height: 100px;
}

#aiChatInput:focus {
    outline: none;
    border-color: #4ECDC4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.1);
}

#aiChatInput::placeholder {
    color: var(--text-muted);
}

.ai-send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B6B, #4ECDC4);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

/* AI Thinking Animation */
.ai-thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--card);
    border-radius: 18px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ECDC4;
    animation: thinking 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes thinking {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* AI Features on Question Page */
.ai-question-help {
    background: rgba(78, 205, 196, 0.1);
    border: 1px solid #4ECDC4;
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
}

.ai-question-help h4 {
    color: #4ECDC4;
    margin: 0 0 10px 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-question-help p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.ai-help-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.ai-help-btn {
    flex: 1;
    padding: 10px;
    background: var(--surface);
    border: 1px solid #4ECDC4;
    border-radius: 8px;
    color: #4ECDC4;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ai-help-btn:hover {
    background: #4ECDC4;
    color: white;
    transform: translateY(-2px);
}

/* Scrollbar for AI Chat */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #4ECDC4;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #FF6B6B;
}

/* === TRANG 2: LÀM BÀI === */
.quiz-header {
    margin-bottom: 30px;
}

.header-info {
    text-align: center;
}

.question-counter {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.question-section {
    text-align: center;
}

.question-content h2 {
    font-size: 1.3rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 0;
}

/* Options với A. B. C. D. bên trái */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.option {
    display: flex;
    align-items: flex-start;
    padding: 16px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}

.option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient);
    opacity: 0.1;
    transition: left 0.3s ease;
}

.option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.option:hover::before {
    left: 0;
}

.option.selected {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.option.selected::before {
    left: 0;
}

.option-letter {
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 12px;
    min-width: 24px;
    font-size: 1rem;
}

.option-text {
    flex: 1;
    line-height: 1.5;
}

.status-container {
    margin: 20px 0;
}

.status {
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.correct {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border-color: var(--success);
}

.incorrect {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
    border-color: var(--error);
}

.navigation-section {
    padding: 20px;
}

.navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.navigation button {
    flex: 1;
}

/* === MOBILE NAVIGATION === */
.mobile-navigation {
    display: none;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 10px 15px;
    z-index: 1000;
    box-shadow: 0 -4px 20px var(--shadow);
    width: 100%;
    margin-top: auto;
}

.mobile-nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.mobile-nav-btn {
    flex: 1;
    padding: 12px 8px;
    border: none;
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 60px;
    justify-content: center;
}

.mobile-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-nav-btn:not(:disabled):hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

.mobile-nav-btn.prev {
    background: var(--secondary-color);
    color: white;
}

.mobile-nav-btn.next {
    background: var(--primary-color);
    color: white;
}

.mobile-nav-btn.check {
    background: var(--success);
    color: white;
}

.mobile-nav-icon {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

/* === TRANG 3: KẾT QUẢ === */
.score-section {
    text-align: center;
}

.score-display {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 8px;
}

.score-value {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-details {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 20px;
}

.result-item {
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    border-left: 4px solid;
    background: var(--surface);
    transition: all 0.3s ease;
    cursor: pointer;
}

.result-item:hover {
    transform: translateX(5px);
    box-shadow: 0 8px 25px var(--shadow);
}

.result-item.correct {
    border-left-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.result-item.incorrect {
    border-left-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.result-item p {
    margin: 8px 0;
    color: var(--text-primary);
}

.result-item strong {
    color: var(--text-primary);
}

.result-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.result-actions {
    display: flex;
    gap: 10px;
}

.view-detail-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.view-detail-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* === MODAL CHI TIẾT CÂU HỎI === */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card);
    margin: 5% auto;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px var(--shadow);
    border: 1px solid var(--border);
    animation: slideUp 0.4s ease;
    overflow: hidden;
    position: relative;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.modal-header h3 {
    flex: 1;
    margin: 0;
    color: var(--text-primary);
    font-size: 1.4rem;
    padding-right: 60px; /* THÊM KHÔNG GIAN CHO NÚT ĐÓNG */
}

.modal-body {
    padding: 24px;
}

.detail-question {
    margin-bottom: 24px;
}

.detail-question h4 {
    color: var(--text-primary);
    font-size: 1.2rem;
    line-height: 1.6;
    margin: 0;
}

.detail-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.detail-option {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.detail-option.user-selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.detail-option.correct-answer {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.detail-option.user-selected.correct-answer {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.2);
}

.detail-option .option-letter {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 16px;
    flex-shrink: 0;
}

.detail-option.correct-answer .option-letter {
    background: var(--success);
}

.detail-option .option-text {
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
    line-height: 1.5;
}

.detail-result {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-choice, .correct-answer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-choice span:first-child, .correct-answer span:first-child {
    color: var(--text-secondary);
    font-weight: 500;
}

.choice-value, .answer-value {
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
}

.answer-value {
    background: var(--success);
}

/* === STYLE CHO DẠNG TRẢ LỜI NGẮN === */
.short-answer-section {
    padding: 20px 0;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
}

#shortAnswerInput {
    width: 100%;
    padding: 16px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

#shortAnswerInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#shortAnswerInput::placeholder {
    color: var(--text-muted);
}

.answer-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 15px;
}

/* === STYLE CHO DẠNG TRUE/FALSE SET === */
.true-false-set {
    padding: 10px 0;
}

.sub-questions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sub-question {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s ease;
    min-height: 60px;
}

.sub-question:hover {
    border-color: var(--primary-color);
}

.sub-question-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.sub-question-text {
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
    word-wrap: break-word;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    display: block;
    width: 100%;
}

.sub-question-number {
    color: var(--primary-color);
    font-weight: 700;
    margin-right: 6px;
    flex-shrink: 0;
}

.true-false-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 10px;
    align-items: center;
}

.tf-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--card);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tf-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.tf-btn.selected.correct {
    background: var(--success);
    color: white;
    border-color: var(--success);
    transform: scale(1.05);
}

.tf-btn.selected.incorrect {
    background: var(--error);
    color: white;
    border-color: var(--error);
    transform: scale(1.05);
}

.tf-btn.correct:not(.selected):hover {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.tf-btn.incorrect:not(.selected):hover {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.tf-hint {
    text-align: center;
    color: var(--warning);
    font-size: 0.9rem;
    padding: 12px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    border: 1px solid var(--warning);
    margin-top: 15px;
}

/* === STYLE CHO MODAL CHI TIẾT CÁC DẠNG MỚI === */
.detail-short-answer, .detail-true-false {
    margin-bottom: 20px;
}

.detail-answer-input {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 10px 0;
    font-weight: 500;
}

.detail-answer-input.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.detail-answer-input.incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.detail-sub-questions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.detail-sub-question {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.detail-sub-question.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.detail-sub-question.incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.detail-sub-question-text {
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.detail-sub-question-answer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.sub-question-result {
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
}

.sub-question-result.correct {
    background: var(--success);
    color: white;
}

.sub-question-result.incorrect {
    background: var(--error);
    color: white;
}

/* === MODAL CÀI ĐẶT MÔN HỌC === */
#subjectSettingsModal .modal-content {
    background: var(--card) !important;
    margin: 5% auto;
    border-radius: 20px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    border: 1px solid var(--border) !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#subjectSettingsModal .modal-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

#subjectSettingsModal .modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
    padding-right: 60px;
}

#subjectSettingsModal .modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(90vh - 120px);
    background: transparent !important;
}

#subjectSettingsModal .settings-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
    border-radius: 12px;
}

#subjectSettingsModal .settings-controls button {
    padding: 12px 20px;
    font-size: 0.9rem;
    flex: 1;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

#subjectSettingsModal .settings-controls .btn-primary {
    background: var(--primary-color);
    color: white;
}

#subjectSettingsModal .settings-controls .btn-secondary {
    background: var(--secondary-color);
    color: white;
}

#subjectSettingsModal .settings-controls button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

#subjectSettingsModal .question-type-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 150px;
    max-height: 300px;
    margin-bottom: 15px;
    overflow: hidden;
}

#subjectSettingsModal .type-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

#subjectSettingsModal .type-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

#subjectSettingsModal .btn-small {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

#subjectSettingsModal .btn-small:hover {
    background: var(--secondary-hover);
}

#subjectSettingsModal .question-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    max-height: none;
    padding: 5px;
    background: transparent;
}

#subjectSettingsModal .question-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    transition: all 0.3s ease;
    min-height: 40px;
}

.light-mode #subjectSettingsModal .question-item {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

#subjectSettingsModal .question-item:hover {
    border-color: var(--primary-color);
}

#subjectSettingsModal .question-item input[type="checkbox"] {
    margin-top: 2px;
    transform: scale(1);
}

#subjectSettingsModal .question-content {
    flex: 1;
    font-size: 0.8rem;
    line-height: 1.3;
    color: var(--text-primary);
    word-break: break-word;
    padding: 2px 0;
}

#subjectSettingsModal .question-item.selected {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
}

#subjectSettingsModal .settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding: 15px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
    border-radius: 12px;
}

#subjectSettingsModal .settings-actions button {
    padding: 12px 24px;
    font-size: 0.9rem;
    min-height: 44px;
}

/* Scrollbar cho danh sách câu hỏi */
#subjectSettingsModal .question-list::-webkit-scrollbar {
    width: 4px;
}

#subjectSettingsModal .question-list::-webkit-scrollbar-track {
    background: var(--surface);
}

#subjectSettingsModal .question-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

/* Cải thiện scrollbar cho modal body */
#subjectSettingsModal .modal-body::-webkit-scrollbar {
    width: 8px;
}

#subjectSettingsModal .modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#subjectSettingsModal .modal-body::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

#subjectSettingsModal .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* === STYLE CHO OPTIONS-SECTION KHI CÓ KẾT QUẢ === */
.options-section.correct {
    border: 2px solid var(--success);
    background: rgba(16, 185, 129, 0.05);
    transition: all 0.3s ease;
}

.options-section.incorrect {
    border: 2px solid var(--error);
    background: rgba(239, 68, 68, 0.05);
    transition: all 0.3s ease;
}

/* === RESPONSIVE DESIGN === */

/* Ẩn navigation desktop trên mobile */
@media (max-width: 768px) {
    .desktop-navigation {
        display: none;
    }
    
    .mobile-navigation {
        display: block;
    }
    
    /* QUAN TRỌNG: Sửa container và page để sticky hoạt động */
    .container {
        padding-bottom: 0;
        display: flex;
        flex-direction: column;
        min-height: calc(100vh - 80px);
    }
    
    #page2 {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }
    
    #page2 .container {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    /* Đảm bảo nội dung có thể scroll */
    .quiz-header,
    .question-section,
    .options-section,
    .status-container,
    .navigation-section {
        flex-shrink: 0;
    }
    
    .options-section {
        flex: 1;
        overflow-y: auto;
    }
    
    /* Responsive cho page 1 */
    #page1 .container {
        justify-content: flex-start;
        padding: 15px;
    }
    
    .main-title {
        font-size: 2.5rem;
    }
    
    #page1 .card {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .compact-subject-list {
        max-height: 250px;
    }
    
    .compact-subject-item {
        padding: 14px 16px;
    }
    
    .action-section button {
        padding: 16px 30px !important;
        font-size: 1rem !important;
    }
    
    /* === TỐI ƯU CHỌN LOẠI BÀI HỌC TRÊN MOBILE === */
    .lesson-type-selector {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .lesson-type-option {
        flex-direction: row;
        padding: 16px;
        min-height: auto;
        align-items: center;
        text-align: left;
    }
    
    .type-icon {
        font-size: 1.5rem;
        margin-right: 12px;
        flex-shrink: 0;
    }
    
    .type-info h3 {
        font-size: 1rem;
        margin-bottom: 4px;
    }
    
    .type-info p {
        font-size: 0.8rem;
        line-height: 1.3;
    }
    
    /* Modal responsive */
    .modal-content {
        width: 95%;
        margin: 2% auto;
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 16px;
        max-height: calc(95vh - 80px);
    }
    
    #subjectSettingsModal .modal-content {
        width: 98%;
        margin: 1% auto;
        max-height: 98vh;
    }
    
    #subjectSettingsModal .modal-body {
        padding: 16px;
        max-height: calc(98vh - 120px);
    }
    
    #subjectSettingsModal .question-type-section {
        min-height: 120px;
        max-height: 250px;
        padding: 12px;
    }
    
    #subjectSettingsModal .settings-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    #subjectSettingsModal .settings-controls button {
        width: 100%;
    }
    
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-header h3 {
        padding-right: 50px;
        font-size: 1.1rem;
    }
    
    /* Nút theme trên mobile */
    .theme-switcher {
        top: 15px;
        right: 15px;
        left: auto;
    }
    
    .theme-toggle-btn {
        padding: 8px 16px;
    }
    
    .theme-text {
        display: none;
    }
    
    .theme-toggle-btn {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        justify-content: center;
        padding: 0;
    }
    
    /* Bộ nhớ AI trên mobile */
    .ai-memory-indicator {
        bottom: 80px;
        right: 10px;
        max-width: 200px;
        font-size: 0.7rem;
    }
    
    /* Đảm bảo input field có đủ không gian khi bàn phím mở */
    #shortAnswerInput {
        font-size: 16px;
    }
    
    /* Responsive AI Modal */
    .ai-assistant-toggle {
        bottom: 15px;
        right: 15px;
    }
    
    .ai-toggle-btn {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
    
    #aiAssistantModal .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 85vh;
    }
    
    #aiAssistantModal .modal-body {
        padding: 20px;
        max-height: calc(85vh - 65px);
    }
    
    .ai-chat-messages {
        max-height: 250px;
        padding: 15px;
    }
    
    .ai-help-buttons {
        flex-direction: column;
    }
}

/* Responsive cho màn hình rất nhỏ */
@media (max-width: 480px) {
    .main-title {
        font-size: 2rem;
    }
    
    .info-content {
        font-size: 0.9rem;
    }
    
    .compact-subject-item {
        padding: 12px 14px;
        font-size: 0.9rem;
    }
    
    .subject-count {
        font-size: 0.8rem;
        min-width: 60px;
        padding: 4px 8px;
    }
    
    .mobile-nav-btn {
        min-height: 55px;
        font-size: 0.75rem;
        padding: 10px 6px;
    }
    
    .mobile-nav-icon {
        font-size: 1rem;
    }
    
    #subjectSettingsModal .settings-controls button {
        font-size: 0.75rem;
        padding: 8px 12px;
    }
    
    #subjectSettingsModal .modal-header h3 {
        font-size: 1rem;
    }
    
    #subjectSettingsModal .question-type-section {
        min-height: 100px;
    }
    
    #subjectSettingsModal .modal-body {
        padding: 12px;
        max-height: calc(98vh - 110px);
    }
    
    /* Nút theme trên mobile nhỏ */
    .theme-switcher {
        top: 10px;
        right: 10px;
    }
    
    .theme-toggle-btn {
        width: 44px;
        height: 44px;
    }
    
    /* Bộ nhớ AI trên mobile nhỏ */
    .ai-memory-indicator {
        bottom: 70px;
        right: 5px;
        max-width: 180px;
        padding: 8px 12px;
    }
    
    .ai-memory-count {
        font-size: 0.65rem;
    }
    
    .ai-memory-preview {
        font-size: 0.65rem;
    }
    
    /* === TỐI ƯU THÊM CHO CHỌN LOẠI BÀI HỌC === */
    .lesson-type-option {
        padding: 14px;
    }
    
    .type-icon {
        font-size: 1.3rem;
        margin-right: 10px;
    }
    
    .type-info h3 {
        font-size: 0.95rem;
    }
    
    .type-info p {
        font-size: 0.75rem;
    }
    
    /* Giảm khoảng cách giữa các section */
    .card {
        margin-bottom: 15px;
        padding: 20px;
    }
    
    #page1 .card {
        padding: 18px;
    }
    
    /* Responsive AI */
    .ai-assistant-toggle {
        bottom: 10px;
        right: 10px;
    }
    
    .ai-toggle-btn {
        width: 52px;
        height: 52px;
        font-size: 20px;
    }
    
    #aiAssistantModal .modal-header {
        padding: 16px 20px;
    }
    
    #aiAssistantModal .modal-header h3 {
        font-size: 1.1rem;
    }
    
    #aiAssistantModal .modal-body {
        padding: 16px;
        gap: 12px;
    }
    
    .ai-config-section {
        padding: 16px;
    }
    
    .ai-chat-messages {
        max-height: 200px;
        padding: 12px;
    }
    
    .ai-message {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    
    .ai-chat-input-container {
        padding: 12px;
    }
    
    #aiChatInput {
        padding: 10px 14px;
        min-height: 45px;
    }
    
    .ai-send-btn {
        width: 45px;
        height: 45px;
        font-size: 16px;
    }
}

/* Đặc biệt cho màn hình rất nhỏ */
@media (max-width: 360px) {
    .lesson-type-option {
        padding: 12px;
    }
    
    .type-icon {
        font-size: 1.2rem;
        margin-right: 8px;
    }
    
    .type-info h3 {
        font-size: 0.9rem;
    }
    
    .type-info p {
        font-size: 0.7rem;
    }
}

/* Đặc biệt cho landscape mode trên mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-navigation {
        padding: 8px 12px;
    }
    
    .mobile-nav-btn {
        min-height: 50px;
    }
    
    .container {
        min-height: calc(100vh - 65px);
    }
    
    .theme-switcher {
        top: 10px;
        right: 10px;
    }
    
    .ai-memory-indicator {
        bottom: 70px;
        right: 10px;
    }
    
    .ai-assistant-toggle {
        bottom: 10px;
        right: 10px;
    }
}

/* Scrollbar styling */
.result-details::-webkit-scrollbar {
    width: 6px;
}

.result-details::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 3px;
}

.result-details::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.result-details::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* === FIX KHOẢNG TRẮNG === */
.page:not(.active) {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
}

body.modal-open {
    overflow: hidden;
}

/* === MODAL NHẬP DỮ LIỆU === */
#importDataModal .modal-content {
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    background: var(--card);
    margin: 5% auto;
    border-radius: 20px;
    box-shadow: 0 20px 60px var(--shadow);
    border: 1px solid var(--border);
    animation: slideUp 0.4s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#importDataModal .modal-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

#importDataModal .modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.4rem;
    padding-right: 60px;
}

#importDataModal .modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

#importDataModal .input-section {
    margin-bottom: 24px;
}

#importDataModal .input-section label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
}

#importDataModal input[type="text"] {
    width: 100%;
    padding: 16px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

#importDataModal input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#importDataModal input[type="text"]::placeholder {
    color: var(--text-muted);
}

#importDataModal textarea {
    width: 100%;
    padding: 16px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    resize: vertical;
    min-height: 300px;
    max-height: 400px;
    line-height: 1.5;
    overflow-y: auto;
}

#importDataModal textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#importDataModal textarea::placeholder {
    color: var(--text-muted);
}

#importDataModal .action-section {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

#importDataModal .action-section button {
    flex: 1;
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

#importDataModal .btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

#importDataModal .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

#importDataModal .btn-secondary {
    background: var(--secondary-color);
    color: white;
}

#importDataModal .btn-secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
}

/* Scrollbar styling */
#importDataModal .modal-body::-webkit-scrollbar {
    width: 6px;
}

#importDataModal .modal-body::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 3px;
}

#importDataModal .modal-body::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

#importDataModal .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

#importDataModal textarea::-webkit-scrollbar {
    width: 6px;
}

#importDataModal textarea::-webkit-scrollbar-track {
    background: var(--surface);
}

#importDataModal textarea::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

/* Responsive cho modal nhập dữ liệu */
@media (max-width: 768px) {
    #importDataModal .modal-content {
        width: 95%;
        margin: 2% auto;
        max-height: 95vh;
    }
    
    #importDataModal .modal-body {
        padding: 20px;
        max-height: calc(95vh - 70px);
    }
    
    #importDataModal .action-section {
        flex-direction: column;
        gap: 12px;
    }
    
    #importDataModal textarea {
        min-height: 250px;
        max-height: 300px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    #importDataModal .modal-header {
        padding: 20px;
    }
    
    #importDataModal .modal-header h3 {
        font-size: 1.2rem;
    }
    
    #importDataModal .modal-body {
        padding: 16px;
        max-height: calc(95vh - 60px);
    }
    
    #importDataModal textarea {
        min-height: 200px;
        max-height: 250px;
        padding: 14px 16px;
    }
    
    #importDataModal .action-section button {
        padding: 14px 20px;
        font-size: 14px;
    }
}

/* === KHU VỰC KÉO THẢ FILE === */
.file-input-section {
    margin-bottom: 24px;
}

.file-input-section label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
}

.file-drop-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: var(--surface);
}

.file-drop-area:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.file-drop-area.highlight {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.file-drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.file-drop-icon {
    font-size: 2rem;
    opacity: 0.7;
}

.file-drop-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-browse-link {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

.file-browse-link:hover {
    color: var(--primary-hover);
}

/* === MODAL QUẢN LÝ REPO GITHUB === */
#githubReposModal .modal-content {
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    background: var(--card);
    margin: 5% auto;
    border-radius: 20px;
    box-shadow: 0 20px 60px var(--shadow);
    border: 1px solid var(--border);
    animation: slideUp 0.4s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#githubReposModal .modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Danh sách repo đã lưu */
.saved-repos-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.saved-repo-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.saved-repo-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow);
}

.repo-info {
    flex: 1;
    min-width: 0;
}

.repo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.repo-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.repo-status {
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.repo-status.synced {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.repo-status.not-synced {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.repo-url {
    font-size: 0.85rem;
    color: var(--text-secondary);
    word-break: break-all;
    margin-bottom: 6px;
}

.repo-description {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.repo-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.repo-actions {
    display: flex;
    gap: 8px;
    margin-left: 12px;
    flex-shrink: 0;
}

.repo-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.repo-action-btn.sync-btn {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.repo-action-btn.sync-btn:hover {
    background: #3b82f6;
    color: white;
    transform: scale(1.1);
}

.repo-action-btn.view-btn {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.repo-action-btn.view-btn:hover {
    background: #8b5cf6;
    color: white;
    transform: scale(1.1);
}

.repo-action-btn.delete-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.repo-action-btn.delete-btn:hover {
    background: var(--error);
    color: white;
    transform: scale(1.1);
}

/* Scrollbar cho danh sách repo */
.saved-repos-list::-webkit-scrollbar {
    width: 6px;
}

.saved-repos-list::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 3px;
}

.saved-repos-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.saved-repos-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Responsive cho modal repo */
@media (max-width: 768px) {
    #githubReposModal .modal-content {
        width: 95%;
        margin: 2% auto;
        max-height: 95vh;
    }
    
    #githubReposModal .modal-body {
        padding: 20px;
    }
    
    .saved-repo-item {
        flex-direction: column;
        gap: 12px;
    }
    
    .repo-actions {
        margin-left: 0;
        align-self: flex-end;
    }
    
    .repo-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .repo-status {
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    #githubReposModal .modal-header {
        padding: 20px;
    }
    
    #githubReposModal .modal-header h3 {
        font-size: 1.2rem;
    }
    
    #githubReposModal .modal-body {
        padding: 16px;
    }
    
    .saved-repo-item {
        padding: 12px;
    }
    
    .repo-action-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

/* Style cho modal cài đặt remote */
.remote-warning {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}

/* Phân biệt câu hỏi remote */
.question-item.remote-item {
    border-left: 3px solid var(--remote-color);
}

.question-item.local-item {
    border-left: 3px solid var(--local-color);
}

/* Animation cho thông báo */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Style cho nút đồng bộ */
.btn-sync {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-sync:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.btn-sync:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Animation cho nút đang đồng bộ */
.syncing {
    animation: pulse 1.5s infinite;
}

/* Animation cho chuyển trang */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page.active .container > * {
    animation: slideIn 0.5s ease forwards;
}

.page.active .container > *:nth-child(1) { animation-delay: 0.1s; }
.page.active .container > *:nth-child(2) { animation-delay: 0.2s; }
.page.active .container > *:nth-child(3) { animation-delay: 0.3s; }
.page.active .container > *:nth-child(4) { animation-delay: 0.4s; }
.page.active .container > *:nth-child(5) { animation-delay: 0.5s; }