/* ==========================================================================
   CUSTOM PRODUCT ARCHIVE (SHOP / CATEGORY PAGE) - 2 COLUMNS STYLE (1440PX)
   ========================================================================== */

/* ÉP SẠCH PHÔNG CHỮ LEXEND */
.custom-shop-breadcrumb-row,
.custom-shop-main,
.custom-shop-main * {
    font-family: var(--font-lexend), sans-serif !important;
    box-sizing: border-box;
}

html, body {
    max-width: 100% !important;
    overflow-x: clip !important; /* Khử hoàn toàn thanh cuộn ngang mà không phá sticky header */
}

/* 1. BREADCRUMB DÒNG TRÊN CÙNG */
.custom-shop-breadcrumb-row {
    max-width: var(--container-max-w, 1200px) !important; /* Đồng bộ độ rộng tối đa hệ thống */
    width: 100% !important;
    margin: 0 auto !important;
    padding-top: 40px !important;
    padding-bottom: 10px !important;
    padding-left: var(--container-pad-x, 10px) !important; /* Kế thừa lề hệ thống */
    padding-right: var(--container-pad-x, 10px) !important;
    box-sizing: border-box !important;
}

.custom-shop-breadcrumb-row .woocommerce-breadcrumb,
.custom-shop-breadcrumb-row nav {
    background: transparent !important;
    border: none !important;
    font-size: 13.5px !important;
    color: var(--text-grey, #7B8A99) !important;
    margin: 0 !important;
    padding: 0 !important;
}

.custom-shop-breadcrumb-row a {
    color: var(--text-grey, #7B8A99) !important;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.custom-shop-breadcrumb-row a:hover {
    color: var(--color-accent, #027CC5) !important; /* Đổi màu hover về màu Accent mới */
}

/* 2. CHIA KHUNG 2 CỘT CHÍNH */
.custom-shop-main {
    max-width: var(--container-max-w, 1200px) !important; /* Đồng bộ độ rộng tối đa hệ thống */
    width: 100% !important;
    margin: 0 auto !important;
    padding-top: 10px !important;
    padding-bottom: 60px !important;
    padding-left: var(--container-pad-x, 10px) !important; /* Kế thừa lề hệ thống */
    padding-right: var(--container-pad-x, 10px) !important;
    box-sizing: border-box !important;
}

.custom-shop-layout {
    display: flex !important;
    gap: 40px !important;
    align-items: flex-start !important;
    box-sizing: border-box !important;
}

/* CỘT TRÁI - SIDEBAR (BỘ LỌC) */
.custom-shop-sidebar {
    width: 260px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}

.custom-sidebar-section {
    background-color: transparent;
    transition: all 0.3s ease;
}

.custom-sidebar-header-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.custom-sidebar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-title, #000000) !important; /* Đổi về màu đen tối thiểu */
    margin: 0 0 10px 0;
}

.custom-sidebar-chevron {
    display: none; /* Ẩn trên desktop */
    color: var(--text-dark, #000000);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    line-height: 1;
}

.custom-sidebar-divider {
    width: 100%;
    height: 1px;
    background-color: #E2E8F0 !important;
    margin-bottom: 20px;
}

.custom-sidebar-heading {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark, #000000) !important; /* Đổi về màu đen tối thiểu */
    margin: 0 0 18px 0;
}

.custom-cat-filter-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.custom-cat-filter-list li {
    margin-bottom: 8px;
}

.custom-cat-filter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none !important;
    color: var(--text-dark, #000000) !important; /* Chuyển màu chữ tối về màu đen */
    opacity: 0.8 !important; /* Phân cấp nhẹ cho các liên kết thường */
    font-size: 14.5px;
    padding: 6px 0;
    transition: all 0.2s ease;
}

.custom-cat-filter-item:hover {
    color: var(--color-accent, #027CC5) !important;
    opacity: 1 !important;
}

.custom-cat-label-wrap {
    display: flex;
    align-items: center;
    min-width: 0;
}

/* Checkbox tùy chỉnh hình vuông bo góc nhạt */
.custom-checkbox-box {
    width: 17px;
    height: 17px;
    border: 1.5px solid var(--text-grey, #7B8A99);
    border-radius: 4px;
    margin-right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: #ffffff;
    transition: all 0.2s ease;
}

/* Khi Danh mục được chọn hoạt động */
.custom-cat-filter-item.active {
    color: var(--color-accent, #027CC5) !important; /* Đổi sang màu Accent mới */
    font-weight: 600;
    opacity: 1 !important;
}

.custom-cat-filter-item.active .custom-checkbox-box {
    background-color: var(--color-accent, #027CC5) !important; /* Đổi sang màu Accent mới */
    border-color: var(--color-accent, #027CC5) !important;
}

/* Vẽ ký tự tích chọn (V trắng) */
.custom-cat-filter-item.active .custom-checkbox-box::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

/* Biểu tượng dấu cộng (+) bên phải danh mục */
.custom-cat-toggle-icon {
    font-size: 18px;
    font-weight: 300;
    color: var(--color-accent, #027CC5) !important; /* Đổi sang màu Accent mới */
}

/* CỘT PHẢI - CONTENT (TỰ ĐỘNG CO LẠI VỪA KHÍT) */
.custom-shop-content {
    flex: 1 !important;        /* Tự lấy khoảng trống còn lại của layout */
    min-width: 0 !important;    /* Ngăn lưới con kéo phình kích thước cột */
    box-sizing: border-box !important;
}

.custom-shop-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #f2f2f2;
    padding-bottom: 15px;
}

.custom-shop-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-title, #000000) !important; /* Chuyển màu chữ tối về màu đen */
    text-transform: uppercase;
    margin: 0 !important;
    letter-spacing: 0.5px;
}

/* DROPDOWN SẮP XẾP SẢN PHẨM */
.custom-shop-toolbar {
    display: flex;
    align-items: center;
}

.custom-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #ffffff !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    border: 1px solid #dcdcdc !important;
    padding: 8px 36px 8px 14px !important;
    font-family: var(--font-lexend), sans-serif;
    font-size: 14px;
    color: var(--text-dark, #000000);
    cursor: pointer;
    outline: none;
    border-radius: 4px;
}

/* LƯỚI SẢN PHẨM (CHIA ĐỀU ĐÚNG 3 CỘT SẢN PHẨM) */
.custom-product-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important; /* Ép co giãn 3 cột */
    gap: 30px 20px !important;
    width: 100% !important;
}

/* Ép ảnh sản phẩm thành hình vuông tỉ lệ 1:1 găn cứng để card không bị quá to */
.product-card .product-card__img,
.product-card__img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important; /* Bắt buộc vuông 1:1 */
    overflow: hidden !important;
}

.product-card {
    width: 100% !important;
    max-width: 100% !important;
}

/* 4. PAGINATION (PHÂN TRANG CHUẨN XANH DƯƠNG) */
.custom-pagination {
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: 6px; 
    margin-top: 40px;
}

.custom-pagination a {
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    width: 28px; 
    height: 28px;
    border: 1px solid #dcdcdc; 
    color: var(--text-dark, #000000); 
    font-size: 13px; 
    font-weight: 500; 
    text-decoration: none;
    background-color: #ffffff;
    transition: all 0.2s ease;
}

.custom-pagination a:hover { 
    border-color: #999999; 
    color: var(--color-accent, #027CC5); 
}

.custom-pagination a.active {
    background-color: var(--color-accent, #027CC5) !important; /* Đổi màu phân trang active sang màu Accent mới */
    border-color: var(--color-accent, #027CC5) !important; 
    color: var(--text-white, #ffffff) !important; 
    font-weight: 600;
}

/* ==========================================================================
   RESPONSIVE LAYOUT (ĐỒNG BỘ ĐIỂM GÃY BREAKPOINT 1200PX)
   ========================================================================== */

/* TABLET & LAPTOP NHỎ (Dưới hoặc bằng 1200px) */
@media (max-width: 1200px) {
    .custom-shop-layout {
        flex-direction: column !important;
        gap: 25px !important;
    }

    .custom-shop-sidebar {
        width: 100% !important;
    }

    /* HỘP BỘ LỌC DẠNG DROPDOWN / ACCORDION THEO MẪU */
    .custom-sidebar-section {
        border: 1px solid #dcdcdc !important;
        background-color: #ffffff !important;
        padding: 12px 16px !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
    }

    .custom-sidebar-header-toggle {
        cursor: pointer !important;
        user-select: none;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px !important;
    }

    .custom-sidebar-title {
        font-size: 18px !important;
        font-weight: 700 !important;
        margin: 0 !important;
        color: var(--text-dark, #000000) !important;
    }

    .custom-sidebar-chevron {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        color: var(--text-dark, #000000) !important;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* Mặc định đóng trên mobile */
    .custom-sidebar-collapse-body {
        display: none;
        margin-top: 14px;
        padding-top: 6px;
    }

    /* Khi bấm mở ra */
    .custom-sidebar-section.is-open .custom-sidebar-collapse-body {
        display: block !important;
        animation: sidebarSlideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }

    /* Mũi tên ^ xoay ngược mượt mà khi mở */
    .custom-sidebar-section.is-open .custom-sidebar-chevron {
        transform: rotate(180deg) !important;
    }

    .custom-sidebar-section .custom-sidebar-divider {
        margin-top: 4px;
        margin-bottom: 16px;
    }

    .custom-product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important; /* Giữ 3 cột sản phẩm thoáng đãng */
        gap: 20px 15px !important;
    }
}

@keyframes sidebarSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* MOBILE (Dưới 767px) */
@media (max-width: 767px) {
    .custom-shop-breadcrumb-row {
        padding-top: 40px !important; 
        padding-bottom: 10px !important;
        padding-left: var(--container-pad-x, 16px) !important;
        padding-right: var(--container-pad-x, 16px) !important;
    }

    .custom-shop-main {
        padding-top: 10px !important;
        padding-bottom: 40px !important;
        padding-left: var(--container-pad-x, 16px) !important;
        padding-right: var(--container-pad-x, 16px) !important;
    }

    .custom-shop-header-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .custom-shop-title {
        font-size: 24px !important;
    }

    .custom-shop-toolbar {
        width: 100%;
    }

    .custom-select {
        width: 100%;
    }

    /* TRÊN ĐIỆN THOẠI CHIA THÀNH LƯỚI 2 CỘT SẢN PHẨM */
    .custom-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 20px 10px !important;
    }
}