/* Filter Bar Styles */
.becar-filter-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 0;
    margin-bottom: 10px;
    flex-wrap: wrap;
    border-bottom: 1px solid #e0e0e0;
}

.becar-sort-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.becar-sort-wrapper label {
    font-weight: 500;
    margin: 0;
    white-space: nowrap;
}

.becar-orderby {
    padding: 5px 12px 8px 12px;
    border: 1px solid #e0e0e0;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
}

.becar-filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 12px !important;
    background: #fff;
    border: 1px solid #e0e0e0;
    font-size: 12px !important;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #437278;
}

.becar-filter-btn:hover {
    background: #f5f5f5;
    border-color: #333;
}

.becar-filter-btn svg {
    width: 14px !important;
    height: 14px !important;
}

/* Active Filters */
.becar-active-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.becar-popup-active-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 0 0;
    min-height: 24px;
}

.becar-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px;
    background: #cdeeff;
    border-radius: 20px;
    font-size: 12px;
}

.becar-filter-tag .remove {
    cursor: pointer;
    font-weight: bold;
    color: #666;
}

.becar-filter-tag .remove:hover {
    color: #000;
}

.becar-clear-all {
    color: #dc3545;
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
}

/* Popup Styles */
.becar-filter-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.becar-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.becar-popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.becar-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}
.becar-sort-wrapper select {
    margin-bottom: 0px;
}
.becar-filter-bar button {
    margin-bottom: 0px;
}

.becar-popup-header h3 {
    margin: 0;
    font-size: 18px;
}

.becar-popup-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.becar-popup-close:hover {
    color: #000;
}

.becar-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.becar-filter-section {
    margin-bottom: 15px;
}

.becar-filter-section h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 600;
}

/* Price Filter */
.becar-price-ranges {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.becar-price-option {
display: flex;
    align-items: center;
    padding: 6px !important;
    border: 1px solid #e0e0e0;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px !important;
    min-width: 0;
    max-width: 140px;
}

.becar-price-option:hover {
    border-color: #288ad6;
    color: #288ad6 ;
    background: #f9f9f9;
}

.becar-price-option input[type="radio"] {
    display: none !important;
}

.becar-custom-price p {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #007cba;
    font-weight: 700;
}

.becar-price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.becar-price-inputs input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.becar-price-slider {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin: 10px 0;
    /* noUiSlider custom */
}

/* Attribute Filter */
.becar-attribute-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.becar-attribute-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px !important;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px !important;
    min-width: 0;
    max-width: 140px;
}

.becar-attribute-option:hover {
    border-color: #288ad6;
    color: #288ad6;
    background: #f9f9f9;
}

.becar-attribute-option input[type="checkbox"] {
    display: none !important;
}

.becar-attribute-option img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
}

.becar-attribute-option span {
    font-size: 13px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Popup Footer */
.becar-popup-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

.becar-btn-secondary,
.becar-btn-primary {
flex: 1;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.becar-btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.becar-btn-secondary:hover {
    background: #e0e0e0;
}

.becar-btn-primary {
    background: #fd6709;
    color: #fff;
}

.becar-btn-primary:hover {
    background: #000;
}
.becar-price-option span {
    font-weight: 400;
}
.becar-attribute-option span {
    font-weight: 400;
}
/* Mobile Responsive */
@media (max-width: 768px) {
    .becar-filter-bar {
        flex-wrap: wrap !important;
        align-items: flex-start !important;
    }
    .becar-sort-wrapper,
    .becar-filter-btn {
        margin-bottom: 0 !important;
    }
    .becar-active-filters {
        width: 100% !important;
        margin-top: 10px;
        order: 2;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
        justify-content: flex-start !important;
    }
    .becar-filter-tag,
    .becar-clear-all {
        width: auto;
        text-align: left;
        margin-bottom: 0;
    }
}

/* Active state styles */
.becar-price-option.active,
.becar-attribute-option.active,
.becar-price-option input:checked ~ span,
.becar-attribute-option input:checked ~ span {
    background: #f0f8ff;
    border-color: #288ad6;
    color: #288ad6;
}
.becar-price-option.active span,
.becar-attribute-option.active span,
.becar-price-option input:checked ~ span,
.becar-attribute-option input:checked ~ span {
    color: #288ad6;
}

.becar-filter-popup.active {
    display: block;
}

/* Loading state */
.becar-loading {
    opacity: 0.6;
    pointer-events: none;
}

.becar-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* noUiSlider custom styles */
.noUi-target {
    height: 4px !important;
    background: #e0e0e0 !important;
    border-radius: 2px !important;
}

.noUi-connect {
    background: #fd6709 !important;
}

.noUi-handle {
    width: 16px !important;
    height: 16px !important;
    top: -6px !important;
    border-radius: 50% !important;
    border: 2px solid #fd6709 !important;
    background: #fff !important;
    box-shadow: none !important;
    cursor: pointer;
}
.noUi-handle:after,
.noUi-handle:before {
    display: none !important;
}

/* 1. Dàn hàng ngang, căn trái cho khoảng giá và thuộc tính */
.becar-price-ranges,
.becar-attribute-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    align-items: flex-start;
}

/* 2. Thanh kéo thả khoảng giá to hơn, màu xanh dương */
.becar-price-slider,
.noUi-target {
    height: 8px !important;
    background: #e6f3ff !important;
    border-radius: 4px !important;
}
.noUi-connect {
    background: #007cba !important;
}
.noUi-handle {
    width: 22px !important;
    height: 22px !important;
    top: -7px !important;
    border-radius: 50% !important;
    border: 2px solid #007cba !important;
    background: #fff !important;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.2) !important;
    cursor: pointer;
}
.becar-price-option input {
    display: none !important;
}
.becar-popup-header button {
    margin: 0em;
}
/* 3. Hiệu ứng tích chọn bắt mắt cho khoảng giá và thuộc tính */
/* Đặt dấu tích là một phần tử riêng biệt, không dùng ::after nữa */
.becar-tick,
.becar-price-option.active .becar-tick,
.becar-price-option input:checked ~ .becar-tick,
.becar-attribute-option.active .becar-tick,
.becar-attribute-option input:checked ~ .becar-tick,
.becar-tick::after {
    display: none !important;
}



@media (max-width: 768px) {
    .becar-tick {
        top: 2px;
        right: 2px;
        width: 16px;
        height: 16px;
        font-size: 12px;
        border-width: 1.5px;
    }
    .becar-tick::after {
        font-size: 12px;
    }
}

/* Đảm bảo label có position:relative */
.becar-price-option,
.becar-attribute-option {
    position: relative;
    overflow: visible;
}

/* 2. Responsive: Sắp xếp theo và nút lọc nâng cao thành 1 hàng, popup cách lề */
@media (max-width: 768px) {
    .becar-filter-bar {
        flex-wrap: nowrap;
        gap: 8px;
    }
    .becar-sort-wrapper {
        flex: 1 1 auto;
        min-width: 0;
        gap: 6px;
    }
    .becar-filter-btn {
        min-width: unset;
        padding: 2px 14px !important;
        font-size: 12px !important;
        width: auto;
        justify-content: flex-end;
    }
    .becar-popup-content {
        width: calc(100vw - 24px);
        height: auto;
        max-width: none;
        max-height: 90vh;
        left: 12px;
        right: 12px;
        top: 24px;
        bottom: 24px;
        transform: none;
        position: fixed;
    }
    .becar-popup-header,
    .becar-popup-footer {
        padding: 14px 16px;
    }
    .becar-price-ranges,
    .becar-attribute-options {
        gap: 6px;
    }
    .becar-attribute-options {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .becar-attribute-option,
    .becar-price-option {
        font-size: 12px !important;
        padding: 4px !important;
        min-width: 0;
        max-width: 100%;
    }
    .becar-attribute-option img {
        width: 20px;
        height: 20px;
    }
}

/* 3. Các ô thuộc tính nhỏ lại trên mobile */
.becar-attribute-option,
.becar-price-option {
    min-width: 50px;
    max-width: 150px;
    font-size: 12px !important;
    padding: 8px 9px !important;
}

/* 4. Sửa lại chữ "Sắp xếp theo:" thành "Sắp xếp:" và nút lọc nâng cao thành "Lọc" */
/* (Bạn cần sửa HTML trong file render_filter_bar ở class-frontend.php như sau:)
   <label>Sắp xếp:</label>
   <button id="becar-advanced-filter-btn" class="becar-filter-btn">Lọc</button>
*/
/* Ẩn/hiện nhãn theo thiết bị */
.becar-sort-text-mobile,
.becar-filter-btn-text-mobile {
    display: none;
}
@media (max-width: 768px) {
    .becar-sort-text-pc,
    .becar-filter-btn-text-pc {
        display: none !important;
    }
    .becar-sort-text-mobile,
    .becar-filter-btn-text-mobile {
        display: inline !important;
    }
    .becar-active-filters {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
        width: auto;
    }
    .becar-filter-tag,
    .becar-clear-all {
        width: auto;
        justify-content: flex-start;
        text-align: left;
    }
}

/* Thanh trượt mức giá nhỏ hơn */
.becar-price-slider,
.noUi-target {
    height: 4px !important;
    background: #e6f3ff !important;
    border-radius: 4px !important;
}
.noUi-connect {
    background: #007cba !important;
}
.noUi-handle {
    width: 16px !important;
    height: 16px !important;
    top: -6px !important;
    border-radius: 50% !important;
    border: 2px solid #007cba !important;
    background: #fff !important;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.2) !important;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.noUi-handle:focus {
    outline: none;
    border-color: #005b96 !important;
    box-shadow: 0 0 0 2px #b3e0ff !important;
}

/* Ô nhập mức giá hiện đại */
.becar-price-inputs input[type="number"] {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 6px;
    font-size: 12px;
    background: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    margin: 0;
}
.becar-price-svg {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
    color: #007cba;
    line-height: 1;
}
.becar-price-svg svg {
    display: inline-block;
    vertical-align: middle;
    width: 18px;
    height: 18px;
    fill: currentColor;
}
.becar-price-inputs input[type="number"]:focus {
    border-color: #007cba;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 2px #b3e0ff;
}

/* Hiển thị placeholder rõ ràng hơn */
.becar-price-inputs input[type="number"]::placeholder {
    color: #b0b8c1;
    font-style: italic;
    opacity: 1;
}

/* Khoảng cách giữa các input */
.becar-price-inputs span {
    color: #888;
    font-size: 16px;
    margin: 0 4px;
    font-weight: bold;
}
.price-section-wrapper {
    display: flex;
    width: 100%;
}

.price-section-wrapper .becar-filter-section {
    width: 45%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .price-section-wrapper {
        flex-direction: column;
        gap: 12px;
    }
    .price-section-wrapper .becar-filter-section {
        width: 100%;
        padding: 0;
    }
}