/**
 * /thi-nang-luc carousel — cards kéo ngang thay vì stack dọc.
 * Áp dụng cho page-template/test-template.php
 *
 * QUAN TRỌNG: CSS này ép `.swiper-slide` có width hợp lý NGAY CẢ KHI Swiper JS chưa init,
 * để tránh trường hợp 1 slide chiếm 100% rồi overflow:hidden cắt phần còn lại
 * (= triệu chứng "MIỄN PHÍ visible + blank to chiếm hết màn hình").
 */

/* ------------------------------------------------------------------ */
/* 1. CONTAINER + SWIPER VIEWPORT                                     */
/* ------------------------------------------------------------------ */
.monaExamSlider {
    position: relative;
    margin: 16px 0 24px;
    /* Reserve không gian 2 bên cho arrow buttons → KHÔNG đè lên cards */
    padding: 0 56px;
}

@media (max-width: 991px) {
    .monaExamSlider {
        padding: 0 48px;
    }
}

@media (max-width: 575px) {
    .monaExamSlider {
        padding: 0;
    }
}

.monaExamSlider .exam-cards-sw {
    overflow: hidden;
    padding: 4px 4px 4px;
    margin: 0 -4px;
}

.monaExamSlider .swiper.monaExamSwiper {
    overflow: visible; /* control button float ngoài */
    width: 100%;
    height: auto;
}

/* ------------------------------------------------------------------ */
/* 2. SLIDE WIDTH — fallback CSS (chạy được kể cả khi Swiper init lỗi) */
/* ------------------------------------------------------------------ */
.monaExamSlider .swiper-wrapper {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
}

.monaExamSlider .swiper-slide {
    /* Override Swiper-bundle default `width: 100%` của .swiper-slide */
    width: auto;
    flex: 0 0 auto;
    height: auto;
    box-sizing: border-box;
    display: flex;
}

/* Fallback width khi Swiper chưa init (sẽ bị inline style của Swiper override sau init) */
.monaExamSlider .exam-card-slide {
    width: calc((100% - 60px) / 3); /* 3 cards với 30px gap (2 gap × 30px = 60px) */
    min-width: 260px;
    margin-right: 20px;
}

.monaExamSlider .exam-card-slide:last-child {
    margin-right: 0;
}

/* Khi Swiper init xong nó set inline style transform/width — bỏ margin fallback */
.monaExamSlider .swiper-initialized .exam-card-slide {
    margin-right: 0;
}

@media (max-width: 1399px) {
    .monaExamSlider .exam-card-slide {
        width: calc((100% - 40px) / 3);
    }
}

@media (max-width: 991px) {
    .monaExamSlider .exam-card-slide {
        width: calc((100% - 20px) / 2);
    }
}

@media (max-width: 575px) {
    .monaExamSlider .exam-card-slide {
        width: 90%;
    }
}

/* Card bên trong slide phải full width slide */
.monaExamSlider .swiper-slide > * {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.monaExamSlider .swiper-slide .exq-it {
    width: 100%;
    height: 100%;
}

/* ------------------------------------------------------------------ */
/* 3. NAVIGATION CONTROL BUTTONS                                      */
/* ------------------------------------------------------------------ */
.monaExamSlider .exam-cards-control {
    position: absolute;
    top: 50%;
    /* left:0/right:0 = sit ở wrapper's padded edges (NGOÀI swiper, không đè card) */
    left: 0;
    right: 0;
    pointer-events: none;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    z-index: 5;
}

.monaExamSlider .swiper-control-btn {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #384259;
    font-size: 16px;
    border: none;
    transition: transform .2s ease, background .2s ease, color .2s ease;
}

.monaExamSlider .swiper-control-btn:hover {
    background: #384259;
    color: #fff;
    transform: scale(1.05);
}

.monaExamSlider .swiper-control-btn.swiper-button-disabled,
.monaExamSlider .swiper-control-btn.swiper-button-lock {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* 4. "Xem tất cả" BUTTON                                             */
/* ------------------------------------------------------------------ */
.exam-cards-viewall {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Closer together */
    margin: 32px auto 0;
    padding: 0 24px;
    height: 44px;
    background: #1d1d1f;
    color: #fff !important;
    border-radius: 12px;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    transition: all .25s ease;
    border: none;
    cursor: pointer;
}

.exam-cards-viewall .inner {
    line-height: 1;
    display: block;
}

.exam-cards-viewall i {
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    margin-left: 0; /* Use gap instead */
    height: 1em;
    transform: translateY(1px); /* Optical adjustment for better visual centering */
}

.exam-cards-viewall:hover {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* ------------------------------------------------------------------ */
/* 5. LOADING STATE                                                   */
/* ------------------------------------------------------------------ */
.monaExamJs.loading .monaExamHtml {
    opacity: 0.5;
    pointer-events: none;
}

/* Skeleton khi monaExamHtml empty (trước AJAX response đầu tiên) */
.monaExamJs.is-loading-exam .monaExamHtml:empty::before {
    content: "";
    display: block;
    height: 280px;
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    border-radius: 14px;
    animation: exam-skeleton-shine 1.4s infinite;
}

@keyframes exam-skeleton-shine {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ------------------------------------------------------------------ */
/* 6. GUARD: ép .crs-list.row chứa carousel hiển thị block, KHÔNG flex */
/* ------------------------------------------------------------------ */
/* .crs-list.row có display:flex từ theme — sẽ làm carousel thành flex item */
/* và có thể collapse width. Override: khi chứa monaExamSlider, dùng block. */
.crs-list.row.monaExamHtml {
    display: block;
    margin: 0;
}

.crs-list.row.monaExamHtml > .col {
    /* Hủy class .col cũ nếu có */
    width: auto;
    padding: 0;
}

/* Mobile: smaller controls, ẩn ở mobile cực nhỏ vì user swipe touch */
@media (max-width: 575px) {
    .monaExamSlider .exam-cards-control {
        display: flex; /* Force show on mobile */
        left: 0;
        right: 0;
    }
    .monaExamSlider .swiper-control-btn {
        width: 36px;
        height: 36px;
    }
    .monaExamSlider .exam-cards-sw {
        padding-bottom: 12px;
    }
}
