/**
 * Advanced Search Widget for Elementor
 * Main Styles
 */

:root {
    --asw-results-distance: 5px; /* Valeur par défaut, sera remplacée par JavaScript */
}

/* Container styles */
.asw-container {
    position: relative;
    width: 100%;
    overflow: visible;
}

/* Form styles */
.asw-search-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    position: relative;
    z-index: 1000;
}

.asw-search-input-wrapper {
    display: flex;
    width: 100%;
    position: relative;
    z-index: 1001;
}

.asw-search-input {
    flex: 1;
    padding: 10px 15px;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 4px 0 0 4px;
    font-size: 16px;
    line-height: 1.5;
    background-color: #000000;
    color: #ffffff;
}

/* Supprimer la croix native du navigateur seulement pour les champs qui ont un bouton personnalisé */
.asw-search-input-wrapper.has-custom-clear .asw-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    display: none;
}
.asw-search-input-wrapper.has-custom-clear .asw-search-input::-ms-clear {
    display: none;
}

/* S'assurer que même en focus il n'y a pas de bordure */
.asw-search-input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.asw-search-button {
    padding: 10px 20px;
    background-color: #4054b2;
    color: #ffffff;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-size: 16px;
    line-height: 1.5;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.asw-search-button:hover {
    background-color: #3443a0;
}

/* Icon button styles */
.asw-search-button i, 
.asw-off-canvas-button i,
.asw-fullscreen-button i,
.asw-search-button svg, 
.asw-off-canvas-button svg,
.asw-fullscreen-button svg {
    font-size: 1em;
    line-height: 1;
    text-align: center;
    display: inline-block;
    margin: 0;
    width: 1em;
    height: 1em;
}

.asw-search-button .elementor-icon {
    color: inherit;
    font-size: inherit;
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.asw-search-button svg, 
.asw-off-canvas-button svg,
.asw-fullscreen-button svg {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    fill: currentColor;
}

/* Off Canvas styles */
.asw-off-canvas-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background-color: #4054b2;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1.5;
    transition: all 0.3s ease;
}

.asw-off-canvas-button:hover {
    background-color: #3443a0;
}

.asw-off-canvas-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 9998;
}

.asw-off-canvas {
    position: fixed;
    top: -120px; /* Slightly off-screen */
    left: 0;
    width: 100%;
    background-color: #000;
    z-index: 9999;
    overflow-y: auto;
    transition: top 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

.asw-off-canvas.open {
    top: 0;
}

.asw-off-canvas-overlay.open {
    display: block;
}

body.asw-off-canvas-open {
    overflow: hidden;
}

.asw-off-canvas .asw-search-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
}

.asw-off-canvas .asw-search-input {
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
}

.asw-off-canvas .asw-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.asw-off-canvas .asw-search-button {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Fullscreen styles */
.asw-fullscreen-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background-color: #4054b2;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1.5;
    transition: all 0.3s ease;
}

.asw-fullscreen-button:hover {
    background-color: #3443a0;
}

.asw-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.asw-fullscreen.open {
    display: flex;
    opacity: 1;
}

.asw-fullscreen-content {
    width: 80%;
    max-width: 800px;
    position: relative;
}

.asw-fullscreen-close {
    position: absolute;
    top: 40px;
    right: 40px;
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: #ffffff;
    transition: color 0.3s ease;
    z-index: 10001;
}

.asw-fullscreen-close:hover {
    color: #dddddd;
}

.asw-fullscreen-form {
    background: transparent;
    padding: 0;
    width: 100%;
}

.asw-fullscreen .asw-search-input-wrapper {
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    width: 100%;
}

.asw-fullscreen .asw-search-input {
    background-color: transparent;
    border: none;
    border-radius: 0;
    color: #ffffff;
    font-size: 24px;
    padding: 15px 5px;
    transition: border-color 0.3s ease;
    width: 100%;
}

.asw-fullscreen .asw-search-input:focus {
    outline: none;
}

.asw-fullscreen .asw-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.asw-fullscreen .asw-search-button {
    background-color: transparent;
    color: #ffffff;
    font-size: 24px;
    border-radius: 0;
    padding: 15px 20px;
}

.asw-fullscreen .asw-search-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.asw-fullscreen .asw-ajax-results {
    position: relative;
    background-color: rgba(255, 255, 255, 0.95);
    margin-top: var(--asw-results-distance);
    max-height: 50vh;
    top: auto;
    border-radius: 6px;
}

/* AJAX results styles - Detached from DOM */
body > .asw-ajax-results {
    display: none;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    position: absolute;
    left: 0;
    top: 0;
    z-index: 999999;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

body > .asw-ajax-results.asw-show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Flèche pointant vers le haut pour le dropdown */
body > .asw-ajax-results:before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%; /* Centrer la flèche */
    margin-left: -8px; /* Décalage pour centrer par rapport à la largeur de la flèche */
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
    z-index: 2;
}

body > .asw-ajax-results:after {
    content: '';
    position: absolute;
    top: -9px;
    left: 50%; /* Centrer la flèche */
    margin-left: -9px; /* Décalage pour centrer par rapport à la largeur de la flèche */
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid #ddd;
    z-index: 1;
}

/* Make scrollbar more aesthetic */
.asw-ajax-results::-webkit-scrollbar {
    width: 6px;
}

.asw-ajax-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.asw-ajax-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
}

.asw-ajax-results::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Ensure the container has relative positioning for absolute positioning of results */
.asw-search-form {
    position: relative !important;
    z-index: 10000;
}

/* Force le positionnement pour le header */
.elementor-location-header .asw-search-form,
.elementor-section-wrap header .asw-search-form {
    position: relative !important;
    z-index: 10000;
}

/* Wrapper for search input needs higher z-index than dropdown */
.asw-search-input-wrapper {
    position: relative !important;
    z-index: 10001 !important;
    width: 100%;
}

/* Fix for container sizing - prevent growth */
.asw-container {
    position: relative !important;
    width: 100%;
    overflow: visible !important;
}

/* Fix for elementor header containers */
.elementor-location-header .asw-container,
.elementor-section-wrap header .asw-container,
.elementor-section.elementor-section-boxed > .elementor-container .asw-container {
    overflow: visible !important;
}

/* Different position for fullscreen */
.asw-fullscreen .asw-ajax-results {
    position: relative !important;
    background-color: rgba(255, 255, 255, 0.95);
    margin-top: var(--asw-results-distance);
    max-height: 50vh;
    top: auto !important;
    border-radius: 6px;
}

/* Styles améliorés pour les résultats */
.asw-result-item {
    transition: background-color 0.2s ease;
}

.asw-result-item a {
    padding: 15px;
    display: flex;
    align-items: flex-start;
}

.asw-result-title {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 600;
}

.asw-result-excerpt {
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    color: #666;
}

/* Résultats de recherche améliorés */
.asw-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.asw-result-type {
    font-size: 12px;
    background-color: #f0f0f0;
    color: #555;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    margin-left: 10px;
}

.asw-highlight {
    background-color: rgba(255, 230, 0, 0.4);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: bold;
}

/* Messages d'information */
.asw-no-results,
.asw-error {
    padding: 20px;
    text-align: center;
    color: #777777;
    border-top: 1px solid #f0f0f0;
}

.asw-error {
    color: #d32f2f;
    background-color: #ffebee;
    border-top: 1px solid #ffcdd2;
}

.asw-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
}

.asw-loading span {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #eee;
    border-radius: 50%;
    border-top-color: #4054b2;
    animation: asw-spin 1s ease-in-out infinite;
}

@keyframes asw-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive styles */
@media screen and (max-width: 767px) {
    .asw-result-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .asw-result-title {
        font-size: 14px;
    }
    
    .asw-result-excerpt {
        font-size: 12px;
    }

    .asw-fullscreen-content {
        width: 95%;
    }

    .asw-fullscreen .asw-search-input {
        font-size: 18px;
    }

    .asw-fullscreen .asw-search-button {
        font-size: 18px;
    }
    
    .asw-fullscreen-close {
        top: 20px;
        right: 20px;
    }

    body > .asw-ajax-results {
        left: 50% !important; /* Forcer le centrage horizontal */
        transform: translateX(-50%) !important; /* Centrer parfaitement */
        width: calc(100% - 30px) !important; /* Largeur presque pleine avec marges */
        max-width: 320px !important; /* Limiter la largeur maximale */
        position: absolute !important;
        max-height: 60vh !important;
        border-radius: 8px !important;
        margin: 0 !important;
    }
    
    body > .asw-ajax-results.asw-show {
        display: block !important;
    }
    
    /* Garder la flèche pointant vers le haut */
    body > .asw-ajax-results:before,
    body > .asw-ajax-results:after {
        display: block !important;
    }
    
    /* Améliorer les styles pour la lisibilité sur mobile */
    body > .asw-ajax-results .asw-result-title {
        font-size: 14px !important;
    }
    
    body > .asw-ajax-results .asw-result-excerpt {
        font-size: 12px !important;
    }
    
    body > .asw-ajax-results .asw-result-thumbnail {
        width: 40px !important;
        height: 40px !important;
    }
    
    /* Améliorer la visibilité du bouton "Voir tous les résultats" */
    body > .asw-ajax-results .asw-view-all {
        padding: 12px !important;
        background-color: #f5f5f5 !important;
    }
}

.asw-results-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.asw-result-item {
    padding: 0;
    border-bottom: 1px solid #eeeeee;
    transition: background-color 0.2s ease;
}

.asw-result-item:last-child {
    border-bottom: none;
}

.asw-result-item a {
    display: flex;
    padding: 15px;
    text-decoration: none;
    color: inherit;
}

.asw-result-item:hover {
    background-color: #f9f9f9;
}

.asw-result-thumbnail {
    width: 60px;
    height: 60px;
    margin-right: 15px;
    flex-shrink: 0;
}

.asw-result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 3px;
}

.asw-result-content {
    flex: 1;
}

.asw-view-all {
    padding: 15px;
    text-align: center;
    border-top: 1px solid #eeeeee;
}

.asw-view-all a {
    color: #4054b2;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s ease;
}

.asw-view-all a:hover {
    color: #3443a0;
    text-decoration: underline;
}

/* Different position for off-canvas */
.asw-off-canvas .asw-ajax-results {
    position: relative !important;
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    margin-top: var(--asw-results-distance);
    box-shadow: none;
    top: auto !important;
    color: #fff;
}

.asw-off-canvas .asw-result-item {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.asw-off-canvas .asw-result-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.asw-off-canvas .asw-result-title {
    color: #fff;
}

.asw-off-canvas .asw-result-excerpt {
    color: rgba(255, 255, 255, 0.7);
}

.asw-off-canvas .asw-view-all a {
    color: #fff;
}

/* Styles spécifiques pour les résultats en mode mobile */
body > .asw-ajax-results.asw-mobile-results {
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 30px) !important;
    max-width: 320px !important;
    border-radius: 8px !important;
    margin: var(--asw-results-distance) 0 0 0 !important;
    position: absolute !important;
    max-height: 60vh !important;
}

body > .asw-ajax-results.asw-mobile-results:before,
body > .asw-ajax-results.asw-mobile-results:after {
    left: 50%;
}

body > .asw-ajax-results.asw-mobile-results:before {
    margin-left: -8px;
}

body > .asw-ajax-results.asw-mobile-results:after {
    margin-left: -9px;
}

/* Styles pour le bouton de suppression */
.asw-clear-button {
    position: absolute;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: #999;
    transition: color 0.2s ease;
    z-index: 9999;
    display: none; /* Caché par défaut */
    width: 20px;
    height: 20px;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.asw-clear-button:hover {
    color: #fff;
    opacity: 0.8;
}

.asw-clear-button img {
    max-width: 100%;
    max-height: 100%;
}

.asw-clear-button i,
.asw-clear-button svg {
    width: 100%;
    height: 100%;
    display: inline-block;
    vertical-align: middle;
}

/* S'assurer que le bouton est bien visible sur le fond sombre */
.asw-search-input[style*="background-color: #000000"] + .asw-clear-button {
    color: #fff;
}

/* Quand le bouton est visible, augmenter son opacité au survol */
.asw-clear-button:hover {
    opacity: 1;
}

/* Ajustement pour le mobile */
@media screen and (max-width: 767px) {
    .asw-clear-button {
        width: 16px;
        height: 16px;
        font-size: 12px;
    }
} 