/* Desktop search bar optimization */
@media (min-width: 768px) {
    /* General search form styling */
    .search_wrapper {
        background-color: white !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
        padding: 8px 15px !important; /* Reduced top/bottom padding */
        max-width: 1200px !important;
        margin: 0 auto !important;
    }
    
    /* Remove box-shadow from homepage search wrapper with high specificity */
    html body.home .search_wrapper,
    body.home .search_wrapper,
    .elementor-widget-container.home .search_wrapper,
    .home .search_wrapper.search_wr_elementor,
    .home .search_wrapper.search_wr_elementor_shadow {
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        -moz-box-shadow: none !important;
    }
    
    .search_wrapper form {
        display: flex !important;
        align-items: flex-end !important; /* Align to bottom for vertical layout */
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
    }
    
    /* Field widths */
    form[action*='advanced-search'] .elementor-field-group-name { width: 20% !important; } /* Destination */
    form[action*='advanced-search'] .elementor-field-group-message { width: 10% !important; } /* Arrivee */
    form[action*='advanced-search'] .elementor-field-group-0db3c4e { width: 10% !important; } /* Depart */
    form[action*='advanced-search'] .elementor-field-group-097341d { width: 10% !important; } /* Voyageurs */
    form[action*='advanced-search'] .elementor-field-group-3be4690,
    form[action*='advanced-search'] .elementor-field-group-25004ac { width: 15% !important; } /* Sports */
    form[action*='advanced-search'] .elementor-field-group-1f07728 { width: 12% !important; } /* Reservation */
    form[action*='advanced-search'] .elemenentor_submit_wrapper { width: auto !important; min-width: 120px !important; } /* Search button */
    
    /* Field group styling */
    .search_wrapper .elementor-field-group {
        display: flex !important;
        flex-direction: column !important; /* Keep vertical layout */
        margin: 0 !important;
        position: relative !important;
        border-right: 1px solid #e0e0e0 !important;
        height: auto !important; /* Auto height for vertical layout */
    }
    
    /* Remove border from last field group before button */
    .search_wrapper .elementor-field-group:last-of-type {
        border-right: none !important;
    }
    
    /* Label styling */
    .search_wrapper .elementor-field-label {
        font-weight: 600 !important;
        margin-bottom: 2px !important; /* Reduced margin */
        font-size: 14px !important;
        color: #333 !important;
        text-align: left !important;
        padding-left: 10px !important; /* Default padding */
        display: block !important; /* Ensure block display */
        width: 100% !important; /* Full width */
    }
    
    /* Fine-tune label alignment for each field */
    /* Destination - move left more */
    .elementor-field-group-name .elementor-field-label {
        padding-left: 1px !important;
    }
    
    /* Arrivée, Départ - move left slightly */
    .elementor-field-group-message .elementor-field-label,
    .elementor-field-group-0db3c4e .elementor-field-label {
        padding-left: 2px !important;
    }
    
    /* Voyageurs - move right more */
    .elementor-field-group-097341d .elementor-field-label {
        padding-left: 14px !important;
    }
    
    /* Sports - move right slightly */
    .elementor-field-group-3be4690 .elementor-field-label,
    .elementor-field-group-25004ac .elementor-field-label {
        padding-left: 13px !important;
    }
    
    /* Reservation is perfect at 10px */
    .elementor-field-group-1f07728 .elementor-field-label {
        padding-left: 10px !important;
    }
    
    /* Field wrapper styling */
    .search_wrapper .elementor_search_builder_field_wrapper {
        height: 35px !important;
        border: none !important;
    }
    
    /* Input field styling */
    .search_wrapper input,
    .search_wrapper select,
    .search_wrapper .dropdown,
    .search_wrapper .bootstrap-select,
    .search_wrapper .wpestate_guest_no_control_info {
        height: 32px !important; /* Reduced height */
        line-height: 32px !important;
        border: none !important;
        background-color: #fff !important;
        font-size: 13px !important; /* Smaller font */
        color: #45423E !important; /* Changed from #333 to match Price slider and Sport */
        width: 100% !important;
        text-align: left !important;
    }
    
    /* Placeholder styling */
    .search_wrapper input::placeholder {
        color: #45423E !important; /* Changed from #777 to match Price slider and Sport */
        opacity: 1 !important;
        text-align: left !important;
    }
    
    /* Dropdown styling */
    .search_wrapper .dropdown-toggle,
    .search_wrapper .filter_menu_trigger {
        height: 32px !important; /* Reduced height */
        line-height: 32px !important;
        padding: 0 10px 0 11px !important; /* Added 11px left padding to prevent text overlap with icon */
        padding-right: 25px !important;
        text-overflow: ellipsis !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        color: #45423E !important; /* Changed from #333 to match Price slider and Sport */
        text-align: left !important;
        justify-content: flex-start !important;
    }
    
    /* Ensure all placeholder text is aligned */
    .search_wrapper .form-control,
    .search_wrapper .dropdown-toggle,
    .search_wrapper .wpestate_guest_no_control_info,
    .search_wrapper .filter-option-inner-inner,
    .search_wrapper button.dropdown-toggle {
        display: flex !important;
        align-items: center !important;
        height: 100% !important;
        padding-left: 10px !important;
        justify-content: flex-start !important;
    }
    
    /* Special handling for filter_menu_trigger to avoid conflicts */
    .search_wrapper .filter_menu_trigger {
        display: flex !important;
        align-items: center !important;
        height: 100% !important;
        padding-left: 11px !important; /* Specifically 11px for filter_menu_trigger */
        justify-content: flex-start !important;
    }
    
/* Fix for dropdown elements */
.search_wrapper .filter-option,
.search_wrapper .filter-option-inner,
.search_wrapper .filter-option-inner-inner {
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
}

/* Remove border from homepage specific dropdown toggles and buttons */
.home .search_wrapper button,
.home .search_wrapper .dropdown-toggle, 
.home .search_wrapper button.dropdown-toggle,
.home .search_wrapper div#booking_toogle,
.home .search_wrapper .wpestate-multiselect-custom-style,
.home .search_wrapper .filter_menu_trigger {
    border: none !important;
}
    
    /* Fix caret position for dropdowns */
    .search_wrapper .caret_filter {
        position: absolute !important;
        right: 10px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }
    
    /* Submit wrapper styling */
    .search_wrapper .elemenentor_submit_wrapper {
        border-right: none !important;
        align-self: center !important;
        display: flex !important;
        align-items: center !important;
        padding: 0 !important;
        margin-top: 0 !important;
    }
}

/* Main Search bar Bouton CHERCHER */
@media (min-width: 1024px) {
    .search_wrapper .advanced_search_submit_button {
        height: 50px !important; /* Reduced height to match form */
        border-radius: 5px !important;
        background-color: #ff6f00 !important;
        color: white !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        font-size: 15px !important; /* Reduced font size */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 20px !important;
        border: none !important;
        cursor: pointer !important;
        transition: background-color 0.2s !important;
        margin-left: 5px !important;
    }
    
    .search_wrapper .advanced_search_submit_button:hover {
        background-color: #e56500 !important;
    }
}

/* Main Search bar Dropdown SPORTS */
.dropdown-menu {
    min-width: 230px !important;
    width: auto !important;
    border-radius: 8px !important;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1) !important;
    max-height: 400px !important; /* Increased max height */
    overflow-y: auto !important; /* Add scrolling if needed */
}

/* Sports dropdown specific styling */
.elementor-field-group-3be4690 .dropdown-menu,
.elementor-field-group-25004ac .dropdown-menu {
    max-height: 400px !important; /* Increased max height for sports dropdown */
}

/* Sports search input specific styling */
.elementor-field-group-3be4690 .bs-searchbox input.form-control,
.elementor-field-group-25004ac .bs-searchbox input.form-control {
    height: 38px !important; /* Increased height for sports search input */
    padding: 10px 12px !important; /* Increased padding */
}

/* Main Search bar Input de recherche dans la dropdown */
.dropdown-menu .bs-searchbox input.form-control {
    background-color: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    padding: 8px 12px !important;
    border-radius: 5px !important;
    box-shadow: none !important;
}

.dropdown-menu .bs-searchbox input.form-control:focus {
    background-color: #ffffff !important;
    border-color: #007bff !important;
    padding-left: 12px !important;
    outline: none !important;
}

/* Force style recalculation by adding a harmless query parameter */
/* Main Search bar Ajustement mobile */
@media (max-width: 767px) {
    /* Force style recalculation with !important flag for shadows */
    body .home div.search_wrapper,
    .home .search_wrapper.search_wr_elementor,
    body .elementor-element-28160 .search_wrapper,
    body .elementor-element.elementor-element-28160 .search_wrapper,
    body.home .elementor-location-header .search_wrapper,
    html body.home .search_wrapper {
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        -moz-box-shadow: none !important;
        border: none !important;
        filter: none !important;
    }
    
    /* Specific padding adjustment for mobile form controls */
    .elementor-28160 .elementor-element.elementor-element-174b045 .form-control,
    body .elementor-28160 .elementor-element.elementor-element-174b045 .form-control {
        padding: 0px 11px 12px 20px !important;
    }
    
    /* Minimum height for guest control info */
    .search_wrapper.search_wr_elementor.search_wr_elementor_shadow .wpestate_guest_no_control_info {
        min-height: 32px !important;
    }
    
    /* Reduce overall wrapper padding */
    .search_wrapper,
    .adv-search-1,
    .search_wrapper form,
    .home .search_wrapper {
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 6px !important;
    }
    
    .dropdown-menu {
        min-width: 70% !important;
        width: 100% !important;
        left: 0% !important;
        border-radius: 8px !important;
    }

    /* Main Search bar Repositionnement des check-marks */
    .dropdown-menu .check-mark {
        position: absolute !important;
        right: 25px !important;
    }
    
    /* Target the dropdown button (Sports) with high specificity to prevent gradient flash */
    .advanced_search_widget .btn.dropdown-toggle.btn-default,
    button.btn.dropdown-toggle.btn-default,
    body .bootstrap-select .btn.dropdown-toggle.btn-default,
    html body .bootstrap-select .btn-group .btn.dropdown-toggle.btn-default,
    .bootstrap-select .dropdown-toggle,
    html body.home .dropdown-toggle.btn-default,
    .elementor-widget-container .bootstrap-select .btn-default {
        background: #ffffff !important; /* Set white background */
        background-image: none !important; /* Remove any gradient */
        background-color: #ffffff !important;
        border-color: transparent !important;
        box-shadow: none !important;
        text-shadow: none !important;
        filter: none !important; /* Remove any filters that might create gradient effects */
        transition: none !important; /* Prevent transition effects */
        -webkit-box-shadow: none !important;
        -webkit-transition: none !important;
    }

    /* Handle hover, active and focus states to prevent Bootstrap defaults */
    .bootstrap-select .btn.dropdown-toggle.btn-default:hover,
    .bootstrap-select .btn.dropdown-toggle.btn-default:active,
    .bootstrap-select .btn.dropdown-toggle.btn-default:focus,
    button.btn.dropdown-toggle.btn-default:hover,
    button.btn.dropdown-toggle.btn-default:active,
    button.btn.dropdown-toggle.btn-default:focus {
        background: #ffffff !important;
        background-image: none !important;
        background-color: #ffffff !important;
        border-color: transparent !important;
        box-shadow: none !important;
        filter: none !important;
    }
    
    /* Adjustments for mobile search form layout with consistent spacing */
    .search_wrapper form {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    /* Set consistent spacing for ALL field groups */
    .search_wrapper .elementor-field-group {
        width: 100% !important;
        border-right: none !important;
        padding: 8px 0 !important;
        margin: 0 !important;
    }
    
    /* Add horizontal separators between fields in mobile view with consistent spacing */
    .search_wrapper .elementor-field-group:not(:last-child) {
        border-right: none !important; /* Remove vertical dividers on mobile */
        border-bottom: 1px solid #e0e0e0 !important; /* Add horizontal dividers with same color as desktop */
        margin-bottom: 0 !important;
    }
    
    /* Reduce padding for all field groups in mobile for tighter layout */
    .search_wrapper .elementor-field-group {
        padding: 5px 8px !important;
    }

    /* Fix padding and separator line position for Sports and Reservation fields */
    .search_wrapper .elementor-field-group:nth-last-child(2),
    .search_wrapper .elementor-field-group:nth-last-child(3) {
        padding: 4px 8px !important; /* Reduce overall padding but keep horizontal */
    }
    
    /* Target dropdown fields in Sports and Reservation */
    .search_wrapper .elementor-field-group:nth-last-child(2) .dropdown-toggle,
    .search_wrapper .elementor-field-group:nth-last-child(3) .dropdown-toggle,
    .search_wrapper .elementor-field-group:nth-last-child(2) .filter_menu_trigger,
    .search_wrapper .elementor-field-group:nth-last-child(3) .filter_menu_trigger,
    .search_wrapper .elementor-field-group-3be4690 .dropdown-toggle,
    .search_wrapper .elementor-field-group-25004ac .dropdown-toggle,
    .search_wrapper .elementor-field-group-1f07728 .dropdown-toggle {
        height: 26px !important;
        line-height: 26px !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }
    
    /* Fix label spacing for these fields */
    .search_wrapper .elementor-field-group:nth-last-child(2) .elementor-field-label,
    .search_wrapper .elementor-field-group:nth-last-child(3) .elementor-field-label {
        margin-bottom: 4px !important;
    }
    
    /* Reset filter menu trigger padding and margin with high specificity */
    html body .search_wrapper .filter_menu_trigger,
    body .home .search_wrapper .filter_menu_trigger,
    .elementor-widget-container .search_wrapper .filter_menu_trigger {
        margin-top: 0px !important;
        padding: 0px 0px 0px 11px !important; /* Added left padding to prevent text overlap with icon */
        border: none !important; /* Ensure no unexpected borders */
        box-shadow: none !important; /* Remove any shadows */
    }
    
    /* Create visual consistency in input fields */
    .search_wrapper input,
    .search_wrapper select,
    .search_wrapper .dropdown,
    .search_wrapper .bootstrap-select,
    .search_wrapper .wpestate_guest_no_control_info,
    .search_wrapper .dropdown-toggle,
    .search_wrapper .filter_menu_trigger {
        height: 28px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        padding-left: 6px !important;
        margin: 0 !important;
    }
    
    /* Create consistent spacing for labels */
    .search_wrapper .elementor-field-label {
        margin-bottom: 6px !important;
        margin-top: 0 !important;
        font-size: 13px !important;
        padding-left: 6px !important;
        font-weight: 500 !important;
    }
    
    /* Standardize field wrapper height */
    .search_wrapper .elementor_search_builder_field_wrapper {
        height: 28px !important;
        margin: 0 !important;
    }
    
    /* Search button styling for mobile with consistent spacing */
    .search_wrapper .elemenentor_submit_wrapper {
        margin-top: 8px !important;
        width: 100% !important;
        padding: 8px 0 !important; /* Match the field group padding */
    }
    
    .search_wrapper .advanced_search_submit_button {
        width: 100% !important;
        margin: 0 !important;
        height: 38px !important; /* Slightly taller than fields */
        font-size: 14px !important; /* Slightly larger than fields */
    }
}
