/* ==========================================================================
   1. Layout Principale della Barra
   ========================================================================== */

.sticky-search-bar {
    /* position: sticky; */
    /* Come da istruzioni, gestito da Elementor */
    top: 0;
    width: 100%;
    background-color: #ffffff;
    padding: 10px 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    z-index: 999;
}

.search-bar-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Riga superiore: il cuore del layout compatto */
.search-bar-top-row {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
}


/* ==========================================================================
   2. Elementi della Barra (Ricerca, Filtri, Link)
   ========================================================================== */

/* Campo di ricerca: flessibile, occupa lo spazio rimanente */
.search-field-container {
    flex: 1 1 auto;
}

.reset-button-container {
    flex-shrink: 0;
}

#search-recipes {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 14px;
}

/* Contenitore del filtro spezie: con larghezze min/max */
.spice-filter-container {
    flex: 0 0 auto;
    min-width: 110px;
    max-width: 150px;
}

/* Link con le nuove icone */
.search-links {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.search-links a {
    color: #333;
    font-size: 20px;
    text-decoration: none;
    padding: 5px;
}

.search-links a:hover {
    color: var(--color-accent, #F5C140);
}


/* ==========================================================================
   3. Stile Componente Dropdown
   ========================================================================== */

.dropdown-container .dropdown-button {
    background-color: #f5f5f5;
    border: 1px solid #ccc;
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    text-align: left;
    white-space: nowrap;
}

.dropdown-container .dropdown-button:hover {
    background-color: #e0e0e0;
}

.dropdown-container .dropdown-content {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    margin-top: 10px;
    border-radius: 5px;
    padding: 10px;
    border: 1px solid #ddd;
    /* --- NUOVO: Regole per lo scorrimento dei filtri --- */
    max-height: 400px;
    overflow-y: auto;
    padding-right: 15px;
}

.dropdown-container .dropdown-content.show {
    display: block;
}

.dropdown-content label {
    display: block;
    padding: 5px;
    cursor: pointer;
}

.dropdown-content label:hover {
    background-color: #f1f1f1;
}

/* --- NUOVO: Stili per i filtri --- */
.category-section {
    margin: 10px 0;
}

.category-header {
    font-weight: bold;
    color: #666;
    margin: 10px 0 5px;
    padding: 5px 0;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.category-items {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.show-more {
    color: #0073aa;
    cursor: pointer;
    font-size: 0.9em;
    margin-top: 5px;
    display: block;
}

.spice-label {
    display: block;
    margin: 3px 0;
    transition: opacity 0.2s;
}

.category-items .spice-label:nth-child(n+6) {
    display: none;
}


/* ==========================================================================
   4. Filtri Sottocategorie
   ========================================================================== */

/* Contenitore del filtro categorie: con larghezze min/max */
.category-filter-container {
    flex: 0 0 auto;
    min-width: 180px;
    max-width: 220px;
}


/* ==========================================================================
   6. Stili per Icona Help e Modal (Popup)
   ========================================================================== */

/* Nascondi il sottotitolo "Help" su desktop */
.search-links .icon-subtitle {
    display: none;
}

/* Stili del Popup (Modal) */
.recipe-help-modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease-out;
    /* --- CORREZIONE MODAL --- */
    /* Rimosso 'overflow: auto;' da qui */
}

/* Classe per mostrare il modal */
.recipe-help-modal.show-modal {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Aggiunto padding per evitare che il box tocchi i bordi */
    padding: 20px;
    box-sizing: border-box;
}

.recipe-modal-content {
    background-color: #fff;
    margin: auto;
    padding: 25px 30px;
    border-radius: 8px;
    width: 90%;
    /* Aggiunto per schermi piccoli */
    max-width: 800px;
    /* Era 80% */
    max-height: 90vh;
    /* Era 80% */
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    overflow-wrap: break-word;
    /* --- CORREZIONE MODAL --- */
    overflow-y: auto;
    /* Aggiunto lo scorrimento QUI, sul box bianco */
}

.recipe-modal-close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.recipe-modal-close:hover,
.recipe-modal-close:focus {
    color: #000;
}

/* Stili per il contenuto del modal */
.recipe-modal-content h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 24px;
}

.recipe-modal-content h4.modal-subtitle {
    color: #F5C140;
    font-size: 20px;
    margin-top: 15px;
    margin-bottom: 10px;
}

.recipe-modal-content p,
.recipe-modal-content li {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.recipe-modal-content ul {
    padding-left: 20px;
    margin-bottom: 8px;
}

.recipe-modal-content li {
    margin-bottom: 8px;
}

.recipe-modal-content a {
    color: #0A2838;
    font-weight: bold;
    text-decoration: underline;
}

.recipe-modal-content a:hover {
    color: #F5C140;
}

.recipe-modal-content .modal-email-link a {
    text-decoration: none;
}

.recipe-modal-legend-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 10px;
}

/* Stili per il video responsive nel modal */
.recipe-modal-video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    /* Questo crea un formato 16:9 */
    height: 0;
    overflow: hidden;
    margin-bottom: 20px;
    /* Spazio tra il video e il testo sotto */
    border-radius: 8px;
    /* Smussa gli angoli del video */
}

.recipe-modal-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ==========================================================================
   5. Stili Responsive
   ========================================================================== */

@media (max-width: 768px) {

    /* Permette alla riga superiore di andare a capo */
    .search-bar-top-row {
        flex-wrap: wrap;
    }

    /* Riga 1: Ricerca e Reset */
    .search-field-container {
        flex: 1 1 auto;
        order: 1;
    }

    .reset-button-container {
        order: 2;
    }

    /* Riga 2: Filtri */
    .category-filter-container,
    .spice-filter-container {
        order: 3;
        flex-grow: 1;
        min-width: 150px;
    }

    /* Riga 3: Icone */
    .search-links {
        order: 4;
        width: 100%;
        margin-top: 15px;
        justify-content: space-around;
    }

    .erase-filter{
            order: 4;
            width: 100%;
            justify-content: space-around;
    }

    /* Stile per TUTTE le icone e sottotitoli */
    .search-links a {
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 20px;
        color: #333;
        text-decoration: none !important;
        flex-basis: 0;
        flex-grow: 1;
        padding: 5px;
    }

    /* Mostra TUTTI i sottotitoli */
    .search-links .icon-subtitle {
        display: block;
        font-size: 14px;
        font-weight: 500;
        color: #555;
        margin-top: 3px;
        white-space: nowrap;
        text-decoration: none !important;
    }
        .recipe-modal-video-wrapper {
            padding-bottom: 177.78%;
            /* Calcolo per 9:16 -> (16 / 9) * 100% */
        }
}