/* Car Filter Optimizations */

/* Clean Apple-style Container */
#homeCarFilter {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    background: #ffffff;
    border-radius: 12px;
    position: relative;
}

/* Clean Apple-style Spinner */
.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #e69006;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: absolute;
    right: 12px;
    top: calc(50% + 10px);
    transform: translateY(-50%);
    z-index: 10;
    pointer-events: none;
}

.spinner.active {
    display: block;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Clean Apple-style Select Container */
.dropdownContainer {
    position: relative;
    display: inline-block;
    margin-right: 12px;
}

.dropdownContainer:last-of-type {
    margin-right: 0;
}

/* Apple-style custom arrow - only for actual dropdown containers */
.dropdownContainer::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #000;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.320, 1);
    pointer-events: none;
    opacity: 1;
    z-index: 2;
}

/* Elegant color and scale change on hover */
.dropdownContainer:hover::after {
    border-top-color: #9ca3af;
    transform: translateY(-50%) scale(1.1);
}

/* Smooth rotation and color change when active */
.dropdownContainer:focus-within::after {
    transform: translateY(-50%) rotate(180deg) scale(1.15);
    border-top-color: #e69006;
}

/* Ensure search button container doesn't get arrows */
#searchButton,
#searchButton::after,
#searchButton::before,
.search-button-container::after,
.search-button-container::before {
    content: none !important;
}

/* Make sure ONLY actual dropdown containers get arrows, not the search button area */
.carFilter.homeCar__filter > *:not(.dropdownContainer)::after,
.carFilter.homeCar__filter > *:not(.dropdownContainer)::before,
#searchButton::after,
#searchButton::before {
    display: none !important;
    content: none !important;
}

/* Clean Apple-style Select Styling */
.dropdownContainer select {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 140px;
    width: auto;
    padding: 12px 32px 12px 16px;
    box-sizing: border-box;
    border: none;
    border-radius: 8px;
    background: #ffffff;
    font-size: 14px;
    font-weight: 400;
    color: #374151;
    appearance: none;
    position: relative;
    z-index: 1;
}

/* Clean Apple-style optgroup styling */
.dropdownContainer select optgroup {
    font-weight: 600;
    font-size: 12px;
    color: #6b7280;
    padding: 8px 0 4px 0;
    margin: 0;
    background: #f9fafb;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Clean option styling */
.dropdownContainer select option {
    padding: 8px 16px;
    background: white;
    color: #374151;
    font-weight: 400;
}

.dropdownContainer select option:hover,
.dropdownContainer select option:focus,
.dropdownContainer select option:active,
.dropdownContainer select option:checked {
    background: #fff7ea;
    color: #000000;
}

/* Popular brands clean styling */
.dropdownContainer select optgroup[label*="Popular"] option {
    font-weight: 500;
}

/* Alphabetic section styling */
.dropdownContainer select optgroup[label*="Alphabetic"] option {
    background: white;
    font-weight: 400;
}



/* Clean Apple-style disabled state */
.dropdownContainer select:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Disabled arrow styling - using class-based approach for better browser support */
.dropdownContainer.disabled::after {
    border-top-color: #e5e7eb;
    opacity: 0.4;
    transform: translateY(-50%) scale(0.9);
}

/* Simple loading state */
.dropdownContainer.loading select {
    background: #f3f4f6;
}





/* Clean Apple-style hover and focus states */
.dropdownContainer select:hover:not(:disabled) {
    background: #f9fafb;
}

.dropdownContainer select:focus:not(:disabled) {
    outline: none;
    background: #f9fafb;
    box-shadow: 0 0 0 3px rgba(230, 144, 6, 0.1);
}

/* Search button loading state */
#searchButton.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

#searchButton.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Clean Apple-style Filter Container Layout */
.carFilter.homeCar__filter {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: transparent;
}

/* Circular Search Button */
#searchButton {
    background: #e69006;
    color: white;
    border: none;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
}

#searchButton:hover {
    background: #d4820a;
    transform: scale(1.05);
}

#searchButton:active {
    background: #c6760a;
    transform: scale(0.95);
}

#searchButton .iconify {
    font-size: 20px;
    margin: 0;
}

/* Loading state for search button */
#searchButton.loading {
    background: #8e8e93;
    cursor: not-allowed;
    pointer-events: none;
}

#searchButton.loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: buttonSpin 1s linear infinite;
    display: inline-block;
}

@keyframes buttonSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error shake animation */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* Hide mobile elements on desktop */
.mobile-filter-actions {
    display: none;
}

/* Modern Apple/Airbnb-style Mobile Design */
@media (max-width: 767.98px) {
    
    /* Filter Content */
    .mobile-filter-content {
        padding: 20px;
        flex: 1;
        padding-bottom: 100px;
    }
    
    /* Dropdown Containers - Card Style */
    .dropdownContainer {
        width: 100%;
        margin: 0 0 16px 0;
        position: relative;
        z-index: 1;
    }
    
    .dropdownContainer:last-of-type {
        margin-bottom: 24px;
    }
    
    /* Modern Card-style Selects */
    .dropdownContainer select {
        width: 100%;
        padding: 20px 50px 20px 20px;
        font-size: 16px;
        font-weight: 500;
        color: #222222;
        background: #f7f7f7;
        border: 2px solid transparent;
        border-radius: 12px;
        min-height: 60px;
        transition: all 0.2s ease;
        appearance: none;
    }
    
    .dropdownContainer select:focus {
        background: #ffffff;
        border-color: #e69006;
        box-shadow: 0 0 0 4px rgba(230, 144, 6, 0.1);
        outline: none;
    }
    
    .dropdownContainer select:disabled {
        background: #f7f7f7;
        color: #b0b0b0;
        cursor: not-allowed;
    }
    
    /* Mobile Chevron */
    .dropdownContainer::after {
        right: 20px;
        border-top: 6px solid #999999;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        top: 50%;
        margin-top: 8px;
    }
    
    .dropdownContainer:focus-within::after {
        border-top-color: #e69006;
        transform: translateY(-50%) rotate(180deg) scale(1.1);
        margin-top: 8px;
    }
    
    /* Mobile Spinner */
    .spinner {
        right: 20px;
        top: 50%;
        margin-top: 8px;
        width: 18px;
        height: 18px;
        border-width: 3px;
    }
    
    /* Bottom Action Area */
    .mobile-filter-actions {
        position: sticky;
        bottom: 0;
        background: #ffffff;
        padding: 20px;
        border-top: 1px solid #f0f0f0;
        display: flex;
        gap: 12px;
        align-items: center;
        z-index: 100;
        width:100%;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* Clear Button */
    .mobile-clear-btn {
        flex: 1;
        padding: 16px 24px;
        background: transparent;
        color: #222222;
        border: 2px solid #e0e0e0;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 600;
        transition: all 0.2s ease;
        cursor: pointer;
    }
    
    .mobile-clear-btn:hover {
        border-color: #c0c0c0;
        background: #f7f7f7;
    }
    
    /* Mobile Search Button */
    #searchButtonMobile {
        flex: 2;
        width: auto;
        height: auto;
        min-height: 52px;
        border-radius: 12px;
        padding: 16px 0px;
        font-size: 14px;
        font-weight: 700;
        background: linear-gradient(135deg, #e69006 0%, #d4820a 100%);
        color: white;
        border: none;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    #searchButtonMobile:hover {
        background: linear-gradient(135deg, #d4820a 0%, #c6760a 100%);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(230, 144, 6, 0.3);
    }
    
    #searchButtonMobile .iconify {
        font-size: 18px;
        margin: 0;
    }
    
    #searchButtonMobile::after {
        content: 'Search';
        margin-left: 0;
    }
    
    /* Hide desktop search button on mobile */
    .desktop-search-btn,
    #searchButton {
        display: none !important;
    }
    
    /* Backdrop for modal */
    .mobile-filter-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .mobile-filter-backdrop.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Hide desktop arrow on mobile */
    .dropdownContainer.disabled::after {
        display: none;
    }
    
    /* Mobile optgroup styling */
    .dropdownContainer select optgroup {
        font-size: 14px;
        font-weight: 700;
        color: #e69006;
        background: #f9f9f9;
        padding: 12px 0 8px 0;
    }
    
    .dropdownContainer select option {
        padding: 12px 20px;
        font-size: 16px;
        color: #222222;
        background: white;
    }
    
    .dropdownContainer select option:hover,
    .dropdownContainer select option:focus {
        background: #fff7ea;
        color: #000000;
    }
}

/* Error states */
.car-filter-error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
    display: none;
}

.car-filter-error.show {
    display: block;
}

/* Success/info states */
.car-filter-info {
    background-color: #d1ecf1;
    color: #0c5460;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
    display: none;
}

.car-filter-info.show {
    display: block;
}

/* Performance debug panel (development only) */
.car-filter-debug {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    z-index: 9999;
    display: none;
}

.car-filter-debug.show {
    display: block;
}

/* Improved visual feedback */
.dropdownContainer select:focus {
    outline: 2px solid #e69006;
    outline-offset: 2px;
}

.dropdownContainer select optgroup {
    font-weight: bold;
    font-style: normal;
}

.dropdownContainer select option {
    padding: 8px;
}

/* Skeleton loading effect */
.skeleton-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
} 