/* ==========================================================================
   NỀN TẢNG TIÊU CHUẨN (RESET & FONTS)
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

body {
    background-color: #f8f9fa;
    color: #0f172a;
    line-height: 1.5;
}

/* ==========================================================================
   1. KHỐI TRANG CHỦ / DANH SÁCH SẢN PHẨM (PRODUCT LIST)
   ========================================================================== */
.product-wrapper {
    width: 100%;
    padding: 30px 0;
    box-sizing: border-box;
}

/* Lưới sản phẩm thông minh - Chia đều 4 cột bằng chằn chặn */
.product-flex-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin: 0 auto;
    width: 100%;
}

/* Thẻ Card sản phẩm */
.product-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Hiệu ứng bóng đổ nhẹ khi Hover card */
.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.06);
    border-color: #cbd5e1;
}

/* Thẻ A bao bọc toàn bộ nội dung bên trong Card */
.product-card > a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* KHUNG CHỨA ẢNH VUÔNG (TỶ LỆ 1:1) */
.product-image {
    aspect-ratio: 1 / 1;    
    overflow: hidden;
    position: relative; /* Điểm bám tọa độ cho Badges */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f1f5f9;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

/* Hiệu ứng phóng to ảnh nhẹ khi Hover */
.product-card:hover .product-image img {
    transform: scale(1.04);
}

/* CỤM BADGES TRẠNG THÁI TRÊN ẢNH */
.product-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
}

.badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    color: #ffffff;
    width: max-content;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    letter-spacing: 0.5px;
}

.badge-hot { background: linear-gradient(135deg, #f97316, #ef4444); }
.badge-new { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.badge-discount { background: linear-gradient(135deg, #22c55e, #15803d); }

/* KHỐI THÔNG TIN CHỮ (TÊN & GIÁ) */
.product-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Ép cố định chiều cao tên sản phẩm & Tạo hiệu ứng gạch chân slide */
.product-info h3 {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.5;
    
    /* Khóa chiều cao cố định chuẩn 2 dòng chữ rộng rãi */
    height: 45px; 
    margin: 0 0 12px 0;
    
    /* Ẩn chữ thừa nếu tên quá dài và thêm dấu (...) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-shrink: 0;

    position: relative;
    display: inline-block;
    width: 100%;
    transition: color 0.3s ease;
}

/* Tạo nét gạch chân vô hình ẩn phía dưới */
.product-info h3::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #4f46e5; /* Màu tím công nghệ hiện đại */
    transform: scaleX(0);
    transform-origin: bottom left;
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Kích hoạt hiệu ứng chữ và gạch chân khi Hover Card */
.product-card:hover .product-info h3 {
    color: #4f46e5;
}

.product-card:hover .product-info h3::after {
    transform: scaleX(1); /* Thanh gạch chạy mượt từ trái sang phải */
}

/* KHỐI GIÁ TIỀN (GIÁ MỚI & GIÁ CŨ KHUYẾN MÃI) */
.product-price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: auto; /* Đẩy cố định khối giá nằm tắp hàng dưới đáy card */
    flex-wrap: wrap;
}

.price-current,
.product-price div:not(.price-old) { /* Giữ tương thích class cũ của bạn */
    color: #ff4d4f;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.3px;
}

.price-old {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    text-decoration: line-through; /* Nét gạch ngang thân chữ */
}


/* ==========================================================================
   2. KHỐI TRANG CHI TIẾT SẢN PHẨM (PRODUCT DETAIL)
   ========================================================================== */
.detail-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 15px;
}

.detail-flex {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Chia đôi màn hình cân đối tỉ lệ 50-50 */
    gap: 50px;
}

/* Khối bên trái: Hình ảnh chi tiết */
.detail-image-box {
    width: 100%;
}

.detail-image-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.detail-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Khối bên phải: Cụm thông tin & Đặt mua */
.detail-info-box {
    display: flex;
    flex-direction: column;
}

.detail-title {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 16px 0;
    line-height: 1.3;
}

.detail-price {
    font-size: 26px;
    font-weight: 700;
    color: #ff4d4f;
    margin-bottom: 25px;
    background: #fff5f5;
    padding: 10px 16px;
    border-radius: 8px;
    display: inline-block;
    width: max-content;
}

.attribute-group {
    margin-bottom: 24px;
}

.attribute-label {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 10px;
    display: block;
}

/* Thiết kế lại ô Swatch bấm chọn Màu/Size */
.variant-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.swatch-item {
    position: relative;
}

.swatch-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
}

.swatch-label {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    background-color: #fff;
    transition: all 0.2s ease;
    user-select: none;
}

.swatch-label:hover {
    border-color: #4f46e5;
    color: #4f46e5;
}

/* Trạng thái Variant biến thể được chọn */
.swatch-item input[type="radio"]:checked + .swatch-label {
    border-color: #4f46e5;
    background-color: #f5f3ff;
    color: #4f46e5;
    font-weight: 600;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

/* Khối nhập số lượng */
.quantity-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quantity-input {
    width: 75px;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    outline: none;
}

/* Cụm 2 nút bấm Giỏ Hàng & Mua Ngay */
.detail-actions {
    display: flex;
    gap: 16px;
    margin-top: auto; /* Đẩy cụm nút bám cố định đáy hộp thông tin chi tiết */
    padding-top: 30px;
}

.btn-detail {
    flex: 1;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-detail-cart {
    background-color: #ffffff;
    color: #4f46e5;
    border: 2px solid #4f46e5;
}

.btn-detail-cart:hover {
    background-color: #f5f3ff;
}

.btn-detail-buy {
    background-color: #ff4d4f;
    color: #ffffff;
}

.btn-detail-buy:hover {
    background-color: #e03e3e;
}

.section-header {
    display: flex;
    justify-content: space-between; /* Đẩy tiêu đề sang trái, nút xem thêm sang phải */
    align-items: flex-end;         /* Căn chân chữ 2 bên thẳng hàng nhau */
    margin-bottom: 25px;            /* Khoảng cách từ tiêu đề xuống lưới sản phẩm */
    border-bottom: 1px solid #e2e8f0; /* Đường kẻ mờ phân cách sang trọng */
    padding-bottom: 15px;
}

/* Khối chữ bên trái */
.title-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-subtitle {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #4f46e5; /* Màu tím thương hiệu làm điểm nhấn nhỏ */
    letter-spacing: 1px;
}

.section-title {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a; /* Màu xám đen quý phái */
    letter-spacing: -0.5px;
}

/* Nút "Xem tất cả" bên phải */
.view-all-link {
    font-size: 14px;
    font-weight: 700;
    color: #475569;
    text-decoration: none;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-bottom: 4px;
}

.view-all-link span {
    transition: transform 0.2s ease;
}

/* Hiệu ứng khi Hover vào nút Xem tất cả */
.view-all-link:hover {
    color: #4f46e5; /* Đổi chữ sang màu tím */
}

.view-all-link:hover span {
    transform: translateX(4px); /* Mũi tên tự động dịch sang phải sinh động */
}

/* ==========================================================================
   3. HỆ THỐNG ĐÁP ỨNG ĐA MÀN HÌNH (RESPONSIVE CHUẨN ĐẸP)
   ========================================================================== */

/* Màn hình Máy tính bảng / Tablet (Dưới 992px) */
@media (max-width: 992px) {
    .product-flex-container {
        grid-template-columns: repeat(3, 1fr); /* Thu gọn còn 3 sản phẩm một hàng */
        gap: 15px;
    }
    
    .detail-flex {
        grid-template-columns: 1fr; /* Trang chi tiết chuyển về 1 cột dọc */
        gap: 30px;
    }
}

/* Màn hình Điện thoại di động nhỏ gọn (Dưới 640px) */
@media (max-width: 640px) {
    .product-flex-container {
        grid-template-columns: repeat(2, 1fr); /* Tiêu chuẩn TMĐT hiển thị 2 cột cực đẹp */
        gap: 12px;
        padding: 0 10px;
    }

    .product-info {
        padding: 12px;
    }

    .product-info h3 {
        font-size: 14px;
        height: 42px; /* Hạ nhẹ chiều cao khung chữ trên mobile */
    }

    .price-current,
    .product-price div:not(.price-old) {
        font-size: 15px;
    }

    .price-old {
        font-size: 12px;
    }

    .badge {
        font-size: 10px;
        padding: 3px 6px;
    }

    .detail-title {
        font-size: 22px;
    }

    .detail-actions {
        flex-direction: column; /* Hai nút lớn chuyển sang xếp chồng hàng dọc */
        gap: 12px;
    }

    .btn-detail {
        width: 100%;
        padding: 14px;
    }
        .section-header {
        margin-bottom: 18px;
        padding-bottom: 10px;
    }
    
    .section-title {
        font-size: 20px; /* Thu nhỏ tiêu đề trên điện thoại tránh chiếm diện tích */
    }
    
    .section-subtitle {
        font-size: 10px;
    }
    
    .view-all-link {
        font-size: 13px;
    }
}


/* ==========================================================================
   THIẾT KẾ ĐẶC BIỆT RIÊNG CHO TIÊU ĐỀ NGÀNH HÀNG (CATEGORY HEADER)
   ========================================================================== */

/* Khung bọc: Biến đường kẻ đáy thành đường xuyên tâm nằm chính giữa dòng */
.category-header-style {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Căn giữa trục dọc */
    margin-bottom: 30px;
    margin-top: 20px;
    border-bottom: none; /* XÓA BỎ ĐƯỜNG KẺ ĐÁY CỦA SẢN PHẨM BÁN CHẠY */
    position: relative;
    width: 100%;
}

/* Tạo đường kẻ ngang hiện đại xuyên qua hông tiêu đề */
.category-header-style::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 1px;
    background-color: #e2e8f0; /* Đường kẻ mảnh sang trọng */
    z-index: 1;
}

/* Đẩy chữ tên ngành hàng và nút Xem tất cả nổi lên trên đường kẻ */
.category-header-style .title-left,
.category-header-style .view-all-link {
    position: relative;
    z-index: 2;
    background-color: #f8f9fa; /* BẮT BUỘC: Trùng với màu nền web của bạn để che đường kẻ đi */
}

/* BIẾN TÊN NGÀNH HÀNG THÀNH DẠNG KHỐI TAG CAPSULE SANG TRỌNG */
.category-header-style .section-title {
    font-size: 16px;            /* Hạ size chữ nhỏ hơn Sản phẩm bán chạy (24px) */
    font-weight: 700;
    color: #4f46e5;             /* Đổi sang màu tím thương hiệu làm điểm nhấn */
    text-transform: uppercase;  /* Viết hoa chữ cái quý phái */
    letter-spacing: 0.5px;
    
    background-color: #f5f3ff;  /* Nền tím mờ nhẹ */
    padding: 8px 20px;          /* Tạo khoảng trống bo góc xung quanh chữ */
    border-radius: 30px;        /* Bo tròn hoàn hảo thành hình viên thuốc */
    border: 1px solid #e0e7ff;  /* Viền mảnh đồng bộ */
    padding-right: 25px;        /* Chừa khoảng trống bên phải cách đường kẻ */
}

/* TINH CHỈNH NÚT XEM TẤT CẢ CHO TIÊU ĐỀ NGÀNH HÀNG */
.category-header-style .view-all-link {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    padding-left: 20px;         /* Tạo khoảng trắng che đường kẻ bên trái nút */
    text-transform: none;
}

.category-header-style .view-all-link span {
    display: inline-block;
    transition: transform 0.2s ease;
}

/* Hiệu ứng tương tác riêng khi hover nút của ngành hàng */
.category-header-style .view-all-link:hover {
    color: #4f46e5;
}
.category-header-style .view-all-link:hover span {
    transform: translateX(3px);
}

/* ==========================================================================
   TỐI ƯU RESPONSIVE TRÊN MOBILE
   ========================================================================== */
@media (max-width: 640px) {
    .category-header-style {
        margin-bottom: 20px;
    }
    /* Ẩn đường kẻ ngang trên mobile để giao diện đỡ rối mắt */
    .category-header-style::before {
        display: none;
    }
    .category-header-style .section-title {
        font-size: 14px;
        padding: 6px 14px;
    }
    .category-header-style .view-all-link {
        font-size: 12px;
    }
}
