/* =================================================================== */

/* CẤU TRÚC & LAYOUT CƠ BẢN */

/* =================================================================== */

.ate-test-container {

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;

    background-color: #fff;

    padding: 2.5%;

    border-radius: 12px;

    border: 1px solid #e0e0e0;

    max-width: 1000px;

    margin: 20px auto;

    box-shadow: 0 4px 15px rgba(0,0,0,0.05);

}

.ate-main-layout { display: flex; flex-wrap: wrap; gap: 25px; text-align: justify; }

.all-questions-pane { flex: 1; min-width: 0; }

.ate-sidebar { width: 100%; max-width: 300px; flex-shrink: 0; background-color: #f9fafb; padding: 20px; border: 1px solid #e5e7eb; border-radius: 8px; }

@media (min-width: 768px) { .ate-sidebar { width: 280px; } }



/* =================================================================== */

/* CẢI TIẾN SIDEBAR STICKY CHO LAYOUT MẶC ĐỊNH & NHIỀU ĐOẠN VĂN    */

/* =================================================================== */

.ate-main-layout .ate-sidebar {

    position: -webkit-sticky; /* Safari */

    position: sticky;

    top: 50px; 

    align-self: flex-start;

}



/* =================================================================== */

/* CÁC THÀNH PHẦN GIAO DIỆN */

/* =================================================================== */

.ate-header { border-bottom: 1px solid #e5e7eb; padding-bottom: 15px; margin-bottom: 25px; display: flex; justify-content: space-between; align-items: center; }

.ate-header h2 { margin: 0; font-size: 24px; font-weight: 600; color: var(--ate-primary-color, #475569); text-align: center; flex-grow: 1; }

.ate-timer-display { font-size: 18px; font-weight: bold; color: var(--ate-primary-color, #475569); background: var(--ate-light-bg, #f8fafc); padding: 8px 15px; border-radius: 20px; border: 1px solid var(--ate-primary-color-light, rgba(71, 85, 105, 0.3)); }



.single-question-block { background: #fff; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid #e5e7eb; }

.single-question-block .question-content { font-size: 16px; line-height: 1.7; color: #374151; }

.single-question-block .answers-list { margin-top: 20px; list-style: none; padding: 0; display: grid; gap: 12px; }

.answers-list label { display: flex; align-items: center; padding: 15px; border: 1px solid #d1d5db; border-radius: 8px; cursor: pointer; transition: all 0.2s ease-in-out; }

.answers-list label:hover { border-color: var(--ate-primary-color, #475569); background-color: var(--ate-light-bg, #f8fafc); }

.answers-list input[type="radio"], .answers-list input[type="checkbox"] { margin-right: 10px; }

.answers-list .answer-option.selected { border-color: var(--ate-primary-color, #475569); background-color: var(--ate-light-bg, #f8fafc); box-shadow: 0 0 0 2px var(--ate-primary-color-light, rgba(71, 85, 105, 0.3)); }



.ate-sidebar h4 { margin-top: 0; margin-bottom: 15px; font-size: 16px; font-weight: 600; }

.ate-navigation {

    display: grid;

    /* Thay đổi ở dòng dưới đây: từ auto-fill thành cố định 5 cột */

    grid-template-columns: repeat(5, 1fr); 

    gap: 10px; /* Tăng khoảng cách một chút cho thoáng hơn */

}

.ate-nav-item { display: flex; justify-content: center; align-items: center; width: 38px; height: 38px; border: 1px solid #d1d5db; border-radius: 50%; cursor: pointer; background-color: #fff; font-weight: 500; transition: all 0.2s; }

.ate-nav-item.answered { background-color: var(--ate-answered-color, #10b981); color: #fff; border-color: var(--ate-answered-color, #10b981); }

.ate-submit-btn { width: 100%; padding: 12px; margin-top: 20px; background-color: var(--ate-primary-color, #475569); color: #fff; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background-color 0.2s; }

.ate-submit-btn:hover { opacity: 0.9; }



/* =================================================================== */

/* CÁC THEME MÀU */

/* =================================================================== */

/* CODE MỚI */

.theme-slate { --ate-primary-color: #475569; --ate-primary-color-light: rgba(71, 85, 105, 0.3); --ate-light-bg: #f8fafc; --ate-answered-color: #059669; --ate-secondary-color: #6c757d; }

.theme-ocean { --ate-primary-color: #0ea5e9; --ate-primary-color-light: rgba(14, 165, 233, 0.3); --ate-light-bg: #f0f9ff; --ate-answered-color: #22c55e; --ate-secondary-color: #6c757d; }

.theme-forest { --ate-primary-color: #16a34a; --ate-primary-color-light: rgba(22, 163, 74, 0.3); --ate-light-bg: #f0fdf4; --ate-answered-color: #16a34a; --ate-secondary-color: #556b2f; }

.theme-ruby { --ate-primary-color: #e11d48; --ate-primary-color-light: rgba(225, 29, 72, 0.3); --ate-light-bg: #fff1f2; --ate-answered-color: #14b8a6; --ate-secondary-color: #6c757d; }

.theme-indigo { 

    --ate-primary-color: #4338ca; 

    --ate-primary-color-light: rgba(67, 56, 202, 0.3); 

    --ate-light-bg: #eef2ff; 

    --ate-answered-color: #10b981; /* Đã sửa lỗi chính tả ở đây */

    --ate-secondary-color: #6c757d; 

}



/* =================================================================== */

/* MÀN HÌNH BẮT ĐẦU & KẾT QUẢ */

/* =================================================================== */

.ate-start-screen { text-align: center; padding: 40px 20px; }

.ate-start-screen h2 { font-size: 26px; color: var(--ate-primary-color, #475569); margin-bottom: 15px; }

.ate-start-screen p { font-size: 16px; color: #4b5563; line-height: 1.7; max-width: 600px; margin: 15px auto; }

.ate-start-btn { padding: 12px 30px; background-color: var(--ate-primary-color, #475569); color: #fff; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; }

.ate-result { text-align: left; padding: 10px; }

.ate-results-header h2 { font-size: 24px; font-weight: 600; color: var(--ate-primary-color, #475569); margin-bottom: 20px; text-align: center; }





/* =================================================================== */

/* GIAO DIỆN READING & LISTENING (CHUẨN THEO CODE GỐC) */

/* =================================================================== */



/* --- Cấu hình chung cho các layout đặc biệt --- */

.ate-test-container.layout-reading-sticky,

.ate-test-container.layout-listening-sticky { 

    padding: 0; 

    border: none; 

    box-shadow: none; 

    max-width: 1280px;

}

.ate-test-container.layout-reading-sticky .ate-header,

.ate-test-container.layout-listening-sticky .ate-header { 

    padding: 15px 3.5%; 

    border-bottom: 1px solid #e0e0e0;

}



/* --- A. Cấu hình cho READING STICKY (Văn bản trên, 2 cột dưới) --- */



/* Phần 1: Đoạn văn ghim trên cùng */

.layout-reading-sticky .quiz-reading-passage-sticky {

    position: sticky;

    top: 32px; /* Dành cho admin bar của WordPress. Nếu không dùng admin bar, có thể đặt là 0 */

    z-index: 100;

    background: #fdfdfd;

    border-bottom: 2px solid #e0e0e0;

    padding: 20px 2.5%;

    height: 30vh; /* Chiều cao cố định bằng 40% màn hình */

    overflow-y: auto; /* Cho phép cuộn bên trong đoạn văn */

    box-sizing: border-box; /* Quan trọng */

    text-align: justify;

}



/* Phần 2: Khu vực 2 cột bên dưới */

/* Layout dưới cho Reading */
.layout-reading-sticky .reading-bottom-section {
    display: flex;
    flex-wrap: wrap; /* Thay đổi từ nowrap thành wrap */
    gap: 30px;
    padding: 30px 2.5%;
    text-align: justify;
}

/* === FIX RIÊNG CHO MOBILE (< 1024px) === */
@media (max-width: 1024px) {
    /* 1. Đưa đoạn văn về trạng thái bình thường (không ghim) để dành chỗ cho câu hỏi */
    .layout-reading-sticky .quiz-reading-passage-sticky {
        position: static !important;
        height: auto !important;
        max-height: 350px;
        overflow-y: auto;
        border-bottom: 2px solid #eee;
        margin-bottom: 20px;
    }

    /* 2. Ép các cột xếp chồng lên nhau */
    .layout-reading-sticky .reading-bottom-section {
        flex-direction: column;
        padding: 15px;
    }

    /* 3. Sidebar chiếm 100% chiều rộng và nằm dưới câu hỏi */
    .layout-reading-sticky .reading-bottom-section .all-questions-pane {
        width: 100%;
        order: 1; /* Câu hỏi hiện trước */
    }

    .layout-reading-sticky .reading-bottom-section .ate-sidebar {
        width: 100% !important;
        position: static !important;
        order: 2; /* Danh sách câu hỏi và nút nộp bài hiện sau */
        margin-top: 20px;
    }
    
    /* 4. Đảm bảo text không bị bó hẹp */
    .single-question-block .question-content {
        word-break: break-word;
    }
}

/* Cột trái: Câu hỏi */

.layout-reading-sticky .reading-bottom-section .all-questions-pane {

    flex: 1; /* Chiếm không gian còn lại */

    min-width: 0; 

}

/* Cột phải: Sidebar */

.layout-reading-sticky .reading-bottom-section .ate-sidebar {

    width: 320px;

    flex-shrink: 0;

    position: sticky;

    /* Vị trí ghim = chiều cao đoạn văn + khoảng cách top của đoạn văn + padding top của khu vực dưới */

    top: calc(30vh + 32px + 30px);

    height: fit-content;

}





/* --- B. Cấu hình cho LISTENING STICKY (2 cột cạnh nhau) --- */

.layout-listening-sticky .reading-listening-body { 

    display: flex;

    gap: 30px; 

    padding: 20px 2.5%;

    align-items: flex-start;

}

.layout-listening-sticky .all-questions-pane {

    flex: 1;

    min-width: 0;

}

.layout-listening-sticky .sticky-audio-player { 

    position: sticky; top: 0px; z-index: 100; 

    background: #fff; padding: 15px; border-radius: 8px; 

    box-shadow: 0 4px 10px rgba(0,0,0,0.08); 

    margin-bottom: 25px; 

}

.layout-listening-sticky .sticky-audio-player audio { width: 100%; }

.layout-listening-sticky .ate-sidebar {

    width: 280px;

    flex-shrink: 0;

    position: sticky;

    top: 50px;

}



/* === CHO TABLET & MOBILE (<= 1024px) === */

@media (max-width: 1024px) {

    /* Chuyển layout 2 cột thành 1 cột */

    .reading-listening-body { 

        flex-direction: column; 

        padding: 20px 5%;

        gap: 20px;

    }

    

    /* Gỡ sticky cho cột đọc bên trái */

    .reading-passage-pane-sticky { 

        position: static; 

        height: auto; 

        max-height: 400px;

        border-right: none; 

        border-bottom: 1px solid #e5e7eb; 

        margin-bottom: 20px; 

        padding-right: 0; 

        flex-basis: auto; 

        min-width: auto;

    }



    /* Gỡ sticky cho audio player */

    .sticky-audio-player { 

        position: static; 

        box-shadow: none; 

        border-bottom: 2px solid #e5e7eb; 

        border-radius: 0; 

        margin-bottom: 15px;

    }



    /* Gỡ sticky cho sidebar của layout reading-sticky và listening-sticky */

    .ate-main-content-right .ate-sidebar, 

    .layout-listening-sticky .ate-sidebar { 

        position: static; 

        width: 100%; 

        max-width: none; 

        order: 2;

        margin-top: 20px;

    }

    .ate-main-content-right { 

        flex-direction: column; 

        gap: 20px;

    }

}





/* CODE MỚI */

/* =================================================================== */

/* NÚT BẤM VÀ XEM LẠI ĐÁP ÁN (ĐÃ CẬP NHẬT) */

/* =================================================================== */

/* CODE MỚI */

.back-to-list-btn {

    background-color: #fff;

    color: #4b5563;

    border: 1px solid #d1d5db;

    padding: 8px 15px;

    border-radius: 6px;

    cursor: pointer;

    font-size: 14px;

    font-weight: 500;

    transition: all 0.2s;

}

.back-to-list-btn:hover {

    border-color: var(--ate-primary-color, #475569);

    color: var(--ate-primary-color, #475569);

}

.back-to-list-btn:hover { background-color: #e5e7eb; }

.ate-results-actions { text-align: center; margin-top: 25px; padding-top: 25px; border-top: 1px solid #eee; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }

.ate-results-actions button { padding: 12px 25px; font-size: 16px; cursor: pointer; border-radius: 8px; color: white; border: none; font-weight: 600; }

.ate-results-actions .review-answers-btn { background-color: var(--ate-answered-color, #28a745); }

.ate-results-actions .try-again-btn { background-color: #007bff; }

.ate-results-actions .back-to-list-btn { background-color: var(--ate-secondary-color, #6c757d); color: white; }





/* === GIAO DIỆN REVIEW MODE === */

.review-mode .ate-header h2 .review-title { color: var(--ate-answered-color, #10b981); }

.review-mode .ate-sidebar .review-actions { display: flex; flex-direction: column; gap: 10px; }

.review-mode .ate-sidebar .review-actions button { width: 100%; padding: 12px; font-size: 16px; font-weight: 600; border-radius: 8px; border: none; cursor: pointer; color: #fff; }

.review-mode .ate-sidebar .try-again-btn { background-color: #007bff; }

.review-mode .ate-sidebar .back-to-list-btn { background-color: #6c757d; }



.review-mode .answer-option { cursor: default; pointer-events: none; }

.review-mode .answer-option label { cursor: default; }



/* Đáp án ĐÚNG của hệ thống (luôn có viền xanh) */

.review-mode .answer-option.is-correct-answer {

    border: 2px solid var(--ate-answered-color, #10b981) !important;

}



/* Người dùng chọn ĐÚNG (nền xanh lá nhạt) */

.review-mode .answer-option.user-correct {

    background-color: #e9f7ec !important;

    border-color: var(--ate-answered-color, #10b981) !important;

}



/* Người dùng chọn SAI (nền đỏ nhạt) */

.review-mode .answer-option.user-incorrect {

    background-color: #fbe9e9 !important;

    border-color: #dc3545 !important;

}

/* =================================================================== */

/* DANH SÁCH ĐỀ THI [advanced_test_list] */

/* =================================================================== */

.ate-list-container { max-width: 1100px; margin: 30px auto; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

.ate-list-container h2 { text-align: center; font-size: 28px; margin-bottom: 30px; }

.ate-controls-container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; margin-bottom: 30px; }

.ate-filters { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }

.ate-filters .filter-btn { background-color: #fff; color: #4b5563; border: 1px solid #d1d5db; padding: 8px 20px; border-radius: 99px; font-size: 14px; font-weight: 500; cursor: pointer; }

.ate-filters .filter-btn.active { background-color: var(--ate-primary-color, #475569); color: #fff; border-color: var(--ate-primary-color, #475569); }

.ate-search-container { flex-grow: 1; max-width: 350px; }

#ate-search-input { width: 100%; padding: 9px 15px; border: 1px solid #d1d5db; border-radius: 99px; font-size: 14px; }

.ate-list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 25px; }

.ate-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); transition: transform 0.2s; }

.ate-card:hover { transform: translateY(-5px); }

.ate-card .card-tag { align-self: flex-start; background-color: var(--ate-light-bg, #f8fafc); color: var(--ate-primary-color, #475569); padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }

.ate-card .card-title { font-size: 18px; font-weight: 600; margin: 15px 0; flex-grow: 1; }

.ate-card .card-meta { display: flex; gap: 15px; font-size: 14px; color: #6b7280; margin-bottom: 20px; border-top: 1px solid #f3f4f6; padding-top: 15px; }

.ate-card .card-meta span { display: flex; align-items: center; gap: 5px; }

.ate-card .card-button { background-color: var(--ate-primary-color, #475569); color: #fff; text-align: center; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; }



/* =================================================================== */

/* HERO SECTION GIỚI THIỆU CHUYÊN MỤC ĐỀ THI                       */

/* =================================================================== */

.ate-category-description-wrapper {

    margin-bottom: 30px;

}



/* Gỡ bỏ thẻ p mặc định của WordPress */

.ate-category-description-wrapper p:first-child {

    margin-top: 0;

}

.ate-category-description-wrapper p:last-child {

    margin-bottom: 0;

}



.ate-hero-section {

    color: #fff;

    padding: 25px 20px;

    border-radius: 16px;

    margin: 0 auto; /* Đã có wrapper bao ngoài */

    max-width: 1100px;

    text-align: center;

    box-shadow: 0 10px 25px rgba(0,0,0,0.1);

}



.ate-hero-container {

    max-width: 800px;

    margin: 0 auto;

}



.ate-hero-badge {

    display: inline-block;

    background-color: rgba(255, 255, 255, 0.15);

    padding: 8px 16px;

    border-radius: 99px;

    font-size: 14px;

    font-weight: 500;

    margin-bottom: 20px;

}



.ate-hero-title {

    font-size: 42px;

    font-weight: 700;

    color: #fff;

    margin-bottom: 15px;

    line-height: 1.2;

}



.ate-hero-description {

    font-size: 16px;

    line-height: 1.7;

    opacity: 0.9;

    margin-bottom: 30px;

}



.ate-hero-filters {

    display: flex;

    justify-content: center;

    gap: 15px;

    flex-wrap: wrap;

    margin-bottom: 40px;

}



/* Tìm và thay thế quy tắc này */

.ate-hero-filters .filter-tag {

    /* Màu sắc được đặt inline */

    padding: 10px 25px;

    border-radius: 99px;

    text-decoration: none;

    font-weight: 600;

    transition: transform 0.2s, box-shadow 0.2s; /* Thêm transition cho box-shadow */

    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.2); /* Hiệu ứng đổ bóng & viền trong */

}

.ate-hero-filters .filter-tag:hover {

    transform: scale(1.05) translateY(-2px); /* Hiệu ứng nhấc lên khi hover */

    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.2);

}



.ate-feature-grid {

    display: grid;

    grid-template-columns: repeat(2, 1fr);

    gap: 20px;

    margin-bottom: 40px;

}

/* Tìm và thay thế quy tắc này */

.ate-feature-item {

    background-color: rgba(0, 0, 0, 0.15); /* Tăng độ đậm của nền để nổi bật hơn */

    border: 1px solid rgba(255, 255, 255, 0.2);

    padding: 20px;

    border-radius: 12px;

    font-size: 16px;

    font-weight: 500;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 10px;

    text-align: left;

    box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.2), inset 0 -1px 1px rgba(255, 255, 255, 0.1); /* Hiệu ứng nhấn vào trong */

    transition: transform 0.2s;

}



.ate-feature-item:hover {

    transform: scale(1.02); /* Phóng to nhẹ khi hover */

}



.feature-icon {

    font-size: 20px;

}



/* Tìm và thay thế quy tắc này */

.ate-main-cta-button {

    display: inline-block;

    /* Màu sắc được đặt inline */

    padding: 15px 40px;

    border-radius: 99px;

    text-decoration: none;

    font-size: 18px;

    font-weight: 700;

    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2), inset 0 2px 2px rgba(255, 255, 255, 0.3); /* Hiệu ứng 3D mạnh hơn */

    transition: all 0.3s;

    border-bottom: 3px solid rgba(0, 0, 0, 0.2); /* Thêm viền dưới để tạo cảm giác nút bấm */

}

.ate-main-cta-button:hover {

    filter: brightness(1.1); /* Làm sáng màu hơn khi hover */

    transform: translateY(-4px); /* Nhấc lên cao hơn */

    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.25), inset 0 2px 2px rgba(255, 255, 255, 0.3);

}

.ate-main-cta-button:active {

    transform: translateY(-1px); /* Hiệu ứng nhấn xuống khi click */

    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), inset 0 2px 2px rgba(255, 255, 255, 0.3);

}



/* Responsive cho mobile */

@media (max-width: 768px) {

    .ate-hero-title {

        font-size: 32px;

    }

    .ate-feature-grid {

        grid-template-columns: 1fr; /* 1 cột trên mobile */

    }

}



/* =================================================================== */

/* TIÊU ĐỀ DANH SÁCH ĐỀ THI [advanced_test_list]                  */

/* =================================================================== */

.ate-list-container h2 {

    text-align: center;

    font-size: 36px;  /* Tăng kích thước cho nổi bật */

    font-weight: 700; /* Đậm hơn */

    margin-bottom: 50px; /* Tăng khoảng cách với lưới đề thi */

    margin-top: 40px; /* Thêm khoảng cách ở trên, tách biệt với phần giới thiệu */

    color: var(--ate-primary-color, #475569); /* Sử dụng màu của theme */

    position: relative; /* Cần thiết để định vị đường gạch chân */

    padding-bottom: 20px; /* Tạo không gian cho đường gạch chân */

}



/* Tạo một đường gạch chân trang trí ngắn ở dưới */

.ate-list-container h2::after {

    content: '';

    display: block;

    width: 80px; /* Độ rộng của đường gạch chân */

    height: 4px; /* Độ dày */

    background-color: var(--ate-primary-color, #475569); /* Cùng màu với chữ */

    border-radius: 2px; /* Bo tròn nhẹ các cạnh */

    

    /* Căn giữa đường gạch chân */

    position: absolute;

    bottom: 0;

    left: 50%;

    transform: translateX(-50%);

}



/* Responsive cho mobile */

@media (max-width: 768px) {

    .ate-list-container h2 {

        font-size: 28px;

        margin-bottom: 40px;

    }

}



/* =================================================================== */

/* CẢI TIẾN SIDEBAR - THÊM THANH CUỘN CHO DANH SÁCH CÂU HỎI     */

/* =================================================================== */



/* 1. Biến sidebar thành một flex container để dễ dàng quản lý không gian */

.ate-sidebar {

    display: flex;

    flex-direction: column;

    /* Giới hạn chiều cao tối đa của sidebar, trừ đi khoảng trống cho header/footer */

    /* Điều này quan trọng để thanh cuộn bên trong hoạt động đúng */

    max-height: calc(100vh - 120px); 

}



/* 2. Cho phép phần danh sách câu hỏi co giãn và có thanh cuộn */

.ate-sidebar .ate-navigation {

    flex-grow: 1; /* Cho phép phần tử này chiếm hết không gian dọc còn lại */

    overflow-y: auto; /* Tự động hiển thị thanh cuộn dọc khi cần */

    padding-right: 30px; /* Thêm một chút không gian để thanh cuộn không che mất nội dung */

    margin-right: -20px; /* Bù lại phần padding để căn chỉnh không bị lệch */

    max-height: 25vh;

}



/* 3. Đảm bảo nút Nộp bài không bị co lại và luôn ở dưới cùng */

.ate-sidebar .ate-submit-btn {

    flex-shrink: 0; 

}



/* Responsive cho mobile */

@media (max-width: 768px) {

    .ate-header h2 {

        font-size: 14px;

    }

    

    .back-to-list-btn {

        font-size: 10px;

    }

}



.quiz-reading-passage {

    text-align: justify;

}



/* =================================================================== */

/* RESPONSIVE CHO LAYOUT NHIỀU ĐOẠN VĂN (MOBILE)                  */

/* =================================================================== */



@media (max-width: 768px) {

    /* 1. Chuyển layout chính thành dạng cột */

    .ate-test-container.layout-reading-multiple-passages .ate-main-layout,

    .ate-test-container.layout-default .ate-main-layout {

        flex-direction: column;

    }



    /* 2. Gỡ bỏ chế độ sticky và đặt lại kích thước cho sidebar */

    .ate-test-container.layout-reading-multiple-passages .ate-sidebar,

    .ate-test-container.layout-default .ate-sidebar {

        position: static; /* Gỡ bỏ sticky */

        width: 100%;      /* Chiếm toàn bộ chiều rộng */

        max-width: none;  /* Bỏ giới hạn chiều rộng tối đa */

        margin-top: 30px; /* Tạo khoảng cách với phần câu hỏi ở trên */

        order: 2;         /* Quan trọng: Di chuyển sidebar xuống vị trí thứ 2 (dưới câu hỏi) */

        max-height: none; /* Bỏ giới hạn chiều cao để không bị cuộn vô lý */

    }



    /* 3. Gỡ bỏ thanh cuộn bên trong sidebar trên mobile */

    .ate-test-container.layout-reading-multiple-passages .ate-sidebar .ate-navigation,

    .ate-test-container.layout-default .ate-sidebar .ate-navigation {

        overflow-y: visible; /* Tắt thanh cuộn */

        max-height: none;    /* Bỏ giới hạn chiều cao */

    }

}



/* THÊM VÀO CUỐI FILE ate-style.css */

.card-tags-wrapper {

    display: flex;

    flex-wrap: wrap;

    gap: 8px;

    /* Ghi đè lên align-self của .card-tag cũ để đảm bảo căn trái */

    align-self: flex-start; 

}



.ate-card .card-tag {

    /* Bỏ align-self vì đã có wrapper xử lý */

    align-self: auto; 

}



/* THÊM VÀO CUỐI FILE ate-style.css */



/* THAY BẰNG KHỐI CODE MỚI NÀY */

/* Cải thiện layout cho khu vực control */

.ate-controls-container {

    display: flex;

    flex-wrap: wrap; /* Cho phép các item xuống dòng khi không đủ chỗ */

    gap: 15px;

    align-items: center; /* Căn giữa các item theo chiều dọc */

    justify-content: space-between; /* Căn đều các nhóm */

}



.ate-filters {

    margin-right: auto; /* Đẩy nhóm filter kỹ năng sang trái */

}



.ate-secondary-filters {

    display: flex;

    gap: 15px;

    align-items: center; /* Căn các bộ lọc phụ thẳng hàng */

}

/* THAY BẰNG KHỐI NÀY */

.ate-number-filter-container {

    display: flex;

    align-items: center;

    gap: 8px; /* Khoảng cách giữa nhãn và ô lọc */

}



.ate-filter-label {

    font-size: 14px;

    font-weight: 500;

    color: #4b5563;

    white-space: nowrap; /* Đảm bảo chữ không bị xuống dòng */

    flex-shrink: 0;

}



#ate-number-filter {

    min-width: 120px; /* Đặt độ rộng tối thiểu cho ô lọc */

}

.ate-search-container {

    min-width: 250px;

}



#ate-number-filter {

    width: 100%;

    padding: 8px 15px;

    border: 2px solid #e5e7eb; /* Viền dày hơn một chút */

    border-radius: 8px; /* Bo tròn vừa phải, đồng bộ với card */

    font-weight: 500;

    color: #374151;

    background-color: #fff;

    -webkit-appearance: none;

    -moz-appearance: none;

    appearance: none;

    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236b7280%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');

    background-repeat: no-repeat;

    background-position: right 15px top 50%;

    background-size: .65em auto;

    padding-right: 40px;

    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; /* Thêm hiệu ứng chuyển động */

    cursor: pointer;

    font-size: 14px;

}



/* Làm nổi bật khi người dùng tương tác */

#ate-number-filter:hover {

    border-color: #d1d5db;

}

#ate-number-filter:focus {

    outline: none;

    border-color: var(--ate-primary-color, #475569); /* Đổi màu viền theo theme */

    box-shadow: 0 0 0 3px var(--ate-primary-color-light, rgba(71, 85, 105, 0.3)); /* Thêm hiệu ứng đổ bóng */

}



/* Responsive cho mobile */

@media (max-width: 900px) {

    .ate-controls-container {

        flex-direction: column;

        align-items: stretch;

    }

    .ate-secondary-filters {

        flex-direction: column;

        width: 100%;

    }

    .ate-set-filter-container,

    .ate-search-container {

        min-width: 100%;

        max-width: none;

    }

}



/* =================================================================== */

/* BỔ SUNG CSS CHO BỘ LỌC PRACTICE TEST                             */

/* =================================================================== */



.ate-practice-test-filter-container {

    display: flex;

    align-items: center;

    gap: 8px; /* Khoảng cách giữa nhãn và ô lọc */

}



#ate-practice-test-filter {

    min-width: 150px; /* Đặt độ rộng tối thiểu cho ô lọc */

    width: 100%;

    padding: 8px 15px;

    border: 2px solid #e5e7eb; /* Viền dày hơn một chút */

    border-radius: 8px; /* Bo tròn vừa phải, đồng bộ với card */

    font-weight: 500;

    color: #374151;

    background-color: #fff;

    -webkit-appearance: none;

    -moz-appearance: none;

    appearance: none;

    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236b7280%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');

    background-repeat: no-repeat;

    background-position: right 15px top 50%;

    background-size: .65em auto;

    padding-right: 40px;

    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out; /* Thêm hiệu ứng chuyển động */

    cursor: pointer;

    font-size: 14px;

}



#ate-practice-test-filter:hover {

    border-color: #d1d5db;

}

#ate-practice-test-filter:focus {

    outline: none;

    border-color: var(--ate-primary-color, #475569); /* Đổi màu viền theo theme */

    box-shadow: 0 0 0 3px var(--ate-primary-color-light, rgba(71, 85, 105, 0.3)); /* Thêm hiệu ứng đổ bóng */

}



/* Sửa lại độ rộng tối thiểu của search container để không bị đẩy quá nhiều */

.ate-search-container {

    min-width: 200px;

}



/* =================================================================== */

/* MỚI: BỔ SUNG CSS CHO BỘ LỌC PART                                 */

/* =================================================================== */



.ate-part-filter-container {

    display: flex;

    align-items: center;

    gap: 8px;

}



#ate-part-filter {

    min-width: 150px;

    width: 100%;

    padding: 8px 15px;

    border: 2px solid #e5e7eb;

    border-radius: 8px;

    font-weight: 500;

    color: #374151;

    background-color: #fff;

    -webkit-appearance: none;

    -moz-appearance: none;

    appearance: none;

    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236b7280%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');

    background-repeat: no-repeat;

    background-position: right 15px top 50%;

    background-size: .65em auto;

    padding-right: 40px;

    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;

    cursor: pointer;

    font-size: 14px;

}



#ate-part-filter:hover {

    border-color: #d1d5db;

}

#ate-part-filter:focus {

    outline: none;

    border-color: var(--ate-primary-color, #475569);

    box-shadow: 0 0 0 3px var(--ate-primary-color-light, rgba(71, 85, 105, 0.3));

}



/* =================================================================== */

/* CSS CHO MODULE THỐNG KÊ ẢO (SOCIAL PROOF)                       */

/* =================================================================== */



.ate-card .card-stats-wrapper {

    margin-bottom: 15px;

    margin-top: -5px; /* Kéo lên gần title hơn */

}



.ate-card .card-rating {

    display: flex;

    align-items: center;

    gap: 8px;

}



.ate-card .stars-container {

    position: relative;

    display: inline-block;

    color: #d1d5db; /* Màu sao nền (xám) */

    font-size: 16px;

    line-height: 1;

}



.ate-card .stars-foreground {

    position: absolute;

    top: 0;

    left: 0;

    white-space: nowrap;

    overflow: hidden;

    color: #f59e0b; /* Màu sao nổi (vàng) */

}



.ate-card .rating-text {

    font-size: 13px;

    color: #6b7280;

    font-weight: 500;

}



/* Căn chỉnh lại icon lượt làm bài trong card-meta */

.ate-card .card-meta span svg {

    flex-shrink: 0; /* Đảm bảo icon không bị co lại */

}



/* =================================================================== */

/* CSS CHO MIỄN TRỪ TRÁCH NHIỆM & THỐNG KÊ MÀN HÌNH BẮT ĐẦU        */

/* =================================================================== */



/* 1. Khối Miễn trừ trách nhiệm (Đã cập nhật để theo theme) */

.ate-list-disclaimer {

    max-width: 800px;

    margin: -20px auto 40px auto;

    padding: 15px 25px;

    background-color: var(--ate-light-bg, #f8f9fa); /* Sử dụng màu nền nhạt của theme */

    border: 1px solid var(--ate-primary-color-light, #e9ecef); /* Sử dụng màu viền nhạt của theme */

    border-radius: 12px; /* Bo tròn nhiều hơn cho mềm mại */

    text-align: center;

    font-size: 14px;

    color: var(--ate-secondary-color, #6c757d); /* Sử dụng màu chữ phụ của theme */

    line-height: 1.7;

    font-style: italic; /* In nghiêng để nhấn mạnh */

}



/* 2. Khối Thống kê ở màn hình bắt đầu */

.ate-start-screen .ate-start-stats {

    display: flex;

    justify-content: center;

    align-items: center;

    gap: 20px;

    flex-wrap: wrap;

    margin: 20px 0;

}



.ate-start-screen .stat-item {

    display: flex;

    align-items: center;

    gap: 8px;

    background-color: #f8f9fa;

    padding: 8px 15px;

    border-radius: 99px;

    font-size: 14px;

    font-weight: 500;

    color: #495057;

}



.ate-start-screen .stat-item svg {

    flex-shrink: 0;

}



.ate-start-screen .rating-stat .stars-container {

    position: relative;

    display: inline-block;

    color: #d1d5db; /* Màu sao nền */

    font-size: 18px;

    line-height: 1;

}



.ate-start-screen .rating-stat .stars-foreground {

    position: absolute;

    top: 0;

    left: 0;

    white-space: nowrap;

    overflow: hidden;

    color: #f59e0b; /* Màu sao nổi */

}



.ate-start-screen .rating-stat strong {

    font-size: 15px;

    color: #212529;

}



.ate-start-screen .rating-stat span {

    font-size: 13px;

    color: #6c757d;

}



/* =================================================================== */

/* CSS CHO KHỐI ĐỀ THI LIÊN QUAN (TRANG KẾT QUẢ)                    */

/* =================================================================== */



.ate-related-tests {

    margin-top: 40px;

    padding-top: 40px;

    border-top: 1px solid #e9ecef;

}



.ate-related-tests h3 {

    text-align: center;

    font-size: 24px;

    font-weight: 600;

    color: var(--ate-primary-color, #475569);

    margin-bottom: 30px;

}



.ate-related-tests .related-grid {

    display: grid;

    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));

    gap: 15px;

}



.ate-related-tests .related-card {

    display: block;

    padding: 20px 15px;

    background-color: #fff;

    border: 1px solid #dee2e6;

    border-radius: 8px;

    text-align: center;

    font-weight: 500;

    color: #495057;

    text-decoration: none;

    transition: all 0.2s ease-in-out;

    box-shadow: 0 2px 4px rgba(0,0,0,0.04);

    cursor: pointer; /* THÊM DÒNG NÀY */

}



.ate-related-tests .related-card:hover {

    transform: translateY(-3px);

    border-color: var(--ate-primary-color, #475569);

    color: var(--ate-primary-color, #475569);

    box-shadow: 0 5px 15px rgba(0,0,0,0.08);

}



/* =================================================================== */

/* === CẢI TIẾN NÚT BẤM VỚI SPINNER =============================== */

/* =================================================================== */



/* Thêm vào nút bấm để căn chỉnh spinner và text */

.ate-submit-btn.ate-btn-loading {

    cursor: wait;

    display: inline-flex;

    align-items: center;

    justify-content: center;

}



/* Spinner quay tròn */

.ate-btn-loading .button-spinner {

    display: inline-block;

    width: 18px;

    height: 18px;

    border: 2px solid rgba(255, 255, 255, 0.5); /* Màu nền mờ của vòng quay */

    border-top-color: #ffffff; /* Màu của phần đang quay */

    border-radius: 50%;

    animation: spin 0.8s linear infinite;

    margin-right: 10px;

}



/* Animation cho spinner */

@keyframes spin {

  to { 

    transform: rotate(360deg); 

  }

}



.ate-dang-filter-container {

    display: flex;

    align-items: center;

    gap: 8px;

}



#ate-dang-filter {

    min-width: 150px;

    padding: 8px 15px;

    border: 2px solid #e5e7eb;

    border-radius: 8px;

    font-size: 14px;

    cursor: pointer;

}

/* Mobile responsive */

@media (max-width: 900px) {

    .ate-dang-filter-container {

        width: 100%;

    }

    #ate-dang-filter {

        width: 100%;

    }

}



/* Tối ưu khu vực chứa nút bấm lọc */

.ate-filters {

    display: flex;

    flex-wrap: wrap; /* Cho phép xuống dòng */

    gap: 8px;

    max-height: 120px; /* Giới hạn khoảng 2 dòng nút bấm */

    overflow-y: auto; /* Hiện thanh cuộn dọc nếu quá dài */

    padding: 5px 2px;

    margin-bottom: 20px;

    border: 1px solid #f0f0f0; /* Viền nhẹ để phân định khu vực cuộn */

    border-radius: 8px;

    background: #fdfdfd;

}



/* Tùy chỉnh thanh cuộn cho đẹp (chỉ hiện trên Chrome/Safari/Edge) */

.ate-filters::-webkit-scrollbar {

    width: 4px;

}

.ate-filters::-webkit-scrollbar-track {

    background: #f1f1f1;

}

.ate-filters::-webkit-scrollbar-thumb {

    background: #ccc;

    border-radius: 10px;

}

.ate-filters::-webkit-scrollbar-thumb:hover {

    background: #999;

}



/* Đảm bảo các nút bấm không bị co lại */

.ate-filters .filter-btn {

    white-space: nowrap;

    flex-shrink: 0;

}



#ate-dang-filter option[style*="display: none"] {

    display: none !important;

}

.ate-reset-container {

    display: flex;

    align-items: center;

}



.ate-btn-reset {

    background-color: #f3f4f6;

    color: #4b5563;

    border: 1px solid #d1d5db;

    padding: 8px 16px;

    border-radius: 8px;

    font-size: 14px;

    font-weight: 500;

    cursor: pointer;

    transition: all 0.2s;

    white-space: nowrap;

}



.ate-btn-reset:hover {

    background-color: #e5e7eb;

    color: #1f2937;

    border-color: #9ca3af;

}



/* Responsive cho mobile */

@media (max-width: 900px) {

    .ate-reset-container {

        width: 100%;

    }

    .ate-btn-reset {

        width: 100%;

        text-align: center;

        padding: 12px;

    }

}

/* =================================================================== */
/* FIX LỖI HIỂN THỊ MATHJAX (GHI ĐÈ DỮ LIỆU TỰ ĐỘNG)                 */
/* =================================================================== */

/* Ghi đè class mjx-container để không bị nhảy dòng (display: block) */
mjx-container[jax="CHTML"][display="true"] {
    display: inline-block !important; /* Thay đổi từ block thành inline-block */
    text-align: left !important;      /* Căn trái thay vì căn giữa */
    margin: 0px 5px !important;       /* Giảm khoảng cách thừa */
}

/* Đảm bảo công thức nằm đúng hàng với văn bản xung quanh */
.question-content mjx-container, 
.answers-list mjx-container {
    vertical-align: middle;
}


/* =================================================================== */
/* CSS CHO KHỐI GIẢI THÍCH (REVIEW MODE)                             */
/* =================================================================== */
.ate-explanation-box {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8faff; /* Màu xanh nhạt nhẹ */
    border-left: 4px solid #3b82f6; /* Viền xanh đậm bên trái */
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
    text-align: justify;
}

.ate-explanation-box .explanation-title {
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 8px;
    font-size: 15px;
    display: flex;
    align-items: center;
}

.ate-explanation-box .explanation-content {
    font-size: 15px;
    line-height: 1.6;
    color: #4b5563;
    /* Code mới thêm bên dưới */
    white-space: pre-wrap;       /* Giữ nguyên các dấu xuống dòng và dòng trống */
    word-wrap: break-word;       /* Tránh việc text quá dài bị tràn ra ngoài */
    display: block;              /* Đảm bảo nó là khối văn bản */
}

/* Tùy chỉnh màu sắc giải thích theo theme nếu muốn */
.theme-forest .ate-explanation-box { background-color: #f0fdf4; border-left-color: #16a34a; }
.theme-forest .explanation-title { color: #166534; }

.theme-ruby .ate-explanation-box { background-color: #fff1f2; border-left-color: #e11d48; }
.theme-ruby .explanation-title { color: #9f1239; }

/* CSS Spinner dành cho các nút chuyển trạng thái */
.ate-start-btn .button-spinner, 
.review-answers-btn .button-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ate-spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Nút bị disabled khi đang load */
.ate-start-btn:disabled, 
.review-answers-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

@keyframes ate-spin {
    to { transform: rotate(360deg); }
}

/* Tối ưu cho câu hỏi tự luận */
.iaeb-type-essay .question-content {
    font-weight: 500;
    border-left: 3px solid #ccc;
    padding-left: 15px;
    margin-bottom: 25px;
}

.essay-note {
    font-size: 0.9em;
    background: #f9f9f9;
    padding: 8px 12px;
    border-radius: 4px;
    display: inline-block;
}

/* Tăng chiều cao vùng đọc đề môn Văn nếu dùng layout reading-sticky */
.layout-reading-sticky .quiz-reading-passage-sticky {
    height: 30vh; /* Tăng lên cho dễ đọc thơ/văn */
}

.layout-reading-sticky .reading-bottom-section .ate-sidebar {
    top: calc(45vh + 32px + 30px);
}

.ate-year-filter-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

#ate-year-filter {
    min-width: 110px;
    padding: 8px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    background-color: #fff;
    font-weight: 500;
}

#ate-year-filter:focus {
    outline: none;
    border-color: var(--ate-primary-color, #475569);
}

/* Mobile responsive */
@media (max-width: 900px) {
    .ate-year-filter-container { width: 100%; }
    #ate-year-filter { width: 100%; }
}

/* =================================================================== */
/* CSS ACCORDION CHO TÀI LIỆU SOẠN VĂN / VĂN MẪU                     */
/* =================================================================== */
.ate-study-document {
    margin-top: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.ate-doc-set-item {
    border-bottom: 1px solid #e5e7eb;
}
.ate-doc-set-item:last-child {
    border-bottom: none;
}
.ate-doc-set-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f9fafb;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.ate-doc-set-header:hover {
    background: #f3f4f6;
}
.ate-doc-set-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ate-doc-toggle-icon {
    font-size: 11px;
    color: #9ca3af;
    transition: transform 0.2s ease-in-out;
}
.ate-doc-set-item.active .ate-doc-toggle-icon {
    transform: rotate(90deg);
}
.ate-doc-set-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}
.ate-doc-set-tag {
    font-size: 11px;
    font-weight: 600;
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 10px;
    border-radius: 99px;
    white-space: nowrap;
}
.ate-doc-toggle-btn {
    background: #fff;
    border: 1px solid #d1d5db;
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s;
    white-space: nowrap;
}
.ate-doc-toggle-btn:hover {
    border-color: var(--ate-primary-color, #475569);
    color: var(--ate-primary-color, #475569);
}
.ate-doc-set-body {
    padding: 20px;
    border-top: 1px solid #f3f4f6;
    background: #fff;
}

/* Hình ảnh trong bài viết Văn mẫu / Soạn văn */
.ate-doc-image {
    text-align: center;
    margin: 20px 0;
}
.ate-doc-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    display: inline-block;
}

/* =================================================================== */
/* CSS PHÂN HỆ ACCORDION & MỤC LỤC CHI TIẾT                          */
/* =================================================================== */
.ate-doc-toc {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
}
.ate-doc-toc-title {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ate-primary-color, #475569);
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
}
.ate-doc-toc-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
.ate-doc-toc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}
.ate-doc-toc-item:hover {
    border-color: var(--ate-primary-color, #475569);
    color: var(--ate-primary-color, #475569);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.ate-toc-lock { color: #ef4444; font-size: 10px; }
.ate-toc-unlock { color: #10b981; font-size: 10px; }

.ate-doc-header-lock-icon {
    font-size: 11px;
    font-weight: 600;
    background: #fee2e2;
    color: #ef4444;
    padding: 2px 8px;
    border-radius: 99px;
    white-space: nowrap;
}
.ate-doc-header-lock-icon.unlocked {
    background: #d1fae5;
    color: #10b981;
}

/* 1. Sửa lỗi ẩn nút sao chép (Chỉ ẩn khi CHƯA có class .unlocked VÀ Admin đang BẬT khóa) */
.ate-task-enabled .ate-locked-wrapper:not(.unlocked) .ate-copy-container {
    display: none !important;
}

/* 2. Làm đẹp nút Sao chép */
.ate-doc-copy-btn:hover {
    background: var(--ate-primary-color, #475569) !important;
    color: #fff !important;
    border-color: var(--ate-primary-color, #475569) !important;
}

/* 3. Căn đều hai bên (Justify) cho nội dung bài học */
.ate-locked-content, 
.ate-unlocked-content, 
.ate-document-teaser {
    text-align: justify !important;
    line-height: 1.8 !important;
}

/* 4. Tối ưu giao diện Header Accordion trên các thiết bị Mobile & Tablet */
@media (max-width: 768px) {
    .ate-doc-set-header {
        flex-wrap: wrap !important;
        gap: 12px !important;
        padding: 15px !important;
    }
    
    .ate-doc-set-title-group {
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .ate-doc-set-title {
        font-size: 14.5px !important;
        width: 100% !important; /* Đẩy các thẻ tag và icon khóa xuống dòng độc lập */
        order: -1 !important; /* Đảm bảo tiêu đề luôn đứng trước */
        line-height: 1.5 !important;
    }
    
    .ate-doc-set-tag, 
    .ate-doc-header-lock-icon {
        font-size: 10px !important;
        padding: 2px 8px !important;
    }
    
    .ate-doc-toggle-btn {
        width: 100% !important; /* Trải rộng nút "Xem bài" toàn màn hình mobile để dễ bấm */
        text-align: center !important;
        margin-top: 5px !important;
    }
}

/* =================================================================== */
/* CSS PHÂN HỆ ACCORDION & KHUNG KHÓA AN TOÀN (ĐÃ FIX TRÀN KHUNG)    */
/* =================================================================== */
.ate-locked-wrapper {
    position: relative !important;
    margin-top: 15px !important;
    min-height: 200px !important; /* Thiết lập chiều cao tối thiểu để vừa vặn với Khung khóa */
    box-sizing: border-box !important;
}

/* Khi đã mở khóa thì xóa chiều cao tối thiểu */
.ate-locked-wrapper.unlocked,
.ate-task-disabled .ate-locked-wrapper {
    min-height: 0 !important;
}

/* Lớp phủ chuyển mờ và định vị khung khóa lên hàng đầu */
.ate-lock-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important; /* Căn giữa theo chiều dọc */
    justify-content: center !important;
    box-sizing: border-box !important;
    z-index: 99 !important;
    padding: 10px !important;
}

/* Hộp thoại nhiệm vụ mở khóa gọn gàng hơn */
.ate-lock-box {
    text-align: center !important;
    padding: 15px 20px !important; /* Thu gọn padding để không bị tràn */
    background: #fff !important;
    border: 2px solid var(--ate-primary-color, #475569) !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08) !important;
    max-width: 420px !important;
    width: 95% !important;
    z-index: 100 !important;
    position: relative !important;
    box-sizing: border-box !important;
}

.ate-lock-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #1f2937 !important;
    margin: 0 0 6px 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
}

.ate-lock-desc {
    font-size: 13px !important;
    color: #4b5563 !important;
    margin: 0 0 12px 0 !important;
    line-height: 1.4 !important;
}

/* Hiệu ứng mờ văn bản và giới hạn chiều cao chống tràn trang */
.ate-locked-content {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
    max-height: 180px; /* Thu gọn chiều cao làm mờ */
    overflow: hidden;
    transition: all 0.3s ease-in-out;
}

/* Khi wrapper cha có class .unlocked, HOẶC khi Admin đang TẮT nhiệm vụ (.ate-task-disabled) -> Giải phóng mờ */
.ate-locked-wrapper.unlocked .ate-locked-content,
.ate-task-disabled .ate-locked-content {
    filter: none !important;
    pointer-events: auto !important;
    user-select: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Tự động ẨN hoàn toàn Hộp nhiệm vụ khi Admin TẮT nhiệm vụ */
.ate-task-disabled .ate-lock-overlay {
    display: none !important;
}

/* Đổi icon "Khóa" thành "Mở khóa" trên tiêu đề khi Admin TẮT nhiệm vụ */
.ate-task-disabled .ate-doc-header-lock-icon {
    background: #d1fae5 !important;
    color: #10b981 !important;
    font-size: 0 !important; /* Ẩn chữ cũ */
}
.ate-task-disabled .ate-doc-header-lock-icon::after {
    content: "🔓 Đã mở khóa";
    font-size: 11px;
}
.ate-task-disabled .ate-toc-lock {
    display: none !important;
}
/* Ẩn triệt để nút Sao chép bị trùng lặp ở đoạn nội dung khóa */
.ate-locked-content .ate-copy-container,
.ate-doc-set-body .ate-copy-container ~ .ate-copy-container {
    display: none !important;
}
/* Định dạng tiêu đề bài viết chuẩn H1 cho cả Mobile và Desktop */
.ate-header h1.ate-doc-main-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--ate-primary-color, #475569);
    text-align: center;
    flex-grow: 1;
    line-height: 1.4;
}

/* Khi đang xem chi tiết bài học (?phan=...), ẩn H1 mặc định của theme để tránh bị trùng lặp 2 thẻ H1 */
body.ate-single-phan-active .entry-header .entry-title,
body.ate-single-phan-active h1.entry-title,
body.ate-single-phan-active h1.page-title {
    display: none !important;
}

@media (max-width: 768px) {
    .ate-header h1.ate-doc-main-title {
        font-size: 18px;
    }
}
