/* ============================================================
   library.css — Giao diện Thư viện điện tử (bản hiện đại hóa)
   PILOT: chỉ áp dụng cho phần tử nằm trong .tve-modern
   An toàn: không ghi đè toàn cục, không ảnh hưởng trang khác.
   ============================================================ */

.tve-modern {
    /* Bảng màu & biến giao diện (đổi ở đây là đổi cả theme) */
    --tve-bg: #f5f7fb;
    --tve-surface: #ffffff;
    --tve-primary: #2563eb;      /* xanh dương hiện đại */
    --tve-primary-dark: #1e40af;
    --tve-accent: #14b8a6;       /* xanh ngọc nhấn */
    --tve-text: #1f2937;
    --tve-text-muted: #6b7280;
    --tve-border: #e5e7eb;
    --tve-radius: 14px;
    --tve-radius-sm: 10px;
    --tve-shadow: 0 1px 3px rgba(16, 24, 40, .08);
    --tve-shadow-hover: 0 12px 28px rgba(16, 24, 40, .18);
    --tve-gap: 18px;

    background: var(--tve-bg);
    color: var(--tve-text);
    padding: 8px 0 40px;
    -webkit-font-smoothing: antialiased;
}

/* Khung nội dung rộng thoáng, tự co theo màn hình */
.tve-modern .content-section { padding: 10px 0; }
.tve-modern .container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
}

/* ---------- Tiêu đề mục (section title) ---------- */
.tve-modern .section-title h2 {
    font-size: clamp(18px, 2.4vw, 24px);
    font-weight: 700;
    line-height: 1.3;
    margin: 18px 0 14px;
    padding-left: 14px;
    position: relative;
    color: var(--tve-text);
}
.tve-modern .section-title h2::before {
    content: "";
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 5px; height: 1.05em;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--tve-primary), var(--tve-accent));
}
.tve-modern .section-title h2 a,
.tve-modern .section-title h2 font {
    color: var(--tve-text) !important;
    text-decoration: none;
    transition: color .15s ease;
}
.tve-modern .section-title h2 a:hover { color: var(--tve-primary) !important; }

/* ---------- Danh sách chủ đề -> dạng "chip/pill" ---------- */
.tve-modern .section-title ul {
    list-style: none;
    padding: 0; margin: 6px 0 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tve-modern .section-title ul li { margin: 0 !important; }
.tve-modern .section-title ul li a {
    display: inline-block;
    padding: 7px 14px;
    border: 1px solid var(--tve-border);
    border-radius: 999px;
    background: var(--tve-surface);
    box-shadow: var(--tve-shadow);
    transition: all .15s ease;
    text-decoration: none;
}
.tve-modern .section-title ul li a font {
    color: var(--tve-text) !important;
    font-size: 14px !important;
}
.tve-modern .section-title ul li a:hover {
    border-color: var(--tve-primary);
    background: var(--tve-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
}
.tve-modern .section-title ul li a:hover font { color: #fff !important; }

/* ============================================================
   LƯỚI SÁCH TỰ CO GIÃN
   Chỉ những .row CÓ CHỨA thẻ sách (.product-item) mới biến thành
   lưới — nhờ :has(), nên không phá vỡ hàng tiêu đề (col-md-8/4).
   Tự động: điện thoại 2-3 cột, tablet 4-5, desktop 6+.
   ============================================================ */
.tve-modern .row:has(.product-item) {
    display: grid;
    /* Số cột CỐ ĐỊNH theo màn hình để các hàng luôn đều nhau
       (12 cuốn: desktop 6 cột -> 6+6, không bị 7+5). */
    grid-template-columns: repeat(6, 1fr);
    gap: var(--tve-gap);
    margin: 0 0 26px;
}
@media (max-width: 1199px) { .tve-modern .row:has(.product-item) { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 991px)  { .tve-modern .row:has(.product-item) { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 575px)  { .tve-modern .row:has(.product-item) { grid-template-columns: repeat(2, 1fr); } }
/* Bootstrap thêm clearfix .row::before/::after; trong grid chúng biến thành
   ô lưới rỗng làm sách bị thụt sang phải 1 ô — ẩn đi. */
.tve-modern .row:has(.product-item)::before,
.tve-modern .row:has(.product-item)::after {
    content: none;
    display: none;
}
/* Vô hiệu hóa lớp cột Bootstrap cũ để lưới điều khiển bố cục */
.tve-modern .row:has(.product-item) > [class*="col-"] {
    width: auto;
    max-width: none;
    min-width: 0;            /* QUAN TRỌNG: cho ô co nhỏ hơn ảnh gốc (ảnh full-size) -> không tràn */
    padding: 0;
    float: none;
}

@media (max-width: 480px) {
    .tve-modern .row:has(.product-item) {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* FALLBACK khi trình duyệt CHƯA hỗ trợ :has() (Chrome < 105, Cốc Cốc cũ...):
   lưới grid không kích hoạt -> .row rơi về Bootstrap với lề âm -15px gây TRÀN.
   Bỏ lề âm để không tràn; cột Bootstrap (16.66%) tự xếp 6/hàng vừa khít. */
.tve-modern .content-section .row { margin-left: 0; margin-right: 0; }

/* ---------- Thẻ sách (card) hiện đại ---------- */
.tve-modern .product-item {
    background: var(--tve-surface);
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius);
    overflow: hidden;
    padding: 0 !important;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: var(--tve-shadow);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tve-modern .product-item:hover {
    transform: translateY(-6px);
    box-shadow: var(--tve-shadow-hover);
    border-color: rgba(37, 99, 235, .35);
}

/* Ảnh bìa: cố định tỉ lệ 3:4, không méo */
.tve-modern .product-thumb {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: #eef2f7;
}
.tve-modern .product-thumb a { display: block; height: 100%; }
.tve-modern .product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}
.tve-modern .product-item:hover .product-thumb img { transform: scale(1.06); }

/* Lớp phủ "Đọc ngay" khi rê chuột (nằm trong thẻ <a> nên bấm được) */
.tve-modern .product-thumb a::after {
    content: "\f06e  Đọc ngay";          /* icon con mắt + chữ */
    font-family: "FontAwesome", sans-serif;
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 9px 10px;
    text-align: center;
    font-size: 13px;
    color: #fff;
    background: linear-gradient(180deg, rgba(37,99,235,0), rgba(30,64,175,.92));
    transform: translateY(100%);
    transition: transform .2s ease;
}
.tve-modern .product-item:hover .product-thumb a::after { transform: translateY(0); }

/* Tên sách */
.tve-modern .product-content {
    border: 0 !important;
    background: transparent;
    padding: 10px 12px 14px !important;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}
/* Nhãn "Chia sẻ từ: <tên trường>" trên thẻ học liệu */
.tve-modern .product-content .tve-card-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 2px 8px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.5;
    color: #0f766e;
    background: rgba(20, 184, 166, .12);
    border-radius: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tve-modern .product-content .tve-card-tag i { font-size: 9.5px; flex: 0 0 auto; }
.tve-modern .product-content h5 {
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tve-modern .product-content h5 a {
    color: var(--tve-text);
    text-decoration: none;
    font-weight: 600;
    transition: color .15s ease;
}
.tve-modern .product-content h5 a:hover { color: var(--tve-primary); }

/* ---------- Phân trang ---------- */
.tve-modern .pagination > li > a,
.tve-modern .pagination > li > span {
    color: var(--tve-text);
    border-radius: 8px !important;
    margin: 0 3px;
    border: 1px solid var(--tve-border);
}
.tve-modern .pagination > li > a:hover {
    background: var(--tve-primary);
    color: #fff;
    border-color: var(--tve-primary);
}
.tve-modern .pagination > .active > a,
.tve-modern .pagination > .active > span {
    background: var(--tve-primary) !important;
    border-color: var(--tve-primary) !important;
    color: #fff !important;
}

/* ---------- Nút cuộn lên đầu trang ---------- */
.tve-totop {
    position: fixed;
    right: 18px; bottom: 22px;
    width: 46px; height: 46px;
    border: 0; border-radius: 50%;
    background: var(--tve-primary);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(37, 99, 235, .4);
    opacity: 0; visibility: hidden;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 9999;
}
.tve-totop.show { opacity: 1; visibility: visible; }
.tve-totop:hover { transform: translateY(-3px); background: var(--tve-primary-dark); }

/* ============================================================
   Trang Thư viện điện tử (demo): hero + khối chủ đề + chip
   ============================================================ */

/* ---------- Header mới (gọn) — chỉ trang Thư viện điện tử ---------- */
.tve-modern .tve-header {
    position: sticky; top: 0; z-index: 1000;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--tve-border);
    box-shadow: 0 1px 8px rgba(16, 24, 40, .06);
}
/* ===== Quảng cáo Google chèn vào header -> JS gắn class này -> bỏ ghim (header
   không cao lên rồi ghim che màn hình). Quảng cáo vẫn hiển thị bình thường. ===== */
.tve-modern .tve-header.tve-header--unpinned { position: static !important; }

/* ===== Trên điện thoại: header không ghim để quảng cáo (nếu lọt vào) không che màn hình ===== */
@media (max-width: 768px) {
    .tve-modern .tve-header { position: static; }
    .tve-modern .tve-header.open { max-height: 90vh; overflow-y: auto; }
}
.tve-modern .tve-header-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    flex-direction: column;     /* 2 hàng: brand+login / nav */
    gap: 8px;
}
/* Hàng trên: brand (trái) — đăng nhập (phải) */
.tve-modern .tve-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
}
/* Ô tìm kiếm */
.tve-modern .tve-search {
    flex: 1 1 280px;
    min-width: 150px;
    max-width: 480px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 16px;
    background: var(--tve-bg);
    border: 1px solid var(--tve-border);
    border-radius: 999px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.tve-modern .tve-search i { color: var(--tve-text-muted); font-size: 14px; }
.tve-modern .tve-search input {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--tve-text);
}
.tve-modern .tve-search:focus-within {
    border-color: var(--tve-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
    background: var(--tve-surface);
}
.tve-modern .tve-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex: 0 1 auto;
    min-width: 0;            /* cho phép tên dài bị cắt … thay vì đẩy giãn */
}
.tve-modern .tve-brand-logo {
    width: 40px; height: 40px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center; justify-content: center;
    color: #fff; font-size: 19px;
    background: linear-gradient(135deg, var(--tve-primary), var(--tve-accent));
    box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}
/* Biến thể logo bằng ảnh (vd logo2.png khi không có tenant) */
.tve-modern .tve-brand-logo-img {
    background: none;
    box-shadow: none;
    border-radius: 0;
    width: auto;
}
.tve-modern .tve-brand-logo-img img {
    height: 40px;
    width: auto;
    display: block;
}
.tve-modern .tve-brand-name {
    font-weight: 800;
    font-size: 17px;
    color: var(--tve-text);
    line-height: 1.2;
    max-width: 60vw;            /* hàng riêng nên thoải mái hơn */
    white-space: nowrap;        /* luôn 1 dòng */
    overflow: hidden;
    text-overflow: ellipsis;    /* tên dài hiển thị … */
}
/* Hàng dưới: nav 6 chủ đề, full-width nên luôn đủ chỗ */
.tve-modern .tve-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    border-top: 1px solid var(--tve-border);
    padding-top: 8px;
    margin-top: 2px;
}
.tve-modern .tve-nav a {
    padding: 8px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--tve-text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: all .15s ease;
}
.tve-modern .tve-nav a:hover {
    color: var(--tve-primary);
    background: rgba(37, 99, 235, .08);
}
/* 2 nút truy cập nhanh trong hàng menu (dồn về phải, dạng pill) */
.tve-modern .tve-nav a.tve-nav-cta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 999px;
    color: var(--tve-primary);
    background: rgba(37, 99, 235, .08);
    border: 1px solid var(--tve-border);
}
.tve-modern .tve-nav a.tve-nav-cta:hover {
    background: var(--tve-primary);
    color: #fff;
    border-color: var(--tve-primary);
}
.tve-modern .tve-nav a.tve-nav-cta-first { margin-left: auto; }
.tve-modern .tve-nav a.tve-nav-cta.tve-nav-cta-active {
    background: var(--tve-primary);
    color: #fff;
    border-color: var(--tve-primary);
}

/* ---------- Dropdown "Hoạt động thư viện" trong nav ---------- */
.tve-modern .tve-dropdown { position: relative; display: inline-flex; }
.tve-modern .tve-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 0;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--tve-text-muted);
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s ease;
}
.tve-modern .tve-dropdown-toggle:hover,
.tve-modern .tve-dropdown.open .tve-dropdown-toggle {
    color: var(--tve-primary);
    background: rgba(37, 99, 235, .08);
}
.tve-modern .tve-dropdown-toggle .tve-caret { font-size: 12px; opacity: .7; transition: transform .15s ease; }
.tve-modern .tve-dropdown.open .tve-dropdown-toggle .tve-caret { transform: rotate(180deg); }
.tve-modern .tve-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1200;
    min-width: 248px;
    padding: 6px;
    background: var(--tve-surface);
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius-sm);
    box-shadow: var(--tve-shadow-hover);
    display: none;
    flex-direction: column;
}
/* Cầu nối trong suốt che khe hở 8px để rê chuột từ nút xuống menu không bị mất hover */
.tve-modern .tve-dropdown-menu::before {
    content: "";
    position: absolute;
    top: -10px; left: 0; right: 0;
    height: 12px;
}
.tve-modern .tve-dropdown:hover .tve-dropdown-menu,
.tve-modern .tve-dropdown.open .tve-dropdown-menu { display: flex; }
.tve-modern .tve-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--tve-text);
    text-decoration: none;
    white-space: nowrap;
}
.tve-modern .tve-dropdown-menu a i { width: 16px; text-align: center; color: var(--tve-primary); }
.tve-modern .tve-dropdown-menu a:hover { background: rgba(37, 99, 235, .08); color: var(--tve-primary); }

@media (max-width: 720px) {
    /* Trên mobile (nav mở dọc): dropdown trải phẳng, không đè lên nội dung */
    .tve-modern .tve-dropdown { display: block; width: 100%; }
    .tve-modern .tve-dropdown-toggle { width: 100%; justify-content: flex-start; }
    .tve-modern .tve-dropdown-menu {
        position: static;
        box-shadow: none;
        border: 0;
        padding: 0 0 0 16px;
        min-width: 0;
    }
    .tve-modern .tve-dropdown:hover .tve-dropdown-menu { display: none; }
    .tve-modern .tve-dropdown.open .tve-dropdown-menu { display: flex; }
}
.tve-modern .tve-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}
.tve-modern .tve-login {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 999px;
    background: var(--tve-primary);
    color: #fff !important;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all .15s ease;
}
.tve-modern .tve-login:hover { background: var(--tve-primary-dark); }
.tve-modern .tve-myshelf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--tve-text);
    text-decoration: none;
    padding: 7px 12px;
    border: 1px solid var(--tve-border);
    border-radius: 999px;
}
.tve-modern .tve-myshelf:hover { border-color: var(--tve-primary); color: var(--tve-primary); }
.tve-modern .tve-user {
    font-size: 13.5px;
    color: var(--tve-text);
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.tve-modern .tve-logout {
    color: var(--tve-text-muted);
    text-decoration: none;
    font-size: 16px;
    padding: 6px 8px;
}
.tve-modern .tve-logout:hover { color: #dc2626; }
.tve-modern .tve-nav-toggle {
    display: none;
    border: 1px solid var(--tve-border);
    background: var(--tve-surface);
    border-radius: 9px;
    width: 42px; height: 40px;
    font-size: 18px;
    color: var(--tve-text);
    cursor: pointer;
    flex: 0 0 auto;
}

/* Màn hình hẹp: gập nav (hàng dưới) vào nút hamburger */
@media (max-width: 1024px) {
    .tve-modern .tve-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .tve-modern .tve-brand-name { font-size: 15px; }
    .tve-modern .tve-nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }
    .tve-modern .tve-header.open .tve-nav { display: flex; }
    .tve-modern .tve-nav a { padding: 11px 12px; }
    /* CTA về dạng item full-width trong menu xổ dọc */
    .tve-modern .tve-nav a.tve-nav-cta { justify-content: center; }
    .tve-modern .tve-nav a.tve-nav-cta-first { margin-left: 0; margin-top: 4px; }
}

/* ---------- Footer mới (đồng bộ) — chỉ trang Thư viện điện tử ---------- */
.tve-modern .tve-footer {
    margin-top: 26px;
    background: #0f172a;
    color: #cbd5e1;
}
.tve-modern .tve-footer-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 36px 16px 26px;
    display: grid;
    grid-template-columns: 1.4fr 1fr 1.4fr;
    gap: 28px;
}
@media (max-width: 768px) {
    .tve-modern .tve-footer-inner { grid-template-columns: 1fr; gap: 22px; }
}
.tve-modern .tve-foot-brand {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.tve-modern .tve-foot-brand strong {
    color: #fff;
    font-size: 16px;
    display: block;
    line-height: 1.3;
}
.tve-modern .tve-foot-brand p {
    margin: 4px 0 0;
    font-size: 13.5px;
    color: #94a3b8;
}
.tve-modern .tve-footer h4 {
    color: #fff;
    font-size: 15px;
    margin: 0 0 12px;
    font-weight: 700;
}
.tve-modern .tve-footer p {
    margin: 0 0 8px;
    font-size: 13.5px;
    line-height: 1.55;
}
.tve-modern .tve-foot-stat {
    font-size: 15px !important;
    color: #e2e8f0 !important;
}
.tve-modern .tve-foot-stat b {
    color: var(--tve-accent);
    font-size: 20px;
}
.tve-modern .tve-footer i { color: var(--tve-accent); margin-right: 6px; }
.tve-modern .tve-footer a { color: #93c5fd; text-decoration: none; }
.tve-modern .tve-footer a:hover { text-decoration: underline; }
.tve-modern .tve-footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, .08);
    text-align: center;
    padding: 16px;
    font-size: 13px;
    color: #94a3b8;
}

/* ---------- Banner đơn vị (carousel ảnh, giống bản cũ) ---------- */
.tve-modern .tve-banner {
    position: relative;
    z-index: 0;                 /* nhốt z-index nội bộ của owl-carousel xuống dưới header */
    margin: 0 0 26px;
    border-radius: var(--tve-radius);
    overflow: hidden;
    box-shadow: var(--tve-shadow);
    background: #eef2f7;
}
.tve-modern .tve-banner .owl-carousel .item img,
.tve-modern .tve-banner img {
    width: 100%;
    height: auto;
    /* Ảnh banner mặc định 1600x400. Nếu trường tải ảnh to/cao quá -> co lại cho
       vừa khung (giữ tỷ lệ, không méo, không tràn); ảnh thường (cao <=400px)
       vẫn hiển thị như mặc định. */
    max-height: 400px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* ---------- Trang chủ đề con: breadcrumb + tiêu đề + phân trang ---------- */
.tve-modern .tve-pagehead { margin: 4px 0 22px; }
.tve-modern .tve-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--tve-text-muted);
    margin-bottom: 12px;
}
.tve-modern .tve-crumb a { color: var(--tve-primary); text-decoration: none; }
.tve-modern .tve-crumb a:hover { text-decoration: underline; }
.tve-modern .tve-crumb i { color: var(--tve-text-muted); font-size: 12px; }
.tve-modern .tve-crumb span { color: var(--tve-text); font-weight: 600; }
.tve-modern .tve-pagetitle {
    margin: 0;
    font-size: clamp(20px, 3vw, 28px);
    font-weight: 800;
    color: var(--tve-text);
    line-height: 1.25;
}
.tve-modern .tve-pagecount {
    margin: 8px 0 0;
    color: var(--tve-text-muted);
    font-size: 14px;
}
.tve-modern .tve-pagecount i { color: var(--tve-primary); margin-right: 6px; }
.tve-modern .tve-scope-clear {
    margin: 8px 0 0;
    font-size: 13.5px;
    color: var(--tve-text-muted);
}
.tve-modern .tve-scope-clear i { color: var(--tve-accent); margin-right: 5px; }
.tve-modern .tve-scope-clear a { color: var(--tve-primary); text-decoration: none; font-weight: 600; }
.tve-modern .tve-scope-clear a:hover { text-decoration: underline; }
.tve-modern .tve-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 6px 0 32px;
}
.tve-modern .tve-pager a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--tve-border);
    background: var(--tve-surface);
    color: var(--tve-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--tve-shadow);
    transition: all .15s ease;
}
.tve-modern .tve-pager a:hover {
    background: var(--tve-primary);
    color: #fff;
    border-color: var(--tve-primary);
}
.tve-modern .tve-pager-info { font-size: 14px; color: var(--tve-text-muted); }

/* Khối "Chủ đề liên quan" trong trang chủ đề con */
.tve-modern .tve-related { margin: 0 0 24px; }
.tve-modern .tve-related-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--tve-text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* Khử nền xanh kiểu cũ của .section-title khi nằm trong theme mới (giaibaitap, hoclieu...) */
.tve-modern .section-title h2 { background: transparent !important; }

/* Trang Giới thiệu thư viện */
.tve-modern .tve-gioithieu {
    background: var(--tve-surface);
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius);
    box-shadow: var(--tve-shadow);
    padding: 22px 24px;
    margin-bottom: 28px;
}
.tve-modern .tve-gioithieu img {
    max-width: 100%;
    height: auto;
    border-radius: var(--tve-radius-sm);
    margin: 0 auto 18px;
    display: block;
}

/* Lưới video hoạt động — khung 16:9 responsive */
.tve-modern .tve-video-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 28px;
}
@media (max-width: 991px) { .tve-modern .tve-video-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .tve-modern .tve-video-grid { grid-template-columns: 1fr; } }
.tve-modern .tve-video-card {
    background: var(--tve-surface);
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius);
    overflow: hidden;
    box-shadow: var(--tve-shadow);
}
.tve-modern .tve-video-embed {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}
.tve-modern .tve-video-embed iframe,
.tve-modern .tve-video-embed video,
.tve-modern .tve-video-embed embed,
.tve-modern .tve-video-embed object {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    border: 0;
}

/* ---------- Trang Đăng nhập ---------- */
.tve-modern .tve-auth { display: flex; justify-content: center; padding: 30px 0 50px; }
.tve-modern .tve-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--tve-surface);
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius);
    box-shadow: var(--tve-shadow-hover);
    padding: 30px 28px 26px;
}
.tve-modern .tve-auth-head { text-align: center; margin-bottom: 22px; }
.tve-modern .tve-auth-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tve-primary), var(--tve-primary-dark));
    color: #fff;
    font-size: 30px;
    margin-bottom: 12px;
}
.tve-modern .tve-auth-head h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--tve-text); }
.tve-modern .tve-auth-head p { margin: 6px 0 0; font-size: 13.5px; color: var(--tve-text-muted); }
.tve-modern .tve-field {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius-sm);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.tve-modern .tve-field:focus-within { border-color: var(--tve-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.tve-modern .tve-field > i { width: 42px; text-align: center; color: var(--tve-text-muted); flex: 0 0 auto; }
.tve-modern .tve-field input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 12px 12px 12px 0;
    font-size: 15px;
    color: var(--tve-text);
    min-width: 0;
}
.tve-modern .tve-field-select { padding: 3px 4px; }
.tve-modern .tve-auth-btn { width: 100%; justify-content: center; margin-top: 6px; cursor: pointer; }

/* select2 trong form đăng nhập khớp theme */
.tve-modern .tve-field-select .select2-container { width: 100% !important; }
.tve-modern .tve-field-select .select2-container--default .select2-selection--single {
    border: 0;
    height: 38px;
    display: flex;
    align-items: center;
    background: transparent;
}
.tve-modern .tve-field-select .select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-left: 8px;
    color: var(--tve-text);
}
.tve-modern .tve-field-select .select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }

/* Thanh công cụ: phân trang (trái) + chọn số bản ghi (phải) — trang Học liệu */
.tve-modern .tve-toolbar { margin: 4px 0 20px; }
.tve-modern .tve-toolbar::before,
.tve-modern .tve-toolbar::after { content: none; display: none; }
.tve-modern .tve-toolbar .pagination-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
    float: none;
    padding: 0;
    margin: 0;
}
.tve-modern .tve-toolbar .pagination { margin: 0; }
.tve-modern .tve-toolbar .pagination-wrap > div { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.tve-modern .tve-toolbar select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--tve-border);
    background: #fff;
    font-size: 13.5px;
    color: var(--tve-text);
}
.tve-modern .tve-chip.tve-chip-active {
    background: var(--tve-primary);
    border-color: var(--tve-primary);
    color: #fff;
    cursor: default;
}
.tve-modern .tve-chip.tve-chip-active .num {
    background: rgba(255, 255, 255, .25);
    color: #fff;
}
/* Chip nổi bật (stt_highlight) */
.tve-modern .tve-chip.tve-chip-hl {
    border-color: #f59e0b;
    color: #b45309;
    background: #fffbeb;
}
.tve-modern .tve-chip.tve-chip-hl .num { background: rgba(245, 158, 11, .18); color: #b45309; }
.tve-modern .tve-chip.tve-chip-hl:hover { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.tve-modern .tve-chip.tve-chip-hl:hover .num { background: rgba(255, 255, 255, .3); color: #fff; }

/* ---------- Hero giới thiệu (fallback cũ, hiện không dùng) ---------- */
.tve-modern .tve-hero {
    background: linear-gradient(120deg, var(--tve-primary), var(--tve-accent));
    color: #fff;
    border-radius: var(--tve-radius);
    padding: clamp(22px, 4vw, 40px) clamp(20px, 4vw, 44px);
    margin: 10px 0 28px;
    box-shadow: var(--tve-shadow);
}
.tve-modern .tve-hero h1 {
    margin: 0 0 8px;
    font-size: clamp(24px, 4vw, 38px);
    font-weight: 800;
    line-height: 1.2;
}
.tve-modern .tve-hero p {
    margin: 0;
    max-width: 680px;
    font-size: clamp(14px, 1.8vw, 17px);
    opacity: .95;
    line-height: 1.55;
}

/* ---------- Khối "Thành tích cá nhân" (học sinh / giáo viên) ---------- */
.tve-modern .tve-stats {
    background: linear-gradient(135deg, var(--tve-primary), var(--tve-primary-dark));
    color: #fff;
    border-radius: var(--tve-radius);
    box-shadow: var(--tve-shadow);
    padding: 16px 18px;
    margin: 4px 0 22px;
}
.tve-modern .tve-stats-head {
    font-size: 15px;
    margin-bottom: 14px;
    opacity: .95;
}
.tve-modern .tve-stats-head i { margin-right: 6px; color: #fde68a; }
.tve-modern .tve-stats-head b { font-weight: 700; }
.tve-modern .tve-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.tve-modern .tve-stat {
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: var(--tve-radius-sm);
    padding: 12px 14px;
    text-align: center;
}
.tve-modern .tve-stat-num {
    display: block;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
}
.tve-modern .tve-stat-lbl {
    display: block;
    margin-top: 4px;
    font-size: 12.5px;
    opacity: .9;
}
@media (max-width: 700px) {
    .tve-modern .tve-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Khối 1 chủ đề lớn ---------- */
.tve-modern .tve-cat { margin-bottom: 34px; }
.tve-modern .tve-cat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 14px;
}
.tve-modern .tve-cat-head .tve-cat-icon {
    flex: 0 0 auto;
    width: 42px; height: 42px;
    display: inline-flex;
    align-items: center; justify-content: center;
    border-radius: 12px;
    color: #fff;
    font-size: 19px;
    background: linear-gradient(135deg, var(--tve-primary), var(--tve-accent));
    box-shadow: 0 4px 12px rgba(37, 99, 235, .28);
}
.tve-modern .tve-cat-head h2 {
    flex: 1 1 auto;
    margin: 0;
    font-size: clamp(18px, 2.4vw, 24px);
    font-weight: 700;
    line-height: 1.25;
    padding: 0;
}
.tve-modern .tve-cat-head h2::before { content: none; }
.tve-modern .tve-cat-head h2 a {
    color: var(--tve-text) !important;
    text-decoration: none;
}
.tve-modern .tve-cat-head h2 a:hover { color: var(--tve-primary) !important; }
/*
 * SỐ TÀI LIỆU của cả chủ đề lớn. `flex: 0 0 auto` + `nowrap` để không bị bẻ
 * xuống hai dòng khi tên chủ đề dài — h2 bên cạnh đã là `flex: 1 1 auto` nên
 * chính nó là phần nhường chỗ.
 */
.tve-modern .tve-cat-head .tve-cat-count {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--tve-text-muted);
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--tve-bg);
    border: 1px solid var(--tve-border);
}
/* Tổng của cả kho, ngay dưới tiêu đề trang chủ. */
.tve-modern .tve-home-count {
    margin: 0 0 18px;
    font-size: 14px;
    color: var(--tve-text-muted);
}
.tve-modern .tve-home-count b { color: var(--tve-primary); font-size: 16px; }
.tve-modern .tve-home-count .fa { margin-right: 6px; opacity: .7; }

/* Nút "Xem tất cả" dạng pill */
.tve-modern .tve-seeall {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--tve-primary);
    text-decoration: none;
    padding: 7px 14px;
    border: 1px solid var(--tve-border);
    border-radius: 999px;
    background: var(--tve-surface);
    white-space: nowrap;
    transition: all .15s ease;
}
.tve-modern .tve-seeall:hover {
    background: var(--tve-primary);
    color: #fff;
    border-color: var(--tve-primary);
}

/* ---------- Chủ đề con (chip / pill) ---------- */
.tve-modern .tve-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin: 0 0 18px;
}
.tve-modern .tve-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--tve-text);
    text-decoration: none;
    padding: 7px 13px;
    border: 1px solid var(--tve-border);
    border-radius: 999px;
    background: var(--tve-surface);
    box-shadow: var(--tve-shadow);
    transition: all .15s ease;
}
.tve-modern .tve-chip:hover {
    border-color: var(--tve-primary);
    color: var(--tve-primary);
    transform: translateY(-2px);
}
.tve-modern .tve-chip .num {
    display: inline-flex;
    align-items: center; justify-content: center;
    min-width: 20px; height: 20px;
    padding: 0 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--tve-primary-dark);
    background: rgba(37, 99, 235, .12);
    border-radius: 999px;
}
.tve-modern .tve-chip:hover .num {
    background: var(--tve-primary);
    color: #fff; 
}

.tve-modern .tve-empty {
    color: var(--tve-text-muted);
    font-style: italic;
    margin: 4px 0 18px;
}

/* Mobile: đầu khối xuống dòng gọn gàng */
@media (max-width: 560px) {
    .tve-modern .tve-cat-head { flex-wrap: wrap; }
    .tve-modern .tve-cat-head h2 { flex: 1 1 auto; }
    .tve-modern .tve-seeall { order: 3; }
}

/* ============================================================
   Trang CHI TIẾT 1 quyển sách (.tve-detail)
   ============================================================ */
.tve-modern .tve-detail {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    background: var(--tve-surface);
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius);
    box-shadow: var(--tve-shadow);
    padding: 24px;
    margin-bottom: 30px;
}
.tve-modern .tve-detail-media {
    flex: 0 0 280px;
    max-width: 280px;
}
.tve-modern .tve-detail-cover {
    position: relative;
    border-radius: var(--tve-radius-sm);
    overflow: hidden;
    border: 1px solid var(--tve-border);
    background: #f3f4f6;
}
.tve-modern .tve-detail-cover img {
    display: block;
    width: 100%;
    height: auto;
}
.tve-modern .tve-detail-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 4px 0 20px;
}
.tve-modern .tve-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: var(--tve-radius-sm);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all .15s ease;
}
.tve-modern .tve-btn-read {
    background: linear-gradient(180deg, var(--tve-primary), var(--tve-primary-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .28);
}
.tve-modern .tve-btn-read:hover { filter: brightness(1.06); color: #fff; }
.tve-modern .tve-btn-ghost {
    background: #fff;
    color: var(--tve-primary);
    border-color: var(--tve-border);
}
.tve-modern .tve-btn-ghost:hover { border-color: var(--tve-primary); background: #f0f6ff; }
.tve-modern .tve-btn-disabled {
    color: var(--tve-text-muted);
    background: #f3f4f6;
    cursor: default;
}
/* QR đè lên góc dưới-phải bìa sách, dạng thẻ nhỏ nền trắng nổi khối */
.tve-modern .tve-detail-qr {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius-sm);
    box-shadow: 0 4px 14px rgba(16, 24, 40, .28);
    line-height: 0;
    transition: transform .15s ease;
}
.tve-modern .tve-detail-qr:hover { transform: scale(1.45); transform-origin: bottom right; }
.tve-modern .tve-detail-qr img {
    width: 78px;
    height: 78px;
    display: block;
}
@media (max-width: 480px) {
    .tve-modern .tve-detail-qr img { width: 62px; height: 62px; }
}
.tve-modern .tve-detail-actions .tve-detail-expired { flex: 1 1 100%; }
.tve-modern .tve-detail-expired {
    color: #b45309;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--tve-radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    margin: 0;
}
.tve-modern .tve-detail-info { flex: 1 1 auto; min-width: 0; }
.tve-modern .tve-detail-title {
    margin: 4px 0 12px;
    font-size: clamp(20px, 3vw, 28px);
    font-weight: 800;
    line-height: 1.25;
    color: var(--tve-text);
}
.tve-modern .tve-detail-meta {
    color: var(--tve-text-muted);
    font-size: 14.5px;
    margin: 0 0 16px;
}
.tve-modern .tve-detail-meta i { color: var(--tve-primary); margin-right: 6px; }
.tve-modern .tve-detail-meta b { color: var(--tve-text); }
.tve-modern .tve-detail-desc {
    color: var(--tve-text);
    font-size: 15px;
    line-height: 1.75;
}
.tve-modern .tve-detail-desc img { max-width: 100%; height: auto; }
.tve-modern .tve-detail-related { margin-top: 6px; }

@media (max-width: 768px) {
    .tve-modern .tve-detail { flex-direction: column; padding: 16px; }
    .tve-modern .tve-detail-media { flex-basis: auto; max-width: 220px; margin: 0 auto; }
}
/* Màn hình nhỏ: các nút thao tác xuống dòng, mỗi nút chiếm trọn chiều ngang */
@media (max-width: 480px) {
    .tve-modern .tve-detail-actions .tve-btn { flex: 1 1 100%; }
}

/* ---------- Trình đọc tài liệu (docsach_view) ---------- */
.tve-modern .tve-reader {
    background: var(--tve-surface);
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius);
    box-shadow: var(--tve-shadow);
    overflow: hidden;
    margin-bottom: 24px;
}
.tve-modern .tve-reader-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--tve-border);
}
.tve-modern .tve-reader-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--tve-text);
    flex: 1 1 auto;
    min-width: 0;
}
.tve-modern .tve-reader-body { background: #f1f3f7; line-height: 0; }
.tve-modern .tve-reader-body iframe {
    display: block;
    width: 100%;
    height: 82vh;
    min-height: 460px;
    border: 0;
}
.tve-modern .tve-reader-body audio {
    display: block;
    width: 92%;
    max-width: 640px;
    margin: 26px auto;
}
/* =====================================================================
   KHỐI QUẢNG CÁO (Google AdSense) — chỉ hiện ở các vị trí khai báo trong
   framework/config/quangcao.class.php. Giữ chỗ sẵn bằng min-height để
   trang không bị nhảy layout khi quảng cáo tải xong.
   ===================================================================== */
.tve-modern .tve-ads {
    position: relative;
    display: block;
    width: 100%;
    max-width: 970px;
    margin: 18px auto;
    padding: 20px 10px 10px;
    background: var(--tve-surface);
    border: 1px solid var(--tve-border);
    border-radius: var(--tve-radius-sm);
    overflow: hidden;
    text-align: center;
}
.tve-modern .tve-ads-label {
    position: absolute;
    top: 4px;
    left: 10px;
    font-size: 10px;
    line-height: 1.4;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--tve-text-muted);
    opacity: .8;
    pointer-events: none;
}
.tve-modern .tve-ads ins.adsbygoogle { display: block; width: 100%; }

/* Banner ngang: thấp và sát nội dung hơn */
.tve-modern .tve-ads--top { margin-top: 6px; }
.tve-modern .tve-ads--cuoi_trang { margin-bottom: 26px; }

/* Không có quảng cáo trả về (unfilled) -> thu gọn khung, tránh ô trống xấu */
.tve-modern .tve-ads:has(ins.adsbygoogle[data-ad-status="unfilled"]) {
    display: none !important;
    min-height: 0 !important;
}

@media (max-width: 767px) {
    .tve-modern .tve-ads { margin: 14px auto; padding: 18px 6px 8px; }
}
