/* --- BỐ CỤC CHÍNH --- */
.single-product .product {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    /* Tăng khoảng cách giữa 2 cột */
}

.single-product .woocommerce-product-gallery {
    flex: 1 1 50%;
    min-width: 300px;
}

.single-product .summary.entry-summary {
    flex: 1 1 45%;
    min-width: 300px;
}

/* --- CỘT THÔNG TIN BÊN PHẢI (.summary) --- */

/* Huy hiệu "New" */
.summary .new-badge {
    border-radius: var(--border-radius-sm);
    font-size: 1.2rem;
    font-family: var(--font-family-text-medium);
    color: var(--color-text-inverse);
    z-index: 2;
    background-color: #28a745;
    width: 80px;
    height: 31px;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    margin-bottom: 2rem;
}

/* Danh mục sản phẩm (BÚT VIẾT) */
.summary .product-category-list {
    text-transform: uppercase;
    font-size: 13px;
    margin-bottom: 1.5rem;
}

.summary .product-category-list a {
    display: flex;
    align-items: center;
}

.summary .product-category-list a {
    color: var(--color-surface-primary);
    text-decoration: none;
    font-weight: 600;
}

.summary .product-category-list a img {
    margin-right: 1rem;
}

/* Khối Tiêu đề + nút Chia sẻ */
.summary .product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 10px;
}

.summary h1.product_title {
    font-size: 2rem;
    font-family: var(--font-family-title);
    text-transform: uppercase;
    color: var(--color-text-primary);
    margin-bottom: 4rem;
}

/* Khối Đánh giá + Đã bán */
.summary .product-meta-reviews {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 14px;
    justify-content: space-between;
}

.summary .woocommerce-review-link {
    color: #555;
}

.summary .sold-count {
    color: #333;
    padding-left: 15px;
    border-left: 1px solid #ddd;
}

/* Giá sản phẩm */
.summary p.price {
    font-size: 24px;
    font-weight: bold;
    color: #d0021b;
    /* Màu đỏ */
    margin-bottom: 15px;
    display: flex;
    flex-direction: row-reverse;
    max-width: 300px;
    justify-content: flex-end;
    align-items: self-end;
}

.price .woocommerce-Price-amount {
    font-family: var(--font-family-title);
}

span.woocommerce-Price-currencySymbol {
    text-decoration: none;
}

.summary p.price del {
    font-size: 16px;
    color: #999;
    margin-left: 10px;
}

.summary p.price del bdi {
    font-size: 1.6rem;
    font-family: var(--font-family-primary);
}

/* Khối Thương hiệu + Mã SP */
.summary .product-brand-sku {
    margin-bottom: 25px;
    /* Tăng khoảng cách */
    font-size: 14px;
    color: #333;
    line-height: 1.6;
}

.summary .product-brand-sku .brand {
    position: relative;
}

.summary .product-brand-sku .brand:after {
    position: absolute;
    content: '';
    height: 16px;
    width: 1px;
    background: var(--color-black);
    right: -1rem;
    top: 50%;
    transform: translateY(-50%);
}

.summary .product-brand-sku span {
    font-weight: 600;
}

/* --- CÁC NÚT BẤM --- */

/* Form chọn số lượng và nút */
.summary form.cart {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.summary form.cart .quantity {
    margin-right: 5px;
}

/* Nút "Thêm vào giỏ hàng" */
.summary form.cart .single_add_to_cart_button {
    background-color: #fff !important;
    color: #000000 !important;
    border: 1px solid #000000 !important;
    border-radius: 5px;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    font-family: var(--font-family-text-medium);
    font-size: 1.6rem;
    height: 4.8rem;
}

.summary form.cart .single_add_to_cart_button:hover {
    background-color: #f5f5f5 !important;
    border-color: #aaa !important;
}

/* Nút "Mua ngay" */
.summary .buy-now-wrapper {
    width: 100%;
}

.summary .buy-now-button {
    background-color: var(--color-surface-primary);
    color: #fff !important;
    border: 1px solid var(--color-surface-primary) !important;
    border-radius: 5px;
    font-size: 1.6rem;
    font-family: var(--font-family-text-medium);
    height: 4.8rem;
    flex-grow: 1;
    width: 50%;
    max-width: 407px;
}

.summary .buy-now-button:hover {
    background-color: #b00216 !important;
    border-color: #b00216 !important;
}

/* --- CSS TÙY CHỈNH CHO HỆ THỐNG SAO ĐÁNH GIÁ --- */

.summary .rating {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Ghi đè style mặc định của WooCommerce */
.summary .star-rating {
    width: 71px;
    /* 14.2px * 5 sao */
    height: 14px;
    background-image: url('../images/icons/star-none.svg') !important;
    /* Icon sao rỗng */
    background-size: 14px 14px !important;
    background-repeat: repeat-x !important;
    position: relative;
    overflow: hidden;
    float: none;
    /* Bỏ float mặc định */
}

.summary .star-rating span {
    display: block;
    height: 100%;
    background-image: url('../images/icons/star.svg') !important;
    /* Icon sao đầy */
    background-size: 14px 14px !important;
    background-repeat: repeat-x !important;
    position: absolute;
    top: 0;
    left: 0;
}

/* Ẩn text mô tả mặc định bên trong sao */
.summary .star-rating span strong,
.summary .star-rating::before {
    content: "" !important;
    font-size: 0 !important;
    color: transparent !important;
}

/* Định dạng cho số lượng review (VD: "(5)") */
.summary .review-count {
    font-size: 14px;
    /* Chuyển thành 14px cho dễ nhìn */
    color: #555;
    /* Đặt màu cứng thay cho biến CSS để đảm bảo hiển thị */
    font-family: inherit;
    /* Kế thừa font của theme */
}

/* --- CSS CHO PHẦN ĐÃ BÁN --- */

.summary .sold-count {
    display: flex;
    align-items: center;
    gap: 5px;
    /* Khoảng cách giữa icon và chữ */
}

/* Định dạng cho icon "buy.svg" */
.summary .sold-count img {
    width: 16px;
    height: 16px;
}

/* Định dạng cho text "Đã bán..." */
.summary .sold-count span {
    color: #0062F1;
    /* Màu xanh dương */
    font-family: inherit;
    /* Kế thừa font của theme */
    font-weight: 600;
    /* In đậm chữ một chút */
    font-size: 14px;
    /* Chỉnh lại kích thước cho dễ đọc */
}

.price ins {
    text-decoration: none;
}

.product-brand-sku {
    display: flex;
    gap: 2rem;
}

/* --- CSS PHIÊN BẢN ƯU TIÊN CAO (SỬA LỖI GHI ĐÈ CỦA THEME) --- *


/* Bố cục chính 2 cột */
.custom-tabs-layout {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 30px !important;
    margin-top: 30px !important;
    width: 100%;
    /* Đảm bảo container không bị co lại */
    padding-bottom: 4rem;
}

/* Cột trái - Nội dung Tabs */
.custom-tabs-layout .tabs-content-left {
    flex: 1 !important;
    /* Tự động co giãn */
    min-width: 300px !important;
    width: auto;
    /* Reset width mặc định của theme */
    background: #fff;
    padding-top: 2rem;
}

/* Cột phải - Khối "Thông tin chi tiết" */
.custom-tabs-layout .product-details-box {
    flex-basis: 320px !important;
    /* Chiều rộng cố định */
    flex-shrink: 0 !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 5px !important;
    padding: 20px !important;
    height: fit-content !important;
    width: 320px !important;
    /* Set width cứng để chống theme ghi đè */
    background: #ffffff;
}

/* --- TÙY CHỈNH GIAO DIỆN TABS (CỘT TRÁI) --- */
.tabs-content-left .panel {
    border: none !important;
}

.tabs-content-left ul.tabs {
    border-bottom: 1px solid #e0e0e0 !important;
    padding-left: 0 !important;
    margin-bottom: 20px !important;
    display: flex !important;
    gap: 30px !important;
}

.tabs-content-left ul.tabs::before {
    border-bottom: none !important;
}

.tabs-content-left ul.tabs li {
    background-color: transparent !important;
    border: none !important;
    padding: 0 0 10px 0 !important;
    position: relative !important;
    margin: 0 !important;
}

.tabs-content-left ul.tabs li a {
    font-size: 18px;
    padding: 0 !important;
    font-family: var(--font-family-text-medium);
    font-weight: 700;
}

.tabs-content-left ul.tabs li.active {
    border-bottom: 2px solid #d0021b !important;
}

.tabs-content-left ul.tabs li.active a {
    color: #d0021b !important;
}

.tabs-content-left ul.tabs li.active::before {
    content: "" !important;
    display: block !important;
    width: 3px !important;
    height: 20px !important;
    background-color: #d0021b !important;
    position: absolute !important;
    left: -15px !important;
    top: 0 !important;
}

/* --- KHỐI THÔNG TIN CHI TIẾT (CỘT PHẢI) --- */
.product-details-box h2 {
    font-size: 18px !important;
    color: var(--color-black);
    padding-left: 15px !important;
    position: relative !important;
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    font-family: var(--font-family-text-medium);
}

.product-details-box h2::before {
    content: "" !important;
    display: block !important;
    width: 3px !important;
    height: 18px;
    background-color: #d0021b !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.product-details-box .custom-details-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
}

.product-details-box .detail-row {
    display: flex !important;
    justify-content: space-between !important;
    padding: 10px 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    font-size: 14px !important;
}

.product-details-box .detail-row:last-child {
    border-bottom: none !important;
}

.product-details-box .detail-label {
    color: #555 !important;
    padding-right: 15px !important;
}

.product-details-box .detail-value {
    color: #333 !important;
    font-weight: 600 !important;
    text-align: right !important;
}

@media(max-width:1024px) {
    .custom-tabs-layout .product-details-box {
        flex-basis: 100% !important;
        width: 100% !important;
    }
}

/* --- CSS CHO KHỐI TIÊU ĐỀ SẢN PHẨM CÙNG THƯƠNG HIỆU --- */

/* Xóa tiêu đề mặc định của WooCommerce */
.single-product section.related.products>h2 {
    display: none !important;
}

/* Container chính của khối tiêu đề tùy chỉnh */
.single-product .custom-related-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* Căn lề trên cùng */
    margin-bottom: 25px;
    /* Khoảng cách với lưới sản phẩm */
}

/* Phần chữ (tiêu đề + mô tả) */
.custom-related-header .header-text {
    flex-grow: 1;
    /* Cho phép co giãn */
    margin-bottom: 2rem;
}

.custom-related-header {
    display: flex;
    align-items: center;
    width: 100%;
}

.custom-related-header .header-text h2 {
    font-size: 20px;
    color: #333 !important;
    font-weight: 700 !important;
    margin: 0 0 8px 0 !important;
    /* Reset margin */
    padding: 0 !important;
}

.custom-related-header .header-text p {
    font-size: 14px !important;
    color: #000000;
    margin: 0 !important;
    padding: 0 !important;

    /* Giới hạn chiều rộng để không bị tràn */
}

/* Phần nút "Xem tất cả" */
.custom-related-header .header-button {
    flex-shrink: 0;
    /* Không cho phép co lại */
}

.custom-related-header .view-all-button {
    border: 1px solid #d0021b !important;
    color: #d0021b !important;
    padding: 14px 20px !important;
    border-radius: 20px !important;
    font-size: 14px !important;
    text-decoration: none !important;
    display: inline-block;
    transition: all 0.3s ease;
}

.custom-related-header .view-all-button:hover {
    background-color: #d0021b !important;
    color: #fff !important;
}

/* Thêm icon mũi tên cho nút "Xem tất cả" */
.custom-related-header .view-all-button::after {
    content: '›';
    /* Ký tự mũi tên sang phải */
    margin-left: 8px;
    font-weight: bold;
}

.custom-related-fullwidth {
    width: 100%;
    background: #dedede;
    /* màu nền mày muốn */
    padding: 4rem 0;
    color: #fff;
}

/* Giới hạn nội dung bên trong */
.custom-related-fullwidth .related {
    max-width: 155.2rem;
    margin: 0 auto;
    width: 100%;
}

.custom-related-fullwidth .related h2 {
    color: #fff;
}

/* --- RESPONSIVE --- */

/* Tablet */
@media (max-width: 992px) {
    .custom-related-header {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 20px;
    }

    .custom-related-header .header-text h2 {
        font-size: 22px;
    }

    .custom-related-header .header-text p {
        font-size: 15px;
    }

    .custom-related-header .view-all-button {
        align-self: flex-start;
    }

    .custom-related-fullwidth {
        background: none;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .custom-related-header {
        padding: 0 15px;
    }

    .custom-related-header .header-text h2 {
        font-size: 20px;
    }

    .custom-related-header .header-text p {
        font-size: 14px;
    }

    .custom-related-header .view-all-button {
        width: 100%;
        text-align: center;
    }
}

/* ================================================================
   GIAO DIỆN TRANG SẢN PHẨM & CÁC TÙY BIẾN
   ================================================================ */

/* Huy hiệu "New" */
.badge.new-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.6rem 1.4rem;
    border-radius: 4px;
    font-size: 1.2rem;
    font-family: var(--font-family-text-medium);
    color: #fff;
    background-color: #28a745;
}

.badge.new-badge img {
    height: 14px;
    width: auto;
}

/* Danh mục sản phẩm */
.product-category-list {
    margin-bottom: 10px;
}

.product-category-list a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #f5f5f5;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 13px;
    color: #555;
    text-decoration: none;
}

.product-category-list .cat-icon {
    height: 16px;
}

/* Đánh giá và số lượng đã bán */
.product-meta-reviews {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 15px 0;
}

.product-meta-reviews .rating,
.product-meta-reviews .sold-count {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sold-count img {
    height: 18px;
}

/* Thương hiệu và SKU */
.product-brand-sku {
    display: flex;
    gap: 20px;
    margin: 15px 0;
    padding: 10px 0;
    border-top: 1px dashed #eee;
    border-bottom: 1px dashed #eee;
    font-size: 15px;
}

/* Nhãn số lượng */
.quantity-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

/* Nút Mua Ngay */
.buy-now-button.button.alt {
    background-color: #c92c2c;
    /* Một màu đỏ đậm hơn */
    color: #fff;
}

.buy-now-button.button.alt:hover {
    background-color: #a72424;
}

/* Layout 2 cột cho mô tả và chi tiết */
.custom-tabs-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-top: 40px;
}

.product-details-box {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 20px;
    height: fit-content;
    /* Chỉ cao bằng nội dung */
}

.product-details-box h2 {
    font-size: 18px;
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: #666;
}

.detail-value {
    font-weight: 600;
}

@media (max-width: 768px) {
    .custom-tabs-layout {
        grid-template-columns: 1fr;
    }
}

/* ================================================================
   STYLES CHO AJAX MINI CART POPUP
   ================================================================ */

/* --- Lớp bao bọc chính --- */
.cart-popup-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    transition: visibility 0.3s;
}

.cart-popup-wrapper.is-hidden {
    visibility: hidden;
}

.cart-popup-wrapper.is-visible {
    visibility: visible;
}

/* --- Lớp phủ nền --- */
.cart-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    cursor: pointer;
}

.is-visible .cart-popup-overlay {
    opacity: 1;
}

/* --- Khung nội dung chính (trượt từ phải qua) --- */
.cart-popup-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 90%;
    height: 100%;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.is-visible .cart-popup-content {
    transform: translateX(0);
}

/* --- Header của popup --- */
.cart-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.cart-popup-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.cart-popup-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #888;
    padding: 5px;
}

.cart-popup-close:hover {
    color: #000;
}

/* --- Body (nơi chứa nội dung giỏ hàng) --- */
.cart-popup-body {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
}

.cart-popup-dynamic-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Style cho spinner loading */
.cart-popup-wrapper.is-loading .cart-popup-body::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #DA0011;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* --- Style cho nội dung mini-cart của WooCommerce --- */
.widget_shopping_cart_content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.woocommerce-mini-cart {
    padding: 0 25px;
    margin: 0;
    list-style: none;
    flex-grow: 1;
}

p.woocommerce-mini-cart__empty-message {
    text-align: center;
    margin: auto;
    color: #777;
    font-size: 16px;
}

.woocommerce-mini-cart-item {
    display: flex;
    gap: 15px;
    padding: 20px 0;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
}

.woocommerce-mini-cart-item a {
    text-decoration: none;
    color: #333;
}

.woocommerce-mini-cart-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border: 1px solid #eee;
    border-radius: 4px;
}

.woocommerce-mini-cart-item .quantity {
    display: block;
    font-size: 14px;
    color: #777;
    margin-top: 5px;
}

.remove_from_cart_button {
    font-size: 24px !important;
    color: #aaa !important;
    margin-left: auto;
    padding: 0 5px;
}

.remove_from_cart_button:hover {
    color: #DA0011 !important;
}

/* --- Footer của popup (Tổng tiền, nút bấm) --- */
.woocommerce-mini-cart__total {
    margin: 0;
    padding: 20px 25px;
    border-top: 1px solid #eee;
    font-size: 16px;
    font-weight: 600;
}

.woocommerce-mini-cart__buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding: 0 25px 25px;
}

.woocommerce-mini-cart__buttons .button {
    width: 100%;
    text-align: center;
    padding: 14px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 5px !important;
}

.button.wc-forward:not(.checkout) {
    background-color: #fff !important;
    color: #333 !important;
    border: 1px solid #ddd !important;
}

.button.wc-forward:not(.checkout):hover {
    background-color: #f5f5f5 !important;
    border-color: #ccc !important;
}

.button.checkout {
    background-color: #DA0011 !important;
    color: #fff !important;
    border: 1px solid #DA0011 !important;
}

.button.checkout:hover {
    background-color: #c1000e !important;
    border-color: #c1000e !important;
}

/* Ngăn cuộn trang chính khi popup mở */
body.cart-popup-is-open {
    overflow: hidden;
}

/* Animation cho spinner */
@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}