/* assets/css/quiz-styles.css */

/* --- 1. BASE & CONTAINER --- */
.wpqib-quiz-container {
    max-width: 850px;
    margin: 0 auto;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.wpqib-quiz-title {
    color: #2c3e50;
    font-weight: 700;
    border-bottom: 3px solid #007bff;
    padding-bottom: 10px;
}

/* --- 2. CARD UI TRANG CHỦ (YÊU CẦU MỚI) --- */
.card-quiz {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #f0f0f0;
    padding: 24px;
    height: 100%;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.card-quiz:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.08);
    border-color: #007bff;
}

/* Badge danh mục */
.quiz-badge {
    background: #f0f7ff;
    color: #007bff;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Icons Bookmark/Heart */
.quiz-actions-top {
    display: flex;
    gap: 10px;
}
.quiz-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 50%;
    color: #adb5bd;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #eee;
}
.quiz-icon-btn:hover {
    background: #fff;
    color: #007bff;
    border-color: #007bff;
}

/* Tiêu đề đề thi (giới hạn 3 dòng) */
.card-quiz .title {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.5;
    margin: 20px 0 10px 0;
    color: #1a202c;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 5.1rem; /* Cố định chiều cao để các card đều nhau */
}

/* Rating & Lượt làm */
.quiz-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.quiz-rating {
    color: #ff9f43;
    font-weight: 700;
}

.quiz-info {
    padding-top: 15px;
    margin-top: auto;
    border-top: 1px dashed #edf2f7;
    display: flex;
    justify-content: space-between;
    color: #718096;
    font-size: 0.85rem;
}

/* --- 3. QUESTION WRAPPER (TRANG LÀM BÀI) --- */
.wpqib-question-wrapper {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    border: 1px solid #f0f0f0;
}

.wpqib-question-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #2d3748;
    margin-bottom: 20px;
    overflow-x: auto;
}

/* Đáp án */
.wpqib-option-item label {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
    background: #fff;
    position: relative;
}

.wpqib-option-item label:hover {
    background-color: #f0f7ff; /* Hơi đậm hơn một chút khi di chuột */
    border-color: #80bdff;
}

/* BỎ: .wpqib-option-item input[type="radio"]:checked + .option-text { font-weight: 600; } */

/* === BẮT ĐẦU ĐOẠN CODE MỚI CHO HIỆU ỨNG NỔI BẬT === */
.wpqib-option-item label.option-selected {
    background-color: #e7f3ff; /* Màu nền xanh dương rất nhạt */
    border-color: #007bff !important;      /* Viền màu xanh dương đậm */
    border-width: 2px;          /* Làm viền dày hơn một chút */
    box-shadow: 0 3px 10px rgba(0, 123, 255, 0.1); /* Đổ bóng xanh nhẹ nhàng */
    font-weight: 600;           /* Chữ bên trong đậm hơn */
    color: #004085;             /* Màu chữ xanh đậm hơn */
}
/* === KẾT THÚC ĐOẠN CODE MỚI === */

/* Màu review chuẩn Bootstrap */
.bg-success { background-color: #28a745 !important; color: #fff !important; }
.bg-danger { background-color: #dc3545 !important; color: #fff !important; }

/* Ép màu Review (Sửa lỗi không hiện màu) */
.wpqib-option-item label.bg-success {
    background-color: #28a745 !important;
    color: #fff !important;
    border-color: #1e7e34 !important;
    font-weight: bold;
}

.wpqib-option-item label.bg-danger {
    background-color: #dc3545 !important;
    color: #fff !important;
    border-color: #bd2130 !important;
}

/* Icon Check/X trong review */
.review-correct::after {
    content: " \f058"; 
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    float: right;
}
.review-wrong::after {
    content: " \f057"; 
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    float: right;
}

/* --- 4. KẾT QUẢ & ĐỀ LIÊN QUAN --- */
.wpqib-quiz-results-summary {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 15px 35px rgba(0,0,0,0.05);
}

.related-quizzes {
    margin-top: 50px;
    padding: 30px;
    background: #f8fafc;
    border-radius: 16px;
}

/* --- 5. MATH & RESPONSIVE --- */
mjx-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    padding: 5px 0;
}

@media (max-width: 768px) {
    .wpqib-quiz-container { padding: 10px; }
    .wpqib-score-display { flex-direction: column; }
    .card-quiz .title { height: auto; -webkit-line-clamp: 2; }
    .wpqib-final-actions .d-flex { flex-direction: column; }
    .wpqib-final-actions .btn { width: 100%; }
}

/* Icon cho Review Mode */
.wpqib-option-item label.bg-success::after {
    content: "\f058"; /* Check circle */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 20px;
    font-size: 1.2rem;
}
.wpqib-option-item label.bg-danger::after {
    content: "\f057"; /* Times circle */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 20px;
    font-size: 1.2rem;
}

/* Giao diện Card Đề liên quan */
.related-section {
    background: #ffffff;
    padding: 30px;
    border-radius: 16px;
    border: 1px solid #f0f0f0;
}

.related-card {
    background: #fff;
    border: 1px solid #edf2f7;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.related-card:hover {
    border-color: #007bff;
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.05) !important;
}

/* Card đề liên quan - Fix đồng bộ hàng ngang */
.related-title {
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    margin-bottom: 20px !important;
    display: block !important;
    height: auto !important; /* Hiện Full tiêu đề */
    color: #2d3748;
    flex-grow: 0; /* Không cho tiêu đề tự giãn nở chiếm không gian */
}

/* Ép các card trong cùng một hàng phải có độ cao bằng cái cao nhất */
.row.d-flex.align-items-stretch .col-md-4 {
    display: flex;
}

/* Phần info chứa lượt làm */
.quiz-info-mini {
    padding-top: 12px !important;
    border-top: 1px dashed #edf2f7 !important;
    display: flex;
    justify-content: flex-start; /* Căn trái icon */
    color: #718096;
    font-size: 0.8rem;
    margin-top: auto !important; /* QUAN TRỌNG: Đẩy toàn bộ cụm này xuống đáy card */
}

.related-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,123,255,0.1) !important;
}

/* Đồng bộ info lượt làm giống trang chủ */
.related-card .quiz-info-mini {
    padding-top: 10px;
    margin-top: auto; /* Đẩy phần này xuống đáy card */
    border-top: 1px dashed #edf2f7;
    display: flex;
    justify-content: space-between;
    color: #718096;
    font-size: 0.8rem;
}

.related-card .btn-outline-primary {
    border-width: 2px;
    font-size: 0.8rem;
}

.related-card .btn-outline-primary:hover {
    background-color: #007bff;
    color: #fff;
}

/* Đảm bảo các card trong hàng luôn cao bằng nhau */
.row.g-3.d-flex.align-items-stretch {
    display: flex;
    flex-wrap: wrap;
}

.related-section .card-quiz {
    padding: 20px !important; /* Tăng padding nhìn cho thoáng */
    border: 1px solid #f0f0f0 !important;
}

.related-section .card-quiz:hover {
    border-color: #007bff !important;
    box-shadow: 0 10px 20px rgba(0,123,255,0.1) !important;
}
.related-section .card-quiz h6 {
    font-size: 0.95rem;
    color: #2d3748;
}

.card { border-radius: 12px; transition: transform 0.2s; }
.card:hover { transform: translateY(-3px); }
.badge { font-weight: 500; font-size: 0.85rem; }
.bg-opacity-25 { background-color: rgba(255, 255, 255, 0.25) !important; }

/* --- TỐI ƯU TABS CĂN GIỮA & DẤU TÍCH --- */
.wpqib-tabs-nav {
    display: flex;
    justify-content: flex-start; /* SỬA Ở ĐÂY: Luôn bắt đầu từ bên trái */
    overflow-x: auto;
    gap: 10px;
    padding: 10px 0;
    scrollbar-width: none;
}

@media (max-width: 768px) {
    .wpqib-tabs-nav { justify-content: flex-start; padding-left: 10px; }
}
.wpqib-tabs-nav::-webkit-scrollbar { display: none; }

.wpqib-tab-btn {
    flex: 0 0 auto;
    padding: 8px 20px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #ddd;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}
.wpqib-tab-btn.active {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
    box-shadow: 0 4px 10px rgba(0,123,255,0.3);
}

.wpqib-tab-btn.completed {
    border-color: #28a745 !important;
    background-color: #e6fffa !important;
    color: #28a745 !important;
}
.wpqib-tab-btn.completed::after {
    content: " \f058"; /* Icon tích xanh */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

/* --- GHIM ĐỒNG HỒ TRÊN ĐẦU KHI CUỘN --- */
#wq-timer-bar {
    position: sticky;
    top: 0;
    z-index: 9999; /* Ưu tiên cao nhất để luôn nổi lên trên */
    background: #fff;
    border-bottom: 2px solid #007bff;
    padding: 8px 0;
    margin: 0 -15px 20px -15px; /* Tràn lề để ghim sát mép màn hình */
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
#wq-timer-bar span {
    font-size: 0.95rem;
    color: #333;
}

#wq-countdown {
    font-weight: 800;
    font-size: 1.1rem;
    color: #007bff;
}
/* --- MÀU REVIEW KẾT QUẢ --- */
.wpqib-option-item label.bg-success {
    background-color: #28a745 !important;
    color: #fff !important;
    border-color: #1e7e34 !important;
}
.wpqib-option-item label.bg-danger {
    background-color: #dc3545 !important;
    color: #fff !important;
    border-color: #bd2130 !important;
}

/* 4. Xóa khoảng trắng dư thừa của mô tả rỗng */
.quiz-description:empty { display: none !important; }

/* 5. Hiệu ứng chọn đáp án mượt hơn */
.wpqib-option-item label:hover { background: #f0f7ff; cursor: pointer; }
.time-warning { color: #d63031; font-weight: bold; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.5; } }

/* Tối ưu menu trang chủ mobile */
@media (max-width: 768px) {
    .navbar-brand { font-size: 1rem; }
    .card-quiz .title { height: auto; -webkit-line-clamp: 2; }
}

@media (max-width: 600px) {
    .wpqib-quiz-results-summary { padding: 15px; }
    .wpqib-score-display { flex-direction: row !important; gap: 15px; }
    .wpqib-chart-container { width: 90px !important; height: 90px !important; }
    .wpqib-score-details { font-size: 0.85rem; line-height: 1.3; }
    .wpqib-score-percentage { font-size: 1.2rem !important; }
    
    /* Làm cho các nút đáp án nhỏ gọn hơn trên Mobile */
    .wpqib-option-item label { padding: 10px 15px; font-size: 0.9rem; }
    
    /* Cố định đồng hồ trên mobile để người dùng luôn thấy */
    #wq-timer-bar {
        position: fixed;
        top: 0; left: 0; right: 0;
        border-radius: 0;
        margin: 0;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    .wpqib-quiz-container { margin-top: 60px; }
}

/* Ẩn các hộp nếu không có nội dung */
.quiz-description:empty, 
.wpqib-tabs-nav:empty,
.wpqib-explanation:empty {
    display: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Hiệu ứng ẩn hiện mượt mà cho navbar */
#main-navbar {
    transition: top 0.3s ease-in-out;
    top: 0;
}
.nav-up {
    top: -80px !important; /* Đẩy navbar lên trên màn hình */
}

/* Ẩn hoàn toàn navbar khi ở trong trang làm bài (quiz.php) */
body.page-quiz #main-navbar {
    display: none !important;
}
/* Đẩy đồng hồ sát mép trên cùng khi ẩn menu */
body.page-quiz #wq-timer-bar {
    top: 0;
    margin-top: 0;
}

/* =========================================
   DESKTOP ARROW NAVIGATION
   ========================================= */
.wpqib-tabs-wrapper {
    position: relative; /* Để định vị mũi tên tuyệt đối */
    padding: 0;
}

.wpqib-scroll-btn {
    display: none; /* Mặc định ẩn trên mobile */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    z-index: 10;
    font-size: 18px;
    color: #555;
    transition: all 0.2s ease;
}

.wpqib-scroll-btn:hover {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

.wpqib-scroll-btn.prev { left: -15px; }
.wpqib-scroll-btn.next { right: -15px; }

/* --- Cấu hình cho DESKTOP (Màn hình > 768px) --- */
@media (min-width: 768px) {
    .wpqib-tabs-wrapper {
        padding: 0 30px; /* Tạo khoảng trống 2 bên để chứa mũi tên */
    }
    /* HIỆN MŨI TÊN TRÊN DESKTOP */
    .wpqib-scroll-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    .wpqib-tabs-nav {
        scroll-behavior: smooth;
    }
}

/* =========================================
   BOTTOM NAVIGATION & ACTIONS (NEW)
   ========================================= */

/* BLOCK DANH SÁCH ĐỀ (Nổi bật hơn) */
.wpqib-bottom-nav {
    margin-top: 40px;
    padding: 25px;
    background-color: #f8f9fa; /* Nền xám nhạt */
    border: 1px solid #e9ecef;
    border-radius: 12px; /* Bo góc khung */
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); /* Đổ bóng nhẹ cho cả khối */
}

.wpqib-bottom-nav h4 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #343a40;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.wpqib-bottom-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

/* Nút đề con bên dưới */
.wpqib-bottom-btn {
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.wpqib-bottom-btn:hover {
    border-color: #007bff;
    background-color: #f0f7ff;
}

/* Trạng thái đang chọn (Active) */
.wpqib-bottom-btn.active {
    background-color: #6c757d; /* Màu xám đậm */
    color: #fff;
    border-color: #6c757d;
}

/* Trạng thái đã làm xong (Completed) */
.wpqib-bottom-btn.completed {
    background-color: #28a745; /* Màu xanh lá */
    border-color: #28a745;
    color: #fff;
    font-weight: 600;
}
.wpqib-bottom-btn.completed::after {
    content: " \2713"; /* Dấu tích trắng */
    font-weight: bold;
}

/* Vừa Active vừa Completed (Đang xem lại đề đã làm) */
.wpqib-bottom-btn.active.completed {
    background-color: #218838; /* Xanh lá đậm hơn */
    border-color: #1e7e34;
}

/* Tối ưu cho mobile */
@media (max-width: 600px) {
    .wpqib-bottom-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }
    .wpqib-bottom-btn {
        padding: 8px 10px;
        font-size: 13px;
    }
}