/* ============================================================
   home.css — Hachi Books (Fahasa-style: trắng - đỏ - sạch)
   Tone chủ đạo: #C92127 (đỏ Fahasa) + trắng + xám nhạt
   ============================================================ */

/* ===== BIẾN MÀU CHUNG ===== */
:root {
    --primary: #C92127;
    --primary-dark: #A8161B;
    --primary-light: #FDECEA;
    --accent: #F5A623;
    --accent-dark: #E89412;
    --text-dark: #242424;
    --text-mid: #555;
    --text-light: #888;
    --bg-page: #F5F5FA;
    --bg-card: #FFFFFF;
    --border: #ECECEC;
    --border-light: #F2F2F2;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: inherit;
}

input, button, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    background: var(--bg-page) !important;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    color: var(--text-dark);
}

.body-content {
    padding: 0 !important;
    margin: 0 !important;
    background: var(--bg-page);
}

    .body-content hr, .body-content footer {
        display: none;
    }

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
    background: #fff;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    border-bottom: 1px solid #f0f0f0;
}

.header-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 72px;
}

.logo {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.5px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

    .logo::before {
        content: "📚";
        font-size: 26px;
    }

    .logo span {
        color: var(--text-dark);
    }

.search-box {
    width: 480px;
    flex-shrink: 0;
    display: flex;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow .15s;
}

    .search-box:focus-within {
        box-shadow: 0 0 0 3px rgba(201,33,39,.12);
    }

    .search-box input {
        flex: 1;
        min-width: 0;
        border: none;
        outline: none;
        padding: 0 16px;
        font-size: 14px;
        height: 40px;
        color: #333;
        background: transparent;
    }

        .search-box input::placeholder {
            color: #aaa;
        }

    .search-box button {
        background: var(--primary);
        border: none;
        color: #fff;
        padding: 0 22px;
        cursor: pointer;
        font-size: 16px;
        height: 40px;
        transition: background .15s;
    }

        .search-box button:hover {
            background: var(--primary-dark);
        }

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

.user-welcome {
    color: var(--text-dark);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-login, .btn-register, .btn-logout, .btn-orders, .cart-btn {
    border-radius: 6px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
    border: none;
}

.btn-login {
    background: var(--primary);
    color: #fff;
}

    .btn-login:hover {
        background: var(--primary-dark);
    }

.btn-register {
    background: #fff;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

    .btn-register:hover {
        background: var(--primary-light);
    }

.btn-logout {
    background: transparent;
    border: 1.5px solid #ddd;
    color: var(--text-mid);
}

    .btn-logout:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

.btn-orders {
    background: var(--primary-light);
    border: 1.5px solid transparent;
    color: var(--primary);
}

    .btn-orders:hover {
        background: #fad5d3;
    }

.cart-btn {
    position: relative;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    color: var(--text-dark);
}

    .cart-btn:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

.cart-count {
    position: absolute;
    top: -7px;
    right: -7px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(201,33,39,.35);
    border: 2px solid #fff;
}

/* ============================================================
   NAV BAR — FIX: overflow visible để dropdown không bị clip
   ============================================================ */
.nav-bar {
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    box-shadow: 0 1px 3px rgba(0,0,0,.03);
    position: relative;
    z-index: 200; /* FIX: đảm bảo nav bar nằm trên content */
    overflow: visible; /* FIX: cho phép dropdown thoát ra ngoài */
}

.nav-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    overflow-y: visible; /* FIX: không clip dropdown theo chiều dọc */
    padding: 0 20px;
    scrollbar-width: none;
    position: relative;
    z-index: 200;
}

    .nav-inner::-webkit-scrollbar {
        display: none;
    }

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-mid);
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all .15s;
    margin-bottom: -1px;
}

    .nav-btn:hover {
        color: var(--primary);
    }

    .nav-btn.active {
        color: var(--primary);
        border-bottom-color: var(--primary);
        font-weight: 700;
    }

/* —— Wrapper "Tất Cả Danh Mục" + Dropdown —— */
.nav-all-wrapper {
    position: relative;
    flex-shrink: 0;
    z-index: 300; /* FIX: cao hơn nav-inner để dropdown hiện đúng */
}

.nav-btn-all {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 6px 6px 0 0;
    font-weight: 700;
    padding: 14px 18px;
    border-bottom: 3px solid var(--primary);
}

    .nav-btn-all:hover {
        background: #fad5d3;
        color: var(--primary);
    }

.nav-arrow {
    font-size: 12px;
    transition: transform .2s;
    display: inline-block;
}

/* FIX: Dropdown dùng display:none/block qua JS thay CSS hover
   vì overflow:auto trên nav-inner clip mất dropdown khi dùng CSS hover */
.cat-dropdown {
    display: none; /* FIX: mặc định ẩn, JS sẽ toggle */
    position: fixed; /* FIX: dùng fixed thay absolute để thoát khỏi overflow */
    min-width: 220px;
    background: #fff;
    border: 1px solid #ececec;
    border-top: 2px solid var(--primary);
    border-radius: 0 8px 8px 8px;
    box-shadow: 0 12px 32px rgba(0,0,0,.13);
    z-index: 9999; /* FIX: z-index cao nhất */
    animation: dropFade .15s ease;
    margin-top: 1px;
}

@keyframes dropFade {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cat-dropdown-inner {
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    max-height: 400px;
    overflow-y: auto;
}

.cat-drop-item {
    background: none;
    border: none;
    text-align: left;
    padding: 10px 20px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: background .12s, color .12s;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

    .cat-drop-item:hover {
        background: var(--primary-light);
        color: var(--primary);
        border-left-color: var(--primary);
        font-weight: 600;
    }

/* ============================================================
   PAGE WRAP
   ============================================================ */
.page-wrap {
    flex: 1;
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px 48px;
    background: transparent;
}

/* ============================================================
   HERO BANNER
   ============================================================ */
.hero {
    background: linear-gradient(135deg, #C92127 0%, #E83E3E 50%, #F25C5C 100%);
    border-radius: 12px;
    padding: 40px 48px;
    color: #fff;
    margin-bottom: 28px;
    box-shadow: 0 6px 20px rgba(201,33,39,.18);
    position: relative;
    overflow: hidden;
}

    .hero::before {
        content: "";
        position: absolute;
        right: -60px;
        top: -60px;
        width: 260px;
        height: 260px;
        background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
        border-radius: 50%;
    }

    .hero::after {
        content: "📖";
        position: absolute;
        right: 60px;
        bottom: -20px;
        font-size: 140px;
        opacity: .14;
        transform: rotate(-12deg);
    }

.hero-text {
    position: relative;
    z-index: 1;
}

    .hero-text h2 {
        font-size: 32px;
        font-weight: 800;
        margin-bottom: 10px;
        letter-spacing: -0.5px;
    }

    .hero-text p {
        font-size: 15px;
        opacity: .95;
        max-width: 580px;
        line-height: 1.5;
    }

/* ============================================================
   SECTION TITLE
   ============================================================ */
.section-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-dark);
    padding-left: 14px;
    border-left: 4px solid var(--primary);
    margin-bottom: 20px;
    letter-spacing: -0.3px;
}

/* ============================================================
   BOOK GRID & CARD
   ============================================================ */
.book-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.book-card {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

    .book-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 24px rgba(0,0,0,.1);
        border-color: var(--primary);
    }

    /* FIX: card hết hàng — cursor not-allowed, không lift khi hover */
    .book-card.book-oos {
        opacity: .88;
        cursor: not-allowed; /* FIX: con trỏ báo không thể click */
    }

        .book-card.book-oos:hover {
            transform: none; /* FIX: không lift lên khi hover */
            box-shadow: none;
            border-color: var(--border);
        }

/* Overlay hiện khi hover card hết hàng */
.book-oos-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(20, 20, 20, .62);
    z-index: 20;
    border-radius: 8px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    pointer-events: none;
}

.book-card.book-oos:hover .book-oos-overlay {
    display: flex;
}

.book-oos-x {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(220, 38, 38, .85);
    color: #fff;
    font-size: 26px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(220,38,38,.5);
    border: 2.5px solid rgba(255,255,255,.6);
}

.book-oos-label {
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    background: rgba(200, 0, 0, .75);
    padding: 5px 14px;
    border-radius: 20px;
    letter-spacing: .3px;
    white-space: nowrap;
}

.book-stock-oos {
    color: var(--primary) !important;
    font-weight: 700 !important;
}

/* Nút disabled khi hết hàng */
.btn-oos {
    opacity: .45 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

.book-cover {
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    position: relative;
    overflow: hidden;
}

    .book-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transition: transform .35s ease;
    }

.book-card:not(.book-oos):hover .book-cover img {
    transform: scale(1.04); /* FIX: chỉ zoom ảnh khi không phải hết hàng */
}

.cover-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 56px;
}

.badge-new {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(201,33,39,.35);
    z-index: 2;
}

.book-body {
    padding: 12px 12px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 13.5px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 38px;
}

.book-genre-tag {
    display: inline-block;
    font-size: 10.5px;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 4px;
    padding: 3px 8px;
    margin-bottom: 6px;
    font-weight: 600;
    align-self: flex-start;
}

.book-date {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.book-stock {
    font-size: 11.5px;
    color: var(--text-mid);
    margin-bottom: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.book-price {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    padding: 4px 12px 12px;
    letter-spacing: -0.3px;
}

.book-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

.btn-add-cart {
    background: #fff;
    color: var(--primary);
    border: none;
    border-right: 1px solid var(--border-light);
    padding: 11px 4px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: background .15s;
}

    .btn-add-cart:hover {
        background: var(--primary-light);
    }

.btn-buy-now {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 11px 4px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 700;
    transition: background .15s;
}

    .btn-buy-now:hover {
        background: var(--primary-dark);
    }

.no-result {
    text-align: center;
    padding: 60px 0;
    color: #aaa;
    font-size: 16px;
    grid-column: 1/-1;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    top: 90px;
    right: 24px;
    background: linear-gradient(135deg, #27ae60, #229954);
    color: #fff;
    padding: 14px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 22px rgba(39,174,96,.35);
    transform: translateX(120%);
    transition: transform .3s ease;
}

    .toast.show {
        transform: translateX(0);
    }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 24px 0 8px;
    flex-wrap: wrap;
}

.pg-btn {
    min-width: 38px;
    height: 38px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all .15s;
    padding: 0 10px;
}

    .pg-btn:hover:not(:disabled) {
        border-color: var(--primary);
        color: var(--primary);
    }

    .pg-btn.active {
        background: var(--primary);
        border-color: var(--primary);
        color: #fff;
    }

    .pg-btn:disabled {
        opacity: .4;
        cursor: not-allowed;
    }

.pg-info {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    margin-top: 10px;
}

/* ============================================================
   MODAL CHI TIẾT SÁCH
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn .2s ease;
}

    .modal-overlay.show {
        display: flex;
    }

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-box {
    background: #fff;
    border-radius: 14px;
    max-width: 880px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 24px 60px rgba(0,0,0,.4);
    animation: slideUp .3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 16px;
    color: #555;
    z-index: 2;
    transition: all .15s;
}

    .modal-close:hover {
        background: var(--primary);
        color: #fff;
    }

.modal-inner {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 28px;
    padding: 28px;
}

.modal-cover {
    background: #fafafa;
    border-radius: 10px;
    overflow: hidden;
    height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .modal-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.modal-title {
    font-size: 24px;
    font-weight: 800;
    color: #222;
    margin-bottom: 10px;
    line-height: 1.3;
}

.modal-genre {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 14px;
}

.modal-price {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 18px;
}

.modal-meta {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.modal-meta-row {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    font-size: 14px;
}

.modal-meta-label {
    color: #666;
    font-weight: 600;
    min-width: 120px;
}

.modal-meta-value {
    color: #333;
}

    .modal-meta-value.highlight {
        color: var(--primary);
        font-weight: 600;
    }

.modal-desc {
    color: #555;
    line-height: 1.6;
    font-size: 14px;
    margin-bottom: 20px;
    max-height: 120px;
    overflow-y: auto;
}

.modal-btn-group {
    display: flex;
    gap: 10px;
}

.btn-modal-cart, .btn-modal-buy {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
}

.btn-modal-cart {
    background: #fff;
    color: var(--primary);
    border: 2px solid var(--primary);
}

    .btn-modal-cart:hover {
        background: var(--primary-light);
    }

.btn-modal-buy {
    background: var(--primary);
    color: #fff;
}

    .btn-modal-buy:hover {
        background: var(--primary-dark);
    }

/* ============================================================
   CART PANEL
   ============================================================ */
.cart-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 998;
}

    .cart-overlay.show {
        display: block;
    }

.cart-panel {
    position: fixed;
    top: 0;
    right: -440px;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: right .3s ease;
    box-shadow: -8px 0 24px rgba(0,0,0,.2);
}

    .cart-panel.show {
        right: 0;
    }

.cart-header {
    background: var(--primary);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .cart-header h3 {
        font-size: 18px;
        font-weight: 700;
    }

.cart-close {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
}

    .cart-close:hover {
        background: rgba(255,255,255,.35);
    }

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f5fa;
}

.cart-empty {
    text-align: center;
    padding: 60px 20px;
    color: #aaa;
    font-size: 15px;
}

.cart-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    transition: box-shadow .2s ease, border-color .2s ease, opacity .2s ease;
}

    .cart-item:hover {
        box-shadow: 0 4px 16px rgba(0,0,0,.07);
        border-color: #ddd;
    }

    .cart-item.unchecked {
        opacity: .5;
        background: #fafafa;
    }

        .cart-item.unchecked:hover {
            opacity: .7;
        }

.cart-check {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    position: relative;
}

    .cart-check:hover {
        border-color: var(--primary);
        background: var(--primary-light);
    }

    .cart-check.checked {
        background: var(--primary);
        border-color: var(--primary);
    }

        .cart-check.checked::after {
            content: '✓';
            color: #fff;
            font-size: 13px;
            font-weight: 800;
            line-height: 1;
        }

.cart-item-cover {
    width: 72px;
    height: 90px;
    min-width: 72px;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #eee;
}

    .cart-item-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

.cart-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-item-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-price {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.3px;
}

.cart-item-qty {
    display: inline-flex;
    align-items: center;
    gap: 0;
    margin-top: 4px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    align-self: flex-start;
    background: #fafafa;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-mid);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
    line-height: 1;
    padding: 0;
}

    .qty-btn:hover {
        background: var(--primary);
        color: #fff;
    }

    .qty-btn:active {
        transform: scale(.9);
    }

.qty-val {
    min-width: 32px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
    padding: 0 4px;
    border-left: 1.5px solid #e0e0e0;
    border-right: 1.5px solid #e0e0e0;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

.cart-remove {
    background: none;
    border: none;
    color: #bbb;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all .2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    align-self: flex-start;
    margin-top: 2px;
}

    .cart-remove:hover {
        background: #fee;
        color: var(--primary);
        transform: scale(1.1);
    }

.cart-footer {
    border-top: 2px solid var(--border);
    padding: 18px 20px;
    background: #fff;
    box-shadow: 0 -4px 12px rgba(0,0,0,.04);
}

.cart-total-wrap {
    margin-bottom: 16px;
}

.cart-selected-info {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 800;
    color: var(--text-dark);
}

    .cart-total span:last-child {
        font-size: 20px;
        color: var(--primary);
    }

.btn-checkout {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, #e83e3e 100%);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s ease;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 14px rgba(201,33,39,.25);
}

    .btn-checkout:hover {
        background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(201,33,39,.4);
    }

    .btn-checkout:active {
        transform: translateY(0);
        box-shadow: 0 2px 8px rgba(201,33,39,.3);
    }

/* ============================================================
   FOOTER
   ============================================================ */
footer.site-footer {
    background: #fff;
    color: var(--text-mid);
    padding: 50px 0 0 0;
    margin-top: 60px;
    border-top: 3px solid var(--primary);
    width: 100%;
    display: block;
}

    footer.site-footer .footer-inner {
        max-width: 1240px;
        margin: 0 auto;
        padding: 0 24px 40px;
        display: grid;
        grid-template-columns: 1.4fr 1fr 1fr 1.2fr;
        gap: 40px;
    }

    footer.site-footer .footer-col {
        color: var(--text-mid);
    }

        footer.site-footer .footer-col h3 {
            font-size: 26px;
            margin: 0 0 16px;
            color: var(--primary);
            font-weight: 800;
            letter-spacing: -0.5px;
            display: flex;
            align-items: center;
            gap: 6px;
        }

            footer.site-footer .footer-col h3::before {
                content: "📚";
                font-size: 24px;
            }

            footer.site-footer .footer-col h3 span {
                color: var(--text-dark);
            }

        footer.site-footer .footer-col h4 {
            font-size: 15px;
            color: var(--text-dark);
            margin: 0 0 18px;
            font-weight: 700;
            position: relative;
            padding-bottom: 10px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

            footer.site-footer .footer-col h4::after {
                content: '';
                position: absolute;
                left: 0;
                bottom: 0;
                width: 36px;
                height: 2.5px;
                background: var(--primary);
                border-radius: 2px;
            }

        footer.site-footer .footer-col p {
            line-height: 1.7;
            font-size: 13.5px;
            color: var(--text-mid);
            margin-bottom: 16px;
        }

        footer.site-footer .footer-col ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

            footer.site-footer .footer-col ul li {
                margin-bottom: 10px;
                font-size: 13.5px;
                color: var(--text-mid);
                line-height: 1.6;
            }

                footer.site-footer .footer-col ul li a {
                    color: var(--text-mid);
                    text-decoration: none;
                    font-size: 13.5px;
                    transition: color .2s ease, padding-left .2s ease;
                    display: inline-block;
                }

                    footer.site-footer .footer-col ul li a:hover {
                        color: var(--primary);
                        padding-left: 6px;
                    }

    footer.site-footer .footer-socials {
        display: flex;
        gap: 10px;
        margin-top: 18px;
        flex-wrap: wrap;
    }

        footer.site-footer .footer-socials a {
            color: var(--primary);
            text-decoration: none;
            font-size: 13px;
            background: var(--primary-light);
            padding: 8px 14px;
            border-radius: 6px;
            transition: all .2s ease;
            border: 1px solid transparent;
            font-weight: 500;
        }

            footer.site-footer .footer-socials a:hover {
                background: var(--primary);
                color: #fff;
                transform: translateY(-2px);
            }

    footer.site-footer .footer-contact li {
        font-size: 13.5px;
        color: var(--text-mid);
        line-height: 1.7;
        margin-bottom: 10px;
    }

    footer.site-footer .footer-bottom {
        text-align: center;
        padding: 18px 24px;
        border-top: 1px solid var(--border);
        background: #fafafa;
        font-size: 13px;
        color: var(--text-light);
    }

        footer.site-footer .footer-bottom p {
            margin: 0;
        }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
    .book-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    footer.site-footer .footer-inner {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }
}

@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 0;
        gap: 12px;
    }

    .search-box {
        width: 100%;
        order: 3;
    }

    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .hero {
        padding: 28px 24px;
    }

    .hero-text h2 {
        font-size: 24px;
    }

    .modal-inner {
        grid-template-columns: 1fr;
    }

    .modal-cover {
        height: 280px;
    }

    footer.site-footer .footer-inner {
        grid-template-columns: 1fr;
        gap: 28px;
    }
}

@media (max-width: 480px) {
    .book-grid {
        grid-template-columns: 1fr;
    }

    .cart-panel {
        width: 100vw;
    }
}

/* ===== BANNER SLIDER ===== */
.banner-slider-wrap {
    position: relative;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto 0;
    border-radius: 14px;
    overflow: hidden;
    background: #eee;
    aspect-ratio: 16 / 5;
    min-height: 160px;
}

.banner-slider {
    width: 100%;
    height: 100%;
    position: relative;
}

.banner-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
}

    .banner-slide.active {
        opacity: 1;
        z-index: 1;
    }

    .banner-slide img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

.banner-prev, .banner-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.35);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 22px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.banner-prev {
    left: 12px;
}

.banner-next {
    right: 12px;
}

    .banner-prev:hover, .banner-next:hover {
        background: rgba(0,0,0,0.6);
    }

.banner-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
}

.banner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: all 0.2s;
}

    .banner-dot.active {
        background: #fff;
        transform: scale(1.3);
    }

/* ===== SECTION TITLES ===== */
.section-title {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
    padding: 0 0 8px 14px;
    border-left: 4px solid #c53030;
    margin: 24px 0 16px;
}

/* ===== BADGE RANK ===== */
.badge-rank {
    position: absolute;
    top: 6px;
    left: 6px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 12px;
    z-index: 2;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* ===== BADGE MỚI ===== */
.badge-new {
    position: absolute;
    top: 6px;
    right: 6px;
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 12px;
    z-index: 2;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ===== FIX MOBILE - TRANG CHI TIẾT SẢN PHẨM ===== */
@media (max-width: 768px) {

    /* Tiêu đề sách - giảm từ 26px xuống vừa màn hình */
    .ct-title {
        font-size: 18px !important;
    }

    /* Giá - giảm từ 30px xuống */
    .ct-price {
        font-size: 22px !important;
    }

    /* Container chính */
    .ct-wrap {
        padding: 16px 12px 40px !important;
    }

    /* Layout 2 cột -> 1 cột (đã có media query nhưng thêm safe) */
    .ct-main {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Ảnh bìa không bị sticky trên mobile */
    .ct-cover-wrap {
        position: static !important;
    }

    /* Thumbnail nhỏ lại chút */
    .ct-thumbs {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 6px !important;
    }

    /* Meta info 2 cột -> 1 cột */
    .ct-meta {
        grid-template-columns: 1fr !important;
    }

    /* Sách liên quan - giảm số cột */
    .related-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* Nút thêm giỏ hàng - font vừa */
    .btn-cart, .btn-buy {
        font-size: 14px !important;
        padding: 12px !important;
    }

    /* Nút quay về */
    .btn-back {
        font-size: 13px !important;
        padding: 8px 14px !important;
        margin-bottom: 16px !important;
    }

    /* Lightbox trên mobile */
    .lightbox {
        padding: 16px !important;
    }

    .lightbox-nav {
        width: 40px !important;
        height: 40px !important;
        font-size: 28px !important;
    }

    .lightbox-prev { left: 8px !important; }
    .lightbox-next { right: 8px !important; }
}

@media (max-width: 480px) {
    .ct-title {
        font-size: 16px !important;
    }

    .ct-price {
        font-size: 20px !important;
    }

    /* Thumbnail: 4 cái thay vì 5 để dễ bấm hơn */
    .ct-thumbs {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .related-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}