/*
 * CSS dùng chung của cửa hàng, viết trên Bootstrap 5 và styles.css của bộ khung
 * site (layout nạp file này ngay sau styles.css). CSS thuần, không qua bước build
 * nào: sửa file là xong.
 *
 * File này chỉ giữ thứ nhiều giao diện cùng dùng: ô tìm sản phẩm và nút giỏ hàng
 * ở đầu trang, lời báo của giỏ hàng, giá, thẻ sản phẩm, cột bên, ô số lượng, nút
 * mua, và khối sản phẩm của trang chủ. Thứ của riêng một giao diện nằm ở cặp file của giao diện
 * đó: product.css và product-responsive.css, cart.css và cart-responsive.css…
 *
 * File này nạp trước cặp file của giao diện. Hai luật cùng độ ưu tiên đụng nhau
 * thì luật ở file của giao diện thắng.
 *
 * Màu của cửa hàng là các biến --shop-* ngay dưới đây; màu còn lại đọc từ các
 * biến --site-* của styles.css, đổi ở đó là cửa hàng đổi theo.
 */

:root {
    /* Nút "Thêm vào giỏ hàng", "Tiến hành thanh toán", "Đặt hàng": xanh lá của site. */
    --shop-buy: var(--site-accent);
    --shop-buy-dark: #026a19;

    /* Nút "Mua hàng ngay": cam, chữ trắng. */
    --shop-now: #fd8a1d;
    --shop-now-end: #fb631a;
    --shop-now-ink: #fff;

    /* Huy hiệu giảm giá trên ảnh sản phẩm: chữ trắng. */
    --shop-sale: #e8a33d;
    --shop-sale-ink: #fff;

    /* Tên sản phẩm trên thẻ: cam, sẫm hơn dải bản quyền một nấc cho đủ tương phản trên nền trắng. */
    --shop-title: #cf4307;

    /* Giá đang bán ở trang sản phẩm, và giá bán trước khuyến mãi. */
    --shop-price: var(--site-primary);
    --shop-price-old: var(--site-muted);
}

/* ─────────────────────── Ô tìm sản phẩm ở đầu trang ─────────────────────── */

/*
 * Ô tìm sản phẩm đứng ở chỗ ô tìm kiếm của dải logo (partials/header-search), và
 * dùng luôn kiểu dáng .search-form của styles.css. Ở đây chỉ nới rộng thêm cho
 * vừa lời nhắc "Tên hoặc mã sản phẩm…".
 */
.site-header .search-form--compact {
    width: 280px;
}

/* ─────────────────────── Nút giỏ hàng ở đầu trang ─────────────────────── */

/*
 * Nút có hai dáng (components/cart-link). Điện thoại và máy tính bảng: nút vuông
 * chỉ có icon ở dải logo, giữa nút tìm sản phẩm và nút mở menu. Màn hình rộng: nút
 * "Giỏ hàng / tiền hàng" ở mép phải thanh điều hướng.
 */

/* Dải logo: cùng cỡ với nút tìm kiếm và nút mở menu. */
.site-header__cart {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    color: #fff;
}

.site-header__cart:hover {
    color: var(--site-bar);
}

.site-header__cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--site-bar);
    color: var(--site-bar-ink);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

/* Thanh điều hướng: các mục menu chiếm hết chỗ còn lại, đẩy nút giỏ hàng ra mép phải. */
.site-nav > .container {
    display: flex;
    align-items: center;
}

.site-nav__list {
    flex: 1;
    min-width: 0;
}

/* Các bộ chọn dưới đây mang thêm .site-nav để thắng luật `.site-nav a` và `.site-nav span` của styles.css. */
.site-nav .site-nav__cart {
    flex-shrink: 0;
    gap: 12px;
    width: auto;
    height: 38px;
    margin-left: 16px;
    padding: 0 18px;
    border-radius: 19px;
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
    font-size: 0.8125rem;
    text-transform: uppercase;
    white-space: nowrap;
    transition: background-color 0.15s;
}

.site-nav .site-nav__cart:hover {
    background: rgba(0, 0, 0, 0.4);
}

.site-nav .site-nav__cart span {
    display: inline;
    width: auto;
}

/* Chữ "đ" của số tiền không viết hoa theo nhãn. */
.site-nav .site-nav__cart [data-cart-subtotal] {
    text-transform: none;
}

.site-nav .site-nav__cart .site-nav__cart-icon {
    position: relative;
    display: inline-flex;
}

.site-nav .site-nav__cart .site-nav__cart-count {
    position: absolute;
    top: -8px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--site-bar);
    color: var(--site-bar-ink);
    font-size: 0.6875rem;
    line-height: 18px;
    text-align: center;
}

/* Màn hình rộng đã có nút ở thanh điều hướng thì nút ở dải logo nhường chỗ. Site chưa có menu thì không có thanh điều hướng, và nút ở dải logo vẫn hiện. */
@media (min-width: 992px) {
    body:has(.site-nav__cart) .site-header__cart {
        display: none;
    }
}

/* ─────────────────────── Lời báo của giỏ hàng ─────────────────────── */

.shop-toasts {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.shop-toast {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 12px 16px;
    border-left: 4px solid var(--shop-buy);
    border-radius: 4px;
    background: #fff;
    color: var(--site-ink);
    font-size: 0.9375rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    pointer-events: auto;
    animation: shop-toast-in 0.25s ease-out;
}

.shop-toast--danger {
    border-left-color: var(--site-primary);
}

.shop-toast a {
    color: var(--site-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Lời báo máy chủ in sẵn (JavaScript tắt, không có gì gỡ nó đi) tự mờ rồi biến mất sau ít giây. */
.shop-toast[data-shop-toast] {
    animation: shop-toast-in 0.25s ease-out, shop-toast-out 0.4s ease-in 8s forwards;
}

@keyframes shop-toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@keyframes shop-toast-out {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* Điện thoại, máy tính bảng: dải logo dính ở mép trên, lời báo đứng dưới nó để không che nút giỏ hàng và nút menu. Màn hình rộng: shop.js đặt lời báo ngay dưới thanh điều hướng. */
@media (max-width: 991.98px) {
    .shop-toasts {
        top: 84px;
    }
}

/* ───────────────────────────── Giá ───────────────────────────── */

.product-price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 2px 10px;
    margin: 0;
    color: var(--site-ink);
    font-size: 1.125rem;
    line-height: 1.3;
}

.product-price__old {
    color: var(--shop-price-old);
    font-size: 0.875em;
}

.product-price__now {
    font-weight: 600;
    text-decoration: none;
}

/* Giá "Liên hệ" của sản phẩm chưa niêm yết giá. */
.product-price--contact .product-price__now {
    color: var(--site-primary);
}

/* Giá ở trang sản phẩm. */
.product-price--large {
    justify-content: flex-start;
    font-size: 1.75rem;
}

.product-price--large .product-price__now {
    color: var(--shop-price);
    font-weight: 800;
}

.product-price--large .product-price__old {
    font-size: 0.65em;
}

/* ─────────────────────── Thẻ sản phẩm ─────────────────────── */

.product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--site-line);
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.product-card:hover {
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Mọi ảnh cùng một khung vuông, để các thẻ trong một hàng cao bằng nhau. */
.product-card__image {
    position: relative;
    aspect-ratio: 1;
    background: var(--site-soft);
    overflow: hidden;
}

.product-card__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
}

/* Ảnh thứ hai nằm chồng lên ảnh đại diện, hiện dần khi rê chuột. */
.product-card__hover {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.3s;
}

.product-card:hover .product-card__hover {
    opacity: 1;
}

/* Huy hiệu giảm giá: hình tròn ở góc trên phải của ảnh. */
.product-card__badge,
.product-gallery__badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--shop-sale);
    color: var(--shop-sale-ink);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
}

.product-card__stock {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    padding: 6px 8px;
    background: rgba(17, 17, 17, 0.78);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
}

.product-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 12px 16px;
    text-align: center;
}

.product-card__title {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.4;
    text-transform: uppercase;
}

.product-card__title a {
    display: -webkit-box;
    overflow: hidden;
    color: var(--shop-title);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.product-card:hover .product-card__title a {
    color: var(--site-primary);
}

/* Dòng nhỏ ở cột bên: ảnh bên trái, tên và giá bên phải, không viền. */
.product-card--compact {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    height: auto;
    padding: 12px 0;
    border: 0;
    border-bottom: 1px solid var(--site-line);
    border-radius: 0;
}

.product-card--compact:hover {
    box-shadow: none;
    transform: none;
}

.product-card--compact:last-child {
    border-bottom: 0;
}

.product-card--compact .product-card__image {
    flex: 0 0 72px;
    border: 1px solid var(--site-line);
    border-radius: 4px;
}

.product-card--compact .product-card__body {
    gap: 4px;
    padding: 0;
    text-align: left;
}

.product-card--compact .product-card__title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: none;
}

.product-card--compact .product-card__title a {
    color: var(--site-ink);
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.product-card--compact .product-price {
    justify-content: flex-start;
    font-size: 0.9375rem;
}

/* ─────────────────────── Cột bên của cửa hàng ─────────────────────── */

.shop-sidebar__block + .shop-sidebar__block {
    margin-top: 32px;
}

/* Tiêu đề khối: một thanh xanh, chữ canh giữa. */
.shop-sidebar__title {
    margin: 0 0 8px;
    padding: 13px 12px;
    background: var(--site-accent);
    color: #fff;
    font-size: 1rem;
    line-height: 1.3;
    text-align: center;
    text-transform: uppercase;
}

.shop-sidebar__categories,
.shop-sidebar__categories ul,
.shop-sidebar__brands {
    margin: 0;
    padding: 0;
    list-style: none;
}

.shop-sidebar__categories a,
.shop-sidebar__brands a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--site-line);
    font-weight: 600;
}

.shop-sidebar__categories ul a {
    padding-left: 22px;
    font-weight: 500;
}

.shop-sidebar__categories ul ul a {
    padding-left: 40px;
}

.shop-sidebar__categories a:hover,
.shop-sidebar__categories a.is-active,
.shop-sidebar__brands a:hover,
.shop-sidebar__brands a.is-active {
    color: var(--site-primary);
}

/* ─────────────────────── Ô số lượng ─────────────────────── */

.quantity {
    display: inline-flex;
    align-items: stretch;
    height: 44px;
    border: 1px solid var(--site-line);
    border-radius: 4px;
    background: #fff;
}

.quantity__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    padding: 0;
    border: 0;
    background: var(--site-soft);
    color: var(--site-ink);
}

.quantity__button:hover {
    background: var(--site-line);
}

.quantity__input {
    width: 52px;
    padding: 0 4px;
    border: 0;
    border-right: 1px solid var(--site-line);
    border-left: 1px solid var(--site-line);
    color: var(--site-ink);
    font-weight: 600;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.quantity__input::-webkit-outer-spin-button,
.quantity__input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

/* ─────────────────────── Nút mua ─────────────────────── */

.btn-buy {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--shop-buy);
    --bs-btn-border-color: var(--shop-buy);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--shop-buy-dark);
    --bs-btn-hover-border-color: var(--shop-buy-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--shop-buy-dark);
    --bs-btn-active-border-color: var(--shop-buy-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--shop-buy);
    --bs-btn-disabled-border-color: var(--shop-buy);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    text-transform: uppercase;
}

/* "Mua hàng ngay": nút lớn hai dòng, dòng dưới là lời dẫn. */
.btn-buy-now {
    --bs-btn-color: var(--shop-now-ink);
    --bs-btn-hover-color: var(--shop-now-ink);
    --bs-btn-active-color: var(--shop-now-ink);
    --bs-btn-disabled-color: var(--shop-now-ink);
    --bs-btn-border-color: var(--shop-now-end);
    --bs-btn-hover-border-color: var(--shop-now-end);
    --bs-btn-active-border-color: var(--shop-now-end);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 9px 12px;
    background: linear-gradient(var(--shop-now), var(--shop-now-end));
    line-height: 1.3;
}

.btn-buy-now:hover,
.btn-buy-now:active {
    background: linear-gradient(var(--shop-now-end), var(--shop-now));
}

.btn-buy-now strong {
    font-size: 1.125rem;
    text-transform: uppercase;
}

.btn-buy-now span {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ─────────────────── Khối sản phẩm của trang chủ ─────────────────── */

.home-products {
    padding: 48px 0 56px;
}

.home-products__icon {
    display: block;
    margin: 0 auto 12px;
}

.home-products__title {
    margin: 0 0 20px;
    font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
}

.home-products__tabs {
    --bs-nav-pills-border-radius: 999px;
    --bs-nav-pills-link-active-bg: var(--site-primary);
    --bs-nav-link-color: var(--site-ink);
    --bs-nav-link-hover-color: var(--site-primary);
    --bs-nav-link-font-weight: 700;
    justify-content: center;
    gap: 6px;
    margin-bottom: 28px;
}

.home-products__tabs .nav-link {
    padding: 8px 20px;
    font-size: 0.9375rem;
    text-transform: uppercase;
}

.home-products__more {
    margin: 32px 0 0;
    text-align: center;
}

.home-products__more .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    --bs-btn-border-radius: 10px;
}

/* Giỏ hàng trống: dùng ở trang giỏ hàng và trang đặt hàng. */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 16px;
    color: var(--site-muted);
    text-align: center;
}

.cart-empty p {
    margin: 0;
    font-size: 1.125rem;
}

/* Điện thoại. */
@media (max-width: 575.98px) {
    .product-card__body {
        padding: 10px 8px 12px;
    }

    .product-card__title {
        font-size: 0.8125rem;
    }

    .product-price {
        font-size: 1rem;
    }

    .product-card__badge {
        top: 6px;
        right: 6px;
        width: 40px;
        height: 40px;
        font-size: 0.75rem;
    }

    .home-products {
        padding: 36px 0 40px;
    }

    .home-products__tabs .nav-link {
        padding: 6px 14px;
        font-size: 0.8125rem;
    }
}
