/* Conteneur principal */
.ajax-search-container {
    position: relative;
    width: 100%;
    margin: 20px 0;
}

/* Champ de saisie */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#searchInput {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid #e2e2e2;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

#searchInput:focus {
    border-color: #a0a0a0;
}

/* Le Spinner */
.loader {
    position: absolute;
    right: 15px;
    width: 20px;
    height: 20px;
    margin-top: -34px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Le conteneur qui contient tous les résultats */

#datafetch.search-results {
    position: fixed;
    top: 200px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 9999;
    
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    /* On augmente le padding top pour que le bouton ne chevauche pas les images */
    padding: 0px 20px 20px 20px; 
    list-style: none;
}

#close-search {
    /* On repasse en absolute pour qu'il "flotte" sans pousser les autres */
    position: absolute; 
    top: 10px;
    right: -40px;
    
    background: #333;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    font-size: 20px;
    
    /* Indispensable pour rester au-dessus des images qui scrollent */
    z-index: 10001; 
}

#close-search:hover {
    background: #d32f2f;
}
/* Chaque bloc de produit */
.search-result-item {
    width: 150px;         /* Largeur calée sur tes images */
    text-align: center;   /* Centre le texte sous l'image */
    margin:10px;
}

/* Lien et contenu interne */
.search-result-item a {
    display: flex;
    flex-direction: column; /* Empile l'image, le titre et le prix verticalement */
    text-decoration: none;
    color: inherit;
}

/* On s'assure que l'image ne dépasse pas */
.search-result-item img {
    display: block;
    margin-bottom: 8px;
    border-radius: 4px;    /* Optionnel : arrondit les coins */
}

.search-result-item .cat-links {
    display: block;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    margin-top: 2px;
}

.search-result-item .title {
    display: block;
    margin-top: 5px;
    line-height: 1.2;
}
.search-history {
    position: absolute;
    font-size: 12px;
    margin-top: 5px;
    color: #fff;
}

.history-item {
    background: #f0f0f0;
    padding: 0px 8px;
    border-radius: 12px;
    cursor: pointer;
    margin-right: 5px;
    display: inline-block;
    color:#666;
}

.history-item:hover {
    background: #e0e0e0;
}
@media (max-width: 768px) {
    @media (max-width: 768px) {
    /* On ajuste le conteneur pour le mobile */
    #datafetch.search-results {
        top: 60px;
        width: 95%;
        padding: 60px 10px 20px 10px; /* Moins de padding sur les côtés */
        justify-content: space-between; /* Aligne bien les deux colonnes */
    }

    /* On force 2 éléments par ligne */
    .search-result-item {
        /* Calcul : (100% / 2) - la moitié du gap (20px / 2 = 10px) */
        width: calc(50% - 30px); 
        margin-bottom: 10px;
        text-align: center;
    }

    /* On s'assure que l'image s'adapte à cette nouvelle largeur */
    .search-result-item img {
        width: 100%;
        height: auto;
        max-width: 150px; /* Garde une taille cohérente */
        margin: 0 auto 8px auto;
    }

    /* Ajustement du bouton fermer pour mobile */
    #close-search.fixed-close {
        top: 0px;
        right: 0px;
        left: auto;
        transform: none;
        width: 30px;
        height: 30px;
    }
}
}