/**
 * Unique Beds Filter - Frontend Styles (Checkbox Version)
 * 
 * Main stylesheet for desktop product filter with custom checkbox dropdowns
 */

/* Filter Wrapper */
.ubf-filter-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 2rem;
}

/* Hide category filter */
.ubf-filter-group[data-filter-type="category"],
.ubf-mobile-filter-group[data-filter-type="category"] {
    display: none !important;
}

/* Filter Bar */
.ubf-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-start;
    padding: 20px;
    border-radius: 4px;
}

.ubf-filter-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

/* Custom Dropdown */
.ubf-custom-dropdown {
    position: relative;
    width: 100%;
}

.ubf-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px;
    background: #fff !important;
    font-size: 13px !important;
    color: #333 !important;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    box-shadow: none !important;
}

.ubf-dropdown-toggle:hover {
    border-color: #999 !important;
    background: #fff !important;
    color: #333 !important;
}

.ubf-dropdown-toggle:focus {
    outline: none;
    border-color: #0073aa !important;
    box-shadow: 0 0 0 1px #0073aa !important;
    background: #fff !important;
    color: #333 !important;
}

.ubf-dropdown-toggle:disabled {
    cursor: not-allowed;
    background-color: #f5f5f5 !important;
    color: #999 !important;
    box-shadow: none !important;
}

.ubf-custom-dropdown.ubf-dropdown-disabled .ubf-dropdown-toggle {
    cursor: not-allowed;
    background-color: #f5f5f5 !important;
    color: #999 !important;
    box-shadow: none !important;
}

/* Make toggles larger with more padding */
button.ubf-dropdown-toggle {
    padding: 20px 10px !important;
}

.ubf-dropdown-label {
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ubf-dropdown-count {
    margin-left: 5px;
    color: #4a9eff;
    font-weight: 600;
    display: none;
}

.ubf-dropdown-arrow {
    margin-left: auto;
    padding-left: 10px;
    font-family: "Font Awesome 5 Free", "FontAwesome";
    font-weight: 900;
    font-size: 14px;
    transition: all 0.3s ease;
    color: #000;
}

.ubf-dropdown-arrow::before {
    content: '\f078';
}

.ubf-custom-dropdown.ubf-dropdown-open .ubf-dropdown-arrow::before {
    content: '✕';
}

.ubf-custom-dropdown.ubf-dropdown-open .ubf-dropdown-arrow {
    transform: none;
}

.ubf-custom-dropdown.ubf-dropdown-open .ubf-dropdown-toggle {
    border-color: #0073aa !important;
    box-shadow: 0 0 0 1px #0073aa !important;
}

/* Dropdown Panel */
.ubf-dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff !important;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    z-index: 1000;
    max-height: 400px;
    overflow: hidden;
    flex-direction: column;
    display: none; /* Hidden by default */
}

.ubf-custom-dropdown.ubf-dropdown-open .ubf-dropdown-panel {
    display: flex !important; /* Show when dropdown is open */
}

/* Search Input */
.ubf-dropdown-search {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.ubf-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.ubf-search-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

/* Dropdown Options Container */
.ubf-dropdown-options {
    overflow-y: auto;
    max-height: 300px;
    padding: 5px 0;
}

.ubf-dropdown-options::-webkit-scrollbar {
    width: 8px;
}

.ubf-dropdown-options::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ubf-dropdown-options::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.ubf-dropdown-options::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Checkbox Options */
.ubf-checkbox-option {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ubf-checkbox-option:hover {
    background: #f0f0f0;
}

.ubf-filter-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    margin-right: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.ubf-checkbox-label {
    flex: 1;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.ubf-option-count {
    color: #999;
    font-size: 0.9em;
    margin-left: 4px;
}

/* Dropdown Actions */
.ubf-dropdown-actions {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
}

.ubf-clear-filter {
    padding: 6px 12px;
    background: transparent;
    color: #0073aa;
    border: 1px solid #0073aa;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ubf-clear-filter:hover {
    background: #0073aa;
    color: #fff;
}

/* Price Panel Special Styling */
.ubf-dropdown-panel.ubf-price-panel {
    padding: 15px;
}

/* Mobile Filter Toggle Button */
.ubf-mobile-filter-toggle {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    width: 100%;
    justify-content: center;
}

.ubf-mobile-filter-toggle:hover {
    background: #444;
}

.ubf-mobile-filter-toggle .ubf-filter-icon {
    font-size: 20px;
}

/* Loading State */
.ubf-loading {
    position: relative;
}

.ubf-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Filter Loading State */
.ubf-filter-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.ubf-loading-spinner {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    z-index: 10;
    pointer-events: none;
}

.ubf-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #333;
    border-radius: 50%;
    animation: ubf-spin 0.6s linear infinite;
}

@keyframes ubf-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Loading state for filter wrapper */
.ubf-filter-wrapper.is-filtering {
    position: relative;
}

.ubf-filter-wrapper.is-filtering::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 5;
    pointer-events: none;
    border-radius: 4px;
}

/* Global loading spinner */
.ubf-global-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
}

.ubf-global-loading-spinner .ubf-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #333;
    border-radius: 50%;
    animation: ubf-spin 0.8s linear infinite;
}

/* Disabled button state */
.ubf-button-disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* No Products Message */
.ubf-no-products {
    padding: 40px;
    text-align: center;
    font-size: 18px;
    color: #666;
}

/* Price Filter Styles */
.ubf-price-filter {
    min-width: 220px;
}

.ubf-price-label {
    display: none;
}

.ubf-price-slider-wrapper {
    padding: 2px 0;
}

.ubf-price-slider {
    margin: 8px 5px;
    height: 16px;
}

.ubf-price-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #333;
    font-weight: 500;
    margin-top: 8px;
}

.ubf-price-separator {
    color: #999;
    margin: 0 6px;
}

/* noUiSlider customization */
.ubf-price-slider .noUi-base {
    height: 16px;
}

.ubf-price-slider .noUi-connect,
.noUi-connect {
    background: #000 !important;
}

.ubf-price-slider .noUi-horizontal .noUi-connect {
    background: #000 !important;
}

.ubf-price-slider .noUi-handle {
    width: 11px;
    height: 11px;
    border: 2px solid #000;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    top: 2.5px;
}

.ubf-price-slider .noUi-handle:before,
.ubf-price-slider .noUi-handle:after {
    display: none;
}

.ubf-price-slider .noUi-tooltip {
    display: none;
}

/* Responsive Tablet */
@media (max-width: 1024px) {
    .ubf-filter-bar {
        gap: 10px;
    }
    
    .ubf-filter-group {
        min-width: 180px;
    }
    
    .ubf-price-filter {
        min-width: 200px;
    }
}

/* Ensure Product Grid Maintains Layout After Filtering */
.woocommerce ul.products,
ul.products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Support for column classes */
.woocommerce ul.products.columns-2,
ul.products.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.woocommerce ul.products.columns-3,
ul.products.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.woocommerce ul.products.columns-4,
ul.products.columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.woocommerce ul.products.columns-5,
ul.products.columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

/* Responsive adjustments for product grid */
@media (max-width: 1024px) {
    .woocommerce ul.products.columns-4,
    .woocommerce ul.products.columns-5,
    ul.products.columns-4,
    ul.products.columns-5 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .woocommerce ul.products,
    ul.products {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .woocommerce ul.products,
    ul.products {
        grid-template-columns: 1fr;
    }
}

/* Reset Button */
.ubf-reset-filter {
    min-width: auto;
    flex: 0 0 auto;
}

.ubf-reset-button {
    padding: 10px 20px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
}

button.ubf-reset-button {
    margin-left: 5px;
}

.ubf-reset-button:hover {
    background: #555;
}

.ubf-reset-button:active {
    background: #222;
}

.ubf-reset-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile Reset Button */
.ubf-mobile-reset-button {
    width: 100%;
    margin-top: 15px;
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .ubf-mobile-filter-toggle {
        display: flex;
    }
    
    .ubf-filter-bar {
        display: none;
    }
    
    button.ubf-reset-button {
        margin-left: 0;
    }
}
