﻿/*==========================================================================
    PRODUCT FILTER - OPTIMIZED FLAT THEME
==========================================================================*/

/* Khung bọc ngoài bộ lọc */
.product-filter {
    background: #fff;
    border: 1px solid #eef1f5; /* Viền mờ nhẹ tinh tế */
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

/* Thanh sắp xếp trên cùng (Nền trắng, dàn hàng ngang) */
.filter-sort {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f2f4f7;
    background: #ffffff;
}

.filter-sort-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px; /* Khoảng cách vừa phải giữa các nút radio */
}

/* Chữ "Xếp theo" và Icon xám tối giản */
.sort-title {
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sort-title i {
    color: #4a5568;
    font-size: 15px;
}

/* Thiết kế ô chọn Radio phẳng */
.sort-radio-label {
    cursor: pointer;
    margin: 0;
    font-size: 14px;
    color: #2d3748;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

.sort-radio-label input[type="radio"] {
    margin: 0;
    width: 15px;
    height: 15px;
    accent-color: #0d6efd; /* Màu xanh hiện đại khi tích chọn */
    cursor: pointer;
}

.filter-sort-right {
    margin-left: auto;
}

/* ĐỒNG BỘ NÚT LỌC SẢN PHẨM */
#btnFilterProduct {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    min-width: 65px;
    height: 32px;
    padding: 0 14px;

    background: #eef1f6;
    color: #333333;
    border: none;
    border-radius: 4px;

    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s ease;
}

#btnFilterProduct i {
    color: #555555;
    font-size: 13px;
    margin-left: 4px;
}

#btnFilterProduct:hover {
    background: #0066ff;
    color: #fff;
    border-color: #0066ff;
}

/* Panel chứa các danh mục lọc ẩn/hiện */
.filter-panel {
    display: none;
    width: 100%;
    border-top: 1px solid #ececec;
    background: #fff;
    overflow: hidden;
    animation: fadeFilter .25s ease-out;
}

.filter-column {
    flex: 1;
    border-right: 1px solid #efefef;
}

.filter-column:last-child {
    border-right: none;
}

.filter-title {
    padding: 15px;
    font-weight: 700;
    font-size: 16px;
    background: #f7f7f7;
    border-bottom: 1px solid #ededed;
}

/* Vùng cuộn chứa Checkbox (Thương hiệu, Giá, Loại) */
.filter-body {
    max-height: 280px;
    overflow-y: auto;
    padding: 12px;
}

.filter-check {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 14px;
}

.filter-check input {
    width: 16px;
    height: 16px;
    margin-right: 10px;
}

.filter-check span {
    color: #444;
    transition: color 0.2s;
}

.filter-check:hover span {
    color: #0066ff;
}

/* Tùy chỉnh Scrollbar mượt mà */
.filter-body::-webkit-scrollbar {
    width: 8px;
}

.filter-body::-webkit-scrollbar-thumb {
    background: #d8d8d8;
    border-radius: 20px;
}

.filter-body::-webkit-scrollbar-thumb:hover {
    background: #bdbdbd;
}

/* Hiệu ứng mượt khi bấm nút mở Panel */
@keyframes fadeFilter {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/*==========================================================================
    PAGINATION (PHÂN TRANG CHUẨN) GIAO DIỆN DESKTOP
==========================================================================*/
.pagination {
    user-select: none;
    display: flex;
    gap: 6px;
}

.pagination .page-link {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    text-decoration: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: all .25s ease;
    cursor: pointer;
}

.pagination .page-item.active .page-link,
.pagination .page-item.current-page .page-link {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
    font-weight: bold;
}

.pagination .page-item:not(.active):not(.disabled) .page-link:hover {
    background: #e9ecef;
    color: #0d6efd;
}

.pagination .page-item.disabled .page-link {
    cursor: default;
    opacity: 0.5;
    background: #f8f9fa;
    color: #6c757d;
}

/*==========================================================================
    ÉP BUỘC HỆ THỐNG NHẬN DIỆN FONT AWESOME CHO ICON
==========================================================================*/
.sort-title i,
#btnFilterProduct i {
    font-family: 'FontAwesome' !important;
    font-style: normal !important;
    font-weight: normal !important;
    display: inline-block !important;
    line-height: 1 !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.sort-title i::before {
    content: "\f15d" !important; /* fa-sort-alpha-asc */
}

/* HIỆU ỨNG XOAY ICON PHỄU THÀNH DẤU X KHI BẤM */
#btnFilterProduct i {
    transition: transform 0.3s ease-in-out, color 0.3s ease !important;
}

#btnFilterProduct i::before {
    content: "\f0b0" !important; /* fa-filter */
}

#btnFilterProduct.active i {
    transform: rotate(180deg) !important;
    color: #dc3545 !important; /* Đổi sang đỏ khi là dấu X */
}

#btnFilterProduct.active i::before {
    content: "\f00d" !important; /* Biến thành fa-times (Dấu X) */
}

/*==========================================================================
    RESPONSIVE TABLET & MOBILE (MAX-WIDTH: 991PX)
==========================================================================*/
@media(max-width: 991px) {
    .product-filter {
        border: none;
        background: transparent;
        margin-bottom: 15px;
    }

    .filter-sort {
        display: flex;
        flex-direction: row !important;
        justify-content: space-between;
        padding: 0;
        background: transparent;
        border-bottom: none;
        gap: 12px;
    }

    .filter-sort-left {
        flex: 1;
        gap: 0;
    }

    .sort-title {
        width: 100%;
        height: 42px;
        background: #eef1f6;
        color: #333333;
        border-radius: 4px;
        font-size: 14px;
        font-weight: 500;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        cursor: pointer;
    }

    .sort-radio-label {
        display: none !important; /* Ẩn radio trên mobile */
    }

    .filter-sort-right {
        flex: 1;
        margin-left: 0;
    }

    #btnFilterProduct {
        width: 100% !important;
        height: 42px !important;
        font-size: 14px !important;
        background: #eef1f6 !important;
        border-radius: 4px !important;
    }

    .filter-panel {
        flex-direction: column;
        border: 1px solid #ececec;
        margin-top: 10px;
        border-radius: 4px;
    }

    .filter-column {
        border-right: none;
        border-bottom: 1px solid #eee;
    }

    .filter-column:last-child {
        border-bottom: none;
    }
}

/*==========================================================================
    RESPONSIVE SMARTPHONE (MAX-WIDTH: 576PX) - THU NHỎ HÌNH TRÒN PHÂN TRANG
==========================================================================*/
@media (max-width: 576px) {
    .pagination {
        display: flex !important;
        gap: 5px !important;
        justify-content: center !important;
        flex-wrap: nowrap !important; /* Ép không cho vỡ dòng */
    }

    .pagination .page-item {
        margin: 0 !important;
        padding: 0 !important;
    }

    .pagination .page-link {
        /* Thiết lập chiều rộng và chiều cao bằng nhau tuyệt đối để thành hình tròn */
        width: 32px !important;
        min-width: 32px !important;
        height: 32px !important;
        max-height: 32px !important;

        /* Ép thành hình tròn hoàn hảo */
        border-radius: 50% !important;

        /* Xóa bỏ hoàn toàn padding của hệ thống cũ gây lệch tâm */
        padding: 0 !important;
        margin: 0 !important;
        font-size: 13px !important;
        line-height: 32px !important; /* Đưa text về tâm */

        /* Căn giữa chuẩn */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }
}