/* ============================================
   GLOBAL SEARCH FRONTEND
   Styles unifiés pour tous les composants de recherche
   Version: 2.0.0
   ============================================ */

/* ============================================
   1. VARIABLES CSS
   ============================================ */
:root {
    --search-border-color: #FFC107;
    --search-border-focus: #FFA000;
    --search-primary: #0798cb;
    --search-input-height: 48px;
    --search-border-radius: 8px;
    --search-border-width: 2px;
}

/* ============================================
   1b. SEARCH BOX (shared across all headers)
   ============================================ */
.search-box {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    z-index: 100;
    overflow: visible;
}

.search-content {
    position: relative;
    width: 100%;
}

/* ============================================
   1c. SEARCH TABS
   ============================================ */
.search-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: none;
    flex-wrap: wrap;
}

.search-tab {
    background: transparent;
    border: none;
    color: #6b7280;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-tab:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.search-tab.active {
    background: var(--search-primary);
    color: white;
}

.search-tab i {
    font-size: 1.1rem;
}

/* ============================================
   1d. SEARCH PANELS (tab content)
   ============================================ */
.search-panel {
    display: none;
}

.search-panel.active {
    display: block;
}

/* ============================================
   1e. FORM CONTROLS (yellow border override)
   ============================================ */
.search-box .form-select,
.search-box .form-control {
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    border: 3px solid var(--search-border-color);
    border-radius: 6px;
    background-color: white;
    transition: border-color 0.2s;
    height: var(--search-input-height);
    line-height: 1.5;
}

.search-box .form-select:focus,
.search-box .form-control:focus {
    border-color: var(--search-border-focus);
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25);
    outline: none;
}

.search-box .form-label {
    text-align: unset !important;
    margin-bottom: 0.5rem;
}

/* Ensure rows don't clip dropdown */
.search-form .row {
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
}

.search-form .col-md-2,
.search-form .col-md-3,
.search-form .col-md-4,
.search-form .col-md-5,
.search-form .col-md-6 {
    overflow: visible;
}

/* Hide children select column (managed by guest picker) */
.col-4:has(select[name="children"]),
.col-6:has(select[name="children"]) {
    display: none !important;
}

.row:has(select[name="children"]) .col-4:not(:has(select[name="children"])),
.row:has(select[name="children"]) .col-6:not(:has(select[name="children"])) {
    flex: 1;
}

/* ============================================
   2. INPUT WITH ICON
   ============================================ */
.search-field {
    position: relative;
}

.input-with-icon {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--search-primary);
    font-size: 1.1rem;
    z-index: 10;
    pointer-events: none;
}

.input-with-icon .form-control,
.input-with-icon .form-select {
    padding-left: 50px !important;
}

.search-field input,
.search-field select,
.search-field .form-control,
.search-field .form-select {
    border: var(--search-border-width) solid var(--search-border-color);
    border-radius: var(--search-border-radius);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    height: var(--search-input-height);
    background-color: #fff;
}

.search-field input:focus,
.search-field select:focus,
.search-field .form-control:focus,
.search-field .form-select:focus {
    border-color: var(--search-border-focus);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.15);
    outline: none;
}

/* ============================================
   3. GUEST PICKER DROPDOWN
   ============================================ */
.guest-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 300px;
    max-width: 400px;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: var(--search-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1100;
}

.guest-picker-content {
    padding: 1rem;
}

.guest-picker-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
}

.guest-picker-row:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

.guest-picker-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
}

.guest-picker-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.guest-picker-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--search-primary);
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--search-primary);
    padding: 0;
}

.guest-picker-btn:hover {
    background: var(--search-primary);
    color: white;
}

.guest-picker-btn:active {
    transform: scale(0.95);
}

.guest-picker-btn:disabled,
.guest-picker-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.guest-picker-btn:focus {
    outline: 2px solid var(--search-primary);
    outline-offset: 2px;
}

.guest-picker-value {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    color: #333;
    transition: transform 0.15s ease, color 0.15s ease;
}

/* Animation de feedback sur changement de valeur */
.guest-picker-value.value-changed {
    transform: scale(1.2);
    color: var(--search-primary);
}

/* Mobile confirm button */
.guest-picker-confirm {
    padding: 0.75rem 1rem;
    border-top: 1px solid #f0f0f0;
}

.guest-picker-confirm-btn {
    height: 44px;
    font-weight: 600;
}

/* Animation d'ouverture du dropdown */
.guest-picker-dropdown.opening {
    animation: dropdownSlideIn 0.2s ease-out;
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Input style pour guest picker */
[data-guest-picker] {
    cursor: pointer;
    user-select: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background-color: white !important;
}

[data-guest-picker]:read-only {
    background-color: white;
    cursor: pointer;
}

/* ============================================
   4. DATE PICKER (Flatpickr overrides)
   ============================================ */
[data-datepicker] {
    cursor: pointer;
    background-color: white !important;
}

[data-datepicker]:read-only {
    background-color: white;
    cursor: pointer;
}

/* Nights display */
.nights-display {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #6c757d;
    pointer-events: none;
    background: white;
    padding: 0 4px;
}

/* ============================================
   5. SEARCH BUTTONS
   ============================================ */
.btn-search-hotels,
.btn-search-restaurants,
.btn-search-experiences,
.btn-search-attractions {
    height: var(--search-input-height);
    min-height: var(--search-input-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    transition: all 0.2s ease;
}

/* Loading state for search buttons */
.btn-loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-loading .fa-spinner {
    font-size: 1.2rem;
}

/* ============================================
   6. SEARCH SUMMARY MOBILE
   ============================================ */
.search-summary-mobile {
    background: white;
    border: var(--search-border-width) solid var(--search-border-color);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 16px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.search-summary-mobile:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-summary-mobile:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.search-summary-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-summary-content > i:first-child {
    font-size: 20px;
    color: #0d6efd;
}

.search-summary-content > i:last-child {
    font-size: 18px;
    margin-left: auto;
    color: #6c757d;
}

.search-summary-text {
    flex: 1;
    min-width: 0;
}

.summary-destination {
    font-weight: 600;
    font-size: 16px;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-details {
    font-size: 13px;
    color: #6c757d;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   7. SEARCH MODAL
   ============================================ */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8f9fa;
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.search-modal.active {
    display: flex;
    animation: searchModalSlideUp 0.3s ease-out;
}

@keyframes searchModalSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Header du modal */
.search-modal-header {
    background: white;
    padding: 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-close-modal:hover {
    color: #333;
}

.search-modal .modal-title {
    flex: 1;
    text-align: center;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

/* Body du modal */
.search-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    -webkit-overflow-scrolling: touch;
}

.search-modal-body .search-field {
    margin-bottom: 16px;
}

.search-modal-body .form-control,
.search-modal-body .form-select {
    font-size: 16px; /* Évite le zoom sur iOS */
    padding: 12px 14px;
}

.search-modal-body .input-with-icon .form-control,
.search-modal-body .input-with-icon .form-select {
    padding-left: 50px;
}

.search-modal-body .btn-search-hotels,
.search-modal-body .btn-search-restaurants,
.search-modal-body .btn-search-experiences,
.search-modal-body .btn-search-attractions {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 20px;
}

/* Body overflow hidden quand modal ouvert */
body.modal-open {
    overflow: hidden;
}

/* ============================================
   8. SEARCH LISTING WRAPPER
   ============================================ */
.search-listing-wrapper .form-control,
.search-listing-wrapper .form-select {
    border: 3px solid var(--search-border-color);
    height: var(--search-input-height);
}

.search-listing-wrapper .form-control:focus,
.search-listing-wrapper .form-select:focus {
    border-color: var(--search-border-focus);
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25);
}

/* ============================================
   9. SEARCH LARGE (Homepage)
   ============================================ */
.search-large .search-field input,
.search-large .search-field select,
.search-large .search-field .form-control,
.search-large .search-field .form-select {
    border-width: 3px;
}

/* ============================================
   10. RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 767.98px) {
    /* Masquer le formulaire desktop en mobile */
    .search-form-desktop {
        display: none !important;
    }
    
    /* Search Box mobile */
    .search-box {
        padding: 1rem;
        border-radius: 8px;
    }
    
    /* Tabs mobile - icons + small text */
    .search-tabs {
        justify-content: space-around;
        gap: 0.25rem;
        margin-bottom: 1rem;
    }
    
    .search-tab {
        flex: 1;
        padding: 0.75rem 0.5rem;
        flex-direction: column;
        gap: 0.25rem;
        font-size: 0.75rem;
    }
    
    .search-tab i {
        font-size: 1.25rem;
    }
    
    .search-tab span {
        font-size: 0.7rem;
    }
    
    /* Forms mobile - full width inputs */
    .search-form .row {
        row-gap: 0.75rem;
    }
    
    .search-form [class*="col-md-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Labels mobile */
    .search-box .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
    }
    
    /* Inputs mobile */
    .search-box .form-control,
    .search-box .form-select {
        font-size: 0.875rem;
        height: 44px;
    }
    
    .input-with-icon .form-control,
    .input-with-icon .form-select {
        padding-left: 40px !important;
        padding-right: 0.5rem !important;
    }
    
    .input-icon {
        font-size: 1rem;
        left: 12px;
    }
    
    /* Search buttons sticky mobile */
    .btn-search-hotels,
    .btn-search-restaurants,
    .btn-search-experiences,
    .btn-search-attractions {
        position: sticky;
        bottom: 10px;
        height: 50px;
        font-size: 1rem;
        font-weight: 600;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        z-index: 50;
        margin-top: 1rem;
    }
    
    /* Guest picker dropdown en position fixe sur mobile */
    .guest-picker-dropdown {
        position: fixed;
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: 80px;
        margin-top: 0;
        z-index: 1200;
        min-width: auto;
        max-width: none;
    }
    
    .guest-picker-content {
        max-height: 50vh;
        overflow-y: auto;
    }
    
    /* Search listing wrapper mobile */
    .search-listing-wrapper {
        background: white;
        border-radius: 8px;
        padding: 1rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        border: 1px solid #e5e7eb;
    }
}

/* ============================================
   11. RESPONSIVE - DESKTOP
   ============================================ */
@media (min-width: 768px) {
    /* Masquer le résumé mobile sur desktop */
    .search-summary-mobile {
        display: none !important;
    }
    
    /* Masquer le modal sur desktop */
    .search-modal {
        display: none !important;
    }
}

/* ============================================
   12. AUTOCOMPLETE DROPDOWN
   ============================================ */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: var(--search-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    max-height: 300px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #f8f9fa;
}

.autocomplete-item-name {
    font-weight: 500;
    color: #212529;
}

.autocomplete-item-detail {
    font-size: 0.85rem;
    color: #6c757d;
}

@media (max-width: 767.98px) {
    .autocomplete-dropdown {
        position: fixed !important;
        left: 1rem !important;
        right: 1rem !important;
        max-height: 60vh;
        width: auto !important;
    }
}

/* ============================================
   13. FLATPICKR CUSTOMIZATION
   ============================================ */
.flatpickr-calendar {
    border-radius: var(--search-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--search-primary);
    border-color: var(--search-primary);
}

.flatpickr-day.inRange {
    background: rgba(7, 152, 203, 0.1);
    border-color: transparent;
}

.flatpickr-day:hover {
    background: rgba(7, 152, 203, 0.2);
    border-color: transparent;
}

/* ============================================
   14. FORM VALIDATION ERRORS
   ============================================ */
.search-field.has-error .form-control,
.search-field.has-error .form-select,
.search-field .form-control.is-invalid,
.search-field .form-select.is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.search-field-error {
    color: #dc3545;
    font-size: 0.8rem;
    margin-top: 4px;
    display: none;
}

/* Animation shake pour les erreurs */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* Style pour les erreurs Laravel (retour serveur) */
.invalid-feedback {
    display: block;
    color: #dc3545;
    font-size: 0.8rem;
    margin-top: 4px;
}
