/**
 * Product Filters Styles
 * 
 * Optimized for Divi 5 integration and responsive design
 * Compatible with theme color scheme and typography
 * 
 * @package Jwell_Theme
 * @since 1.0.0
 */

/* ==========================================================================
   Base Filter Container
   ========================================================================== */

   .jwell-product-filters {
    margin: 30px 0;
    padding: 0px;
    background: #ffffff;
    border-radius: 12px;
    position: relative;
}

/* ==========================================================================
   Filter Form Layout
   ========================================================================== */

.jwell-filters-form {
    position: relative;
}

.jwell-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 0;
}

.jwell-filter-group {
    flex: 1;
    min-width: 200px;
    position: relative;
}

/* ==========================================================================
   Filter Labels
   ========================================================================== */

.jwell-filter-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #333333;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Select Dropdowns (Simple Mode)
   ========================================================================== */

.jwell-filter-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.4;
    color: #444444;
    background: #ffffff;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    cursor: pointer;
}

.jwell-filter-select:focus {
    outline: none;
    border-color: #e0a000;
    box-shadow: 0 0 0 3px rgba(46, 163, 242, 0.1);
}

.jwell-filter-select:hover {
    border-color: #cccccc;
}

/* ==========================================================================
   Multiselect Components
   ========================================================================== */

.jwell-multiselect-wrapper {
    position: relative;
    width: 100%;
}

.jwell-multiselect-header {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    min-height: 48px;
}

.jwell-multiselect-header:hover {
    border-color: #cccccc;
}

.jwell-multiselect-header.active {
    border-color: #e0a000;
    box-shadow: 0 0 0 3px rgba(46, 163, 242, 0.1);
}

.jwell-multiselect-placeholder {
    font-size: 15px;
    color: #666666;
    flex: 1;
    text-align: left;
}

.jwell-multiselect-arrow {
    font-size: 12px;
    color: #888888;
    transition: transform 0.3s ease;
    width: 20px;
    text-align: center;
}

.jwell-multiselect-header.active .jwell-multiselect-arrow {
    transform: rotate(180deg);
}

/* ==========================================================================
   Multiselect Dropdown
   ========================================================================== */

.jwell-multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.jwell-multiselect-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    margin: 0;
}

.jwell-multiselect-option:last-child {
    border-bottom: none;
}

.jwell-multiselect-option:hover {
    background: #f8f9fa;
}

.jwell-multiselect-option input[type="checkbox"] {
    margin: 0 10px 0 0;
    transform: scale(1.1);
    accent-color: #e0a000;
}

.jwell-multiselect-option span {
    font-size: 14px;
    color: #333333;
    line-height: 1.4;
}

/* ==========================================================================
   Filter Actions
   ========================================================================== */

.jwell-filter-actions {
    width: 100%;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-shrink: 0;
    margin-top: 5px;
}

.jwell-filter-submit {
    width: 100%;
    background: #E0A000 !important;
    color: white !important;
    border: none !important;
    padding: 8px !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: bold !important;
    transition: background-color 0.3s ease !important;
    text-decoration: none !important;
    display: inline-block !important;
    box-sizing: border-box !important;
    margin-top: 0 !important;
}

.jwell-filter-submit:hover {
    background: #c7900a !important;
    color: white !important;
}

.jwell-filter-submit:active {
    transform: translateY(0);
}

.jwell-filter-reset,
.jwell-filter-reset-button,
.jwell-filter-reset-link {
    width: 100%;
    color: #666 !important;
    background: #ccc !important;
    border: none !important;
    padding: 8px !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    text-align: center;
    font-weight: bold !important;
    transition: background-color 0.3s ease !important;
    text-decoration: none !important;
    display: inline-block !important;
    box-sizing: border-box !important;
    margin-top: 0 !important;
}

.jwell-filter-reset:hover,
.jwell-filter-reset-button:hover,
.jwell-filter-reset-link:hover {
    color: #333333 !important;
    background: #f0f0f0 !important;
    text-decoration: none !important;
}

/* Mobile reset styles */
.jwell-mobile-filter-reset,
.jwell-mobile-filter-reset-button,
.jwell-mobile-filter-reset-link {
    width: 100%;
    color: #666 !important;
    background: #ccc !important;
    border: none !important;
    padding: 12px !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    text-align: center;
    font-weight: bold !important;
    transition: background-color 0.3s ease !important;
    text-decoration: none !important;
    display: inline-block !important;
    box-sizing: border-box !important;
}

.jwell-mobile-filter-reset:hover,
.jwell-mobile-filter-reset-button:hover,
.jwell-mobile-filter-reset-link:hover {
    color: #333333 !important;
    background: #f0f0f0 !important;
    text-decoration: none !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 980px) {
    .jwell-filters-row {
        gap: 15px;
    }
    
    .jwell-filter-group {
        min-width: 250px;
    }
    
    .jwell-product-filters {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .jwell-filters-row {
        flex-direction: column;
        gap: 20px;
    }
    
    .jwell-filter-group {
        min-width: auto;
        width: 100%;
    }
    
    .jwell-filter-actions {
        width: 100%;
        justify-content: center;
        margin-top: 15px;
    }
    
    .jwell-filter-submit {
        flex: 1;
        max-width: 200px;
    }
    
    .jwell-product-filters {
        margin: 0;
        padding: 20px 15px;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .jwell-product-filters {
        margin: 0px -15px;
        padding: 15px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .jwell-multiselect-dropdown {
        max-height: 200px;
    }
    
    .jwell-filter-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .jwell-filter-submit,
    .jwell-filter-reset {
        width: 100%;
        text-align: center;
    }
    
    .jwell-filter-loader {
        right: 20px;
    }
    
    .jwell-spinner {
        width: 14px;
        height: 14px;
        border-width: 1px;
    }
}

/* ==========================================================================
   Divi Integration
   ========================================================================== */

/* Ensure proper integration with Divi's global styles */
.et_pb_module .jwell-product-filters {
    font-family: inherit;
}

.et_pb_module .jwell-filter-label {
    font-family: inherit;
}

.et_pb_module .jwell-filter-select,
.et_pb_module .jwell-multiselect-placeholder {
    font-family: inherit;
}

/* Override Divi's button styles when needed */
/*.et_pb_module .jwell-filter-submit.button {
    background: linear-gradient(135deg, #2ea3f2 0%, #1e88d4 100%) !important;
    border: none !important;
    font-size: 15px !important;
    padding: 12px 24px !important;
}*/

/*.et_pb_module .jwell-filter-submit.button:hover {
    background: linear-gradient(135deg, #1e88d4 0%, #1a75c0 100%) !important;
}*/

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

.jwell-filter-select:focus,
.jwell-multiselect-header:focus {
    outline: 2px solid #e0a000;
    outline-offset: 2px;
}

.jwell-multiselect-option input[type="checkbox"]:focus {
    outline: 2px solid #e0a000;
    outline-offset: 2px;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.jwell-product-filters.loading {
    opacity: 0.7;
    pointer-events: none;
}

.jwell-product-filters.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 #e0a000;
    border-radius: 50%;
    animation: jwell-spinner 1s linear infinite;
}

/* Filter Loading States */
.jwell-filter-loading {
    position: relative;
}

.jwell-filter-loading .jwell-multiselect-header {
    opacity: 0.7;
}

.jwell-filter-loader {
    position: absolute;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    z-index: 1001;
    pointer-events: none;
}

.jwell-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: jwell-spin 1s linear infinite;
}

@keyframes jwell-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes jwell-spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.jwell-filter-temp-disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
}

/* Mobile filter loading states */
.jwell-mobile-filter-section.jwell-filter-loading {
    position: relative;
}

.jwell-mobile-filter-section.jwell-filter-loading .jwell-mobile-filter-section-header {
    opacity: 0.7;
}

.jwell-mobile-filter-section.jwell-filter-loading .jwell-mobile-filter-options {
    opacity: 0.6;
    pointer-events: none;
}

.jwell-mobile-loader {
    position: absolute;
    top: 50%;
    right: 40px; /* Account for toggle arrow */
    transform: translateY(-50%);
    z-index: 1001;
    pointer-events: none;
}

.jwell-mobile-filter-option.jwell-filter-temp-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.jwell-mobile-filter-option.jwell-filter-temp-disabled input {
    cursor: not-allowed;
}

.jwell-mobile-filter-option.jwell-filter-temp-disabled .option-label {
    color: #999;
}

/* Hidden filter elements */
.jwell-filter-hidden {
    display: none !important;
}

.jwell-filter-group-hidden {
    display: none !important;
}

.jwell-mobile-filter-section-hidden {
    display: none !important;
}

/* ==========================================================================
   Dark Theme Support (if applicable)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .jwell-product-filters {
        background: #1a1a1a;
        border-color: #333333;
    }
    
    .jwell-filter-label {
        color: #e0e0e0;
    }
    
    .jwell-filter-select,
    .jwell-multiselect-header {
        background: #2a2a2a;
        border-color: #444444;
        color: #e0e0e0;
    }
    
    .jwell-multiselect-dropdown {
        background: #2a2a2a;
        border-color: #444444;
    }
    
    .jwell-multiselect-option {
        border-color: #333333;
        color: #e0e0e0;
    }
    
    .jwell-multiselect-option:hover {
        background: #333333;
    }
}