/* ==========================================================================
   1. KHUNG CHỨA BỘ LỌC CHÍNH (FORM)
   ========================================================================== */
#product-filter-form {
    background: #ffffff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #f0f0f0;
    box-sizing: border-box;
}

.filter-group {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid #f2f2f2;
}

.filter-group:last-of-type {
    border-bottom: none;
    margin-bottom: 10px;
    padding-bottom: 0;
}

.filter-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #222222;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Ô nhập tìm kiếm từ khóa */
.filter-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    font-size: 14px;
    color: #333333;
    transition: all 0.25s ease-in-out;
    box-sizing: border-box;
}

.filter-input:focus {
    border-color: #ff5722;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 87, 34, 0.15);
}

/* ==========================================================================
   2. SỬA LỖI CÂY DANH MỤC ĐỆ QUY (CHECKBOX TREE)
   ========================================================================== */
.checkbox-filter-container {
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    background-color: #fafafa;
}

/* Tùy chỉnh thanh cuộn siêu mỏng cho cây danh mục */
.checkbox-filter-container::-webkit-scrollbar {
    width: 4px;
}
.checkbox-filter-container::-webkit-scrollbar-thumb {
    background: #dddddd;
    border-radius: 4px;
}

.filter-checkbox-tree, 
.filter-checkbox-tree ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.filter-checkbox-tree li {
    list-style: none !important;
    margin: 0 !important;
    padding: 5px 0;
    position: relative;
}

/* Khối nhãn chứa checkbox + text (Ép thẳng hàng tuyệt đối) */
.checkbox-tree-item {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #444444;
    line-height: 1.4;
    margin: 0 !important;
    user-select: none;
}

/* Định dạng riêng ô checkbox vuông */
.checkbox-tree-item input[type="checkbox"] {
    accent-color: #ff5722;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-tree-item span {
    transition: color 0.2s ease;
}

.checkbox-tree-item:hover span {
    color: #ff5722;
}

/* CSS xử lý đệ quy lùi cấp cho danh mục con/cháu */
.nested-tree-level {
    margin-left: 8px !important;
    padding-left: 14px !important;
    border-left: 1px dashed #cccccc;
}

/* Nhánh gạch ngang nối vào danh mục con */
.nested-tree-level > li::before {
    content: "";
    position: absolute;
    top: 15px;
    left: 0;
    width: 8px;
    height: 1px;
    border-top: 1px dashed #cccccc;
}

/* Khử nét thừa cho phần tử cuối cùng của nhánh */
.nested-tree-level > li:last-child {
    border-left: none;
}
.nested-tree-level > li:last-child::before {
    border-left: 1px dashed #cccccc;
    height: 15px;
    top: 0;
}

/* ==========================================================================
   3. KHỐI CHỌN NHANH MỨC GIÁ (RADIO BUTTONS)
   ========================================================================== */
.quick-price {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.quick-price-btn {
    display: block;
    padding: 8px 4px;
    background: #ffffff;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    font-size: 13px;
    color: #555555;
    text-align: center;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
    cursor: pointer;
    user-select: none; /* Ngăn bôi đen chữ khi người dùng click nhanh nhiều lần */
}

.quick-price-btn:hover {
    border-color: #ff5722;
    color: #ff5722;
}

/* Giao diện khi nút ĐƯỢC ACTIVE (Click lần 1) */
.quick-price-btn.active {
    background: #fff5f2 !important;
    border-color: #ff5722 !important;
    color: #ff5722 !important;
    font-weight: 600;
}

.quick-price-item {
    display: block;
    margin: 0 !important;
    cursor: pointer;
}

.quick-price-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.quick-price-item span {
    display: block;
    padding: 8px 4px;
    background: #ffffff;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    font-size: 13px;
    color: #555555;
    text-align: center;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-price-item input[type="radio"]:checked + span {
    background: #fff5f2;
    border-color: #ff5722;
    color: #ff5722;
    font-weight: 500;
}

/* ==========================================================================
   4. THANH KÉO SLIDER & Ô HIỂN THỊ KHOẢNG GIÁ
   ========================================================================== */
#price-range-slider {
    margin: 15px 5px 20px 5px; /* Tạo khoảng trống cho thanh kéo slider */
}

.price-range-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.price-input-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: #fdfdfd;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    padding: 0 10px;
}

.price-input-box span {
    font-size: 12px;
    color: #888888;
    white-space: nowrap;
}

.price-filter-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 13px;
    color: #333333;
    font-weight: 600;
    text-align: right;
    outline: none;
}

.range-divider {
    color: #999999;
    font-weight: bold;
}

/* ==========================================================================
   5. Ô CHỌN SẮP XẾP (SELECT OPTION) & NÚT SUBMIT
   ========================================================================== */
.filter-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    font-size: 14px;
    color: #444444;
    background-color: #ffffff;
    cursor: pointer;
    outline: none;
    box-sizing: border-box;
}

.filter-select:focus {
    border-color: #ff5722;
}

.filter-actions {
    margin-top: 15px;
}

.btn-search-submit {
    width: 100%;
    padding: 12px;
    background: #ff5722;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease;
}

.btn-search-submit:hover {
    background: #e64a19;
}

/* ==========================================================================
   6. CẤU HÌNH RESPONSIVE (PC TRỰC QUAN / MOBILE SIDEBAR TRƯỢT)
   ========================================================================== */

/* Trạng thái mặc định trên Máy tính (PC) -> Ẩn các nút điều hướng Mobile */
.btn-trigger-filter-mobile, 
.filter-mobile-header, 
.filter-overlay {
    display: none;
}

/* Giao diện dành riêng cho Di động & Máy tính bảng (Dưới 768px) */
@media (max-width: 768px) {
    
    /* Hiện nút mở bộ lọc chính */
    .btn-trigger-filter-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px;
        background: #ffffff;
        color: #ff5722;
        border: 1px solid #ff5722;
        border-radius: 6px;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        margin-bottom: 15px;
    }

    /* Ép Form lọc chuyển thành một hộp thoại Sidebar ẩn bên phải màn hình */
    #product-filter-form {
        position: fixed;
        top: 0;
        left: -320px; /* ĐỔI TỪ RIGHT THÀNH LEFT: Đẩy khuất về bên trái */
        right: auto;  /* Hủy cấu hình right cũ nếu có */
        width: 300px;
        height: 100%;
        z-index: 9999;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.15); /* Đổi bóng đổ hướng sang phải */
        border-radius: 0;
        overflow-y: auto;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* ĐỔI HIỆU ỨNG THEO BIẾN LEFT */
    }

    /* Khi kích hoạt class này bằng JS, form sẽ trượt ra ngoài */
    #product-filter-form.active {
        left: 0; /* ĐỔI TỪ RIGHT THÀNH LEFT */
    }
    /* Thanh Header trên cùng của bộ lọc trên Mobile */
    .filter-mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 14px;
        margin-bottom: 18px;
        border-bottom: 2px solid #f5f5f5;
    }

    .filter-mobile-header span {
        font-weight: 700;
        font-size: 16px;
        color: #222222;
    }

    /* Nút dấu X dùng đóng bộ lọc nhanh */
    #close-filter-btn {
        background: none;
        border: none;
        font-size: 28px;
        color: #999999;
        cursor: pointer;
        line-height: 1;
        padding: 0;
        margin: 0;
    }

    /* Lớp màn đen mờ bao phủ trang web */
    .filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        z-index: 9998;
        display: none;
        backdrop-filter: blur(2px); /* Tùy chọn làm mờ nhẹ hậu cảnh */
    }

    .filter-overlay.active {
        display: block;
    }
}
/* Ép buộc tăng khoảng thụt lề bằng thuộc tính !important cường độ cao */
.checkbox-filter-container ul.nested-tree-level {
    list-style: none !important;
    margin: 0 0 0 18px !important;   /* Đẩy lùi khối con sang phải so với cha */
    padding: 0 0 0 14px !important;  /* Tạo khoảng trống bên trong nhánh */
    border-left: 1px dashed #cccccc !important; /* Đường kẻ dọc kết nối */
    display: block !important;       /* Ép hiển thị dạng khối để nhận margin */
    position: relative !important;
}

/* Đảm bảo các thẻ li con bên trong nhận đúng thuộc tính */
.checkbox-filter-container ul.nested-tree-level > li {
    list-style: none !important;
    padding: 4px 0 !important;
    margin: 0 !important;
    position: relative !important;
}

/* Tạo nhánh gạch ngang đâm vào ô checkbox con */
.checkbox-filter-container ul.nested-tree-level > li::before {
    content: "" !important;
    position: absolute !important;
    top: 15px !important;
    left: -14px !important;          /* Căn chỉnh khớp với khoảng padding 14px phía trên */
    width: 10px !important;
    height: 1px !important;
    border-top: 1px dashed #cccccc !important;
}

/* Khử nét thừa dọc cho danh mục con nằm cuối cùng của mỗi nhánh */
.checkbox-filter-container ul.nested-tree-level > li:last-child {
    border-left: none !important;
}
/* Container bọc 2 ô nhập và dấu gạch ngang */
.price-range-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

/* Từng ô nhập giá */
.price-input-field {
    flex: 1;
    position: relative;
}

.price-custom-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    font-size: 14px;
    color: #333333;
    font-weight: 500;
    text-align: center; /* Căn giữa chữ cho cân đối */
    background-color: #ffffff;
    transition: all 0.2s ease-in-out;
    box-sizing: border-box;
}

/* Hiệu ứng khi nhấn chọn vào ô nhập */
.price-custom-input:focus {
    border-color: #ff5722;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 87, 34, 0.12);
    background-color: #fff;
}

/* Thanh gạch ngang nhỏ nối giữa 2 ô */
.price-range-line {
    width: 12px;
    height: 1px;
    background-color: #999999;
    flex-shrink: 0;
}

/* Định dạng chữ gợi ý (Placeholder) */
.price-custom-input::placeholder {
    color: #bbbbbb;
    font-weight: 400;
}

