/**
 * Estilos para el Buscador de Alérgenos (Frontend)
 * Versión 1.4.0 - Corrección Total de Alineación, Gaps y Alertas
 */

:root {
    --green-card: #54664f;
    --texto-card: #725b40;
    --radius-xl: 32px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --bg-image: url('../images/form-background.svg');
}

/* 1. ANIMACIONES */
@keyframes saFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes saRotate {
    to { transform: rotate(360deg); }
}

/* 2. CONTENEDOR EXTERIOR */
#saef-filtro-container {
    position: relative;
    max-width: 1100px;
    margin: 40px auto;
    padding: 40px;
    border-radius: var(--radius-xl);
    overflow: visible;
    background: var(--bg-image);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, .25);
}

/* 3. TARJETA DEL FORMULARIO */
.saef-card {
    position: relative;
    z-index: 1;
    background: var(--bg-image);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

/* 4. TEXTOS */
#saef-filtro-container h3 {
    margin: 0 0 15px;
    font-size: 40px;
    font-weight: 700;
    color: var(--green-card);
}

#saef-filtro-container p {
    margin: 0 0 35px;
    font-size: 20px;
    color: var(--texto-card);
}

/* 5. ESTRUCTURA DEL FORMULARIO Y ETIQUETAS */
.saef {
    display: flex !important;
    align-items: stretch !important; /* Obliga al botón a tener la misma altura que el input */
    gap: 15px;
    width: 100%;
}

.saef-input-wrapper {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px; /* ESPACIO ENTRE ETIQUETAS */
    padding: 10px 15px;
    background: rgba(255, 255, 255, .9);
    border: 1px solid rgba(123, 104, 79, 0.45);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 12px rgba(120, 90, 50, .15);
    min-height: 64px !important;
    box-sizing: border-box !important;
}

.saef-tag {
    display: inline-flex;
    align-items: center;
    background: var(--green-card);
    color: #fff;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

.saef-tag-remove {
    margin-left: 10px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.8;
}

.saef-tag-remove:hover { opacity: 1; }

#saef-allergen-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 18px !important;
    color: #555;
    height: 40px !important;
    line-height: 40px !important;
    min-width: 180px;
    margin: 0 !important;
    padding: 0 !important;
}

.saef-button {
    height: auto !important; /* Permitimos que align-items stretch del padre mande */
    min-height: 64px !important;
    padding: 0 32px !important;
    background: var(--green-card) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--radius-md) !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin: 0 !important;
}

.saef-button:hover { background: #718d69 !important; }

/* 6. LISTA DE AUTOCOMPLETADO */
.saef-autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-width: 600px; /* Evitamos que sea excesivamente larga */
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    z-index: 999;
    margin-top: 8px;
    display: none;
    overflow: hidden;
    border: 1px solid rgba(123, 104, 79, 0.2);
    animation: saFadeIn 0.3s ease-out forwards;
}

.saef-autocomplete-list ul { list-style: none; margin: 0; padding: 0; }

.saef-autocomplete-list li {
    padding: 14px 20px;
    cursor: pointer;
    font-size: 18px;
    color: var(--texto-card);
    transition: all 0.2s ease;
    text-align: left;
    border-bottom: 1px solid rgba(123, 104, 79, 0.08);
}

.saef-autocomplete-list li:hover {
    background: #fdfaf7;
    color: var(--green-card);
    padding-left: 25px;
}

/* 7. RESULTADOS Y ALERTAS */
#saef-resultado { margin-top: 45px; }

.saef-alerta-parcial {
    padding: 25px !important;
    background: #fff8f8 !important;
    border: 2px dashed #e5a4a4 !important;
    border-radius: var(--radius-md) !important;
    color: #a94442 !important;
    text-align: center;
    margin: 20px 0;
    animation: saFadeIn 0.4s ease;
}

.saef-alerta-parcial h4 { color: #a94442 !important; margin-bottom: 10px !important; font-size: 20px !important; }
.saef-alerta-parcial p { margin: 0 !important; font-size: 16px !important; color: #725b40 !important; }

.saef-productos-filtrados-lista {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    list-style: none;
    margin-top: 20px;
}

.saef-producto-resultado { list-style: none !important; margin-bottom: 0; }

.saef-producto-resultado a {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 20px;
    background: #fff;
    border-radius: var(--radius-md);
    padding: 12px 20px;
    border: 1px solid #eee;
    transition: all 0.2s ease;
}

.saef-producto-resultado a:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.saef-producto-resultado img {
    width: 60px !important;
    height: 60px !important;
    object-fit: cover !important;
    border-radius: 8px;
    flex-shrink: 0;
}

.saef-product-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.saef-title { font-size: 18px; font-weight: 700; color: var(--green-card); }
.saef-precio { font-size: 18px; color: #333; font-weight: 700; }

/* 8. MÓVIL */
@media (max-width: 768px) {
    #saef-filtro-container {
        padding: 20px 15px;
        margin: 10px;
    }

    .saef-card {
        padding: 20px 15px;
    }

    #saef-filtro-container h3 {
        font-size: 28px;
        text-align: center;
    }

    #saef-filtro-container p {
        font-size: 16px;
        text-align: center;
        margin-bottom: 25px;
    }

    /* Formulario en vertical */
    .saef {
        flex-direction: column;
        gap: 10px;
    }

    .saef-input-wrapper {
        min-height: 55px !important;
        padding: 8px;
    }

    /* Corrección del botón con texto largo */
    .saef-button {
        width: 100% !important;
        min-height: 55px !important;
        font-size: 16px !important; /* Bajamos un poco el tamaño para que quepa el texto */
        padding: 12px !important;
        white-space: normal !important; /* Permite que el texto salte de línea si es muy largo */
        line-height: 1.2 !important;
    }

    /* Lista de productos en móvil */
    .saef-producto-resultado a {
        padding: 12px;
        gap: 12px;
    }

    .saef-product-info {
        flex-direction: column; /* Título arriba, precio abajo */
        align-items: flex-start;
        gap: 5px;
    }

    .saef-precio {
        font-size: 15px;
    }

    .saef-title {
        font-size: 15px;
        line-height: 1.3;
    }

    /* Botón final en móvil */
    .saef-enlace-completo .saef-button {
        width: 100% !important;
        font-size: 15px !important;
    }
}

/* =========================================
   9. TÍTULO DINÁMICO DE PÁGINA DE RESULTADOS
   ========================================= */

.saef-results-page-title {
    font-size: 32px !important;
    font-weight: 700 !important;
    color: var(--texto-card) !important;
    line-height: 1.2 !important;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(84, 102, 79, 0.1); /* Línea sutil decorativa */
}

/* El número de productos (el strong original) */
.saef-results-page-title strong {
    color: var(--green-card); /* Color verde de tu marca */
    font-size: 1.1em;
}

/* NUEVO: Los alérgenos en Mayúsculas y Color Destacado */
.saef-results-page-title .saef-allergen-name {
    color: #d35400; /* Un color naranja oscuro/teja que destaca mucho */
    text-transform: uppercase; /* ¡Todo a MAYÚSCULAS! */
    font-weight: 800;
    display: inline-block;
    padding: 0 5px;
}

/* Adaptación para móvil */
@media (max-width: 768px) {
    .saef-results-page-title {
        font-size: 24px !important;
        text-align: center !important;
    }
}

