/**
 * GI FAQ Search - Stili del campo di ricerca FAQ
 *
 * Plugin WordPress per Grassini Impianti srl
 * Design responsive, accessibile e compatibile con i principali temi WP.
 *
 * v2.4.1 — Bottom-up collapse con gap cleanup
 */

/* ==========================================================================
   0. HIDING — Nasconde FAQ non pertinenti (v2.4.1)
   
   APPROCCIO BOTTOM-UP COLLAPSE:
   Il JS marca SOLO le FAQ non pertinenti con data-gi-h="1".
   Poi collassa i wrapper vuoti dal basso verso l'alto.
   Gap cleanup elimina spacer/separator residui.
   L'intro NON viene MAI toccata.
   ========================================================================== */
[data-gi-h="1"] {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    line-height: 0 !important;
}
 *
 * Ref: WCAG 2.1 Contrast Requirements - https://www.w3.org/TR/WCAG21/#contrast-minimum
 * Ref: Material Design Search - https://m3.material.io/components/search
 *
 * @package GI_FAQ_Search
 * @version 1.0.0
 */

/* ==========================================================================
   1. WRAPPER PRINCIPALE
   ========================================================================== */

.gi-faq-search-wrapper {
    max-width: 720px;
    margin: 2rem auto;
    padding: 1.5rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    position: relative;
    z-index: 10;
}

/* ==========================================================================
   2. CONTAINER INPUT
   ========================================================================== */

.gi-faq-search-input-container {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #d0d5dd;
    border-radius: 12px;
    padding: 0;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
}

/* Focus state - colore primario Grassini Impianti (blu/verde) */
.gi-faq-search-input-container:focus-within {
    border-color: #1a73e8;
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.15),
                0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Hover state */
.gi-faq-search-input-container:hover {
    border-color: #98a2b3;
}

/* ==========================================================================
   3. ICONA LENTE
   ========================================================================== */

.gi-faq-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 48px;
    color: #667085;
    pointer-events: none;
}

.gi-faq-search-input-container:focus-within .gi-faq-search-icon {
    color: #1a73e8;
}

/* ==========================================================================
   4. CAMPO INPUT
   ========================================================================== */

.gi-faq-search-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-size: 16px; /* Minimo 16px per evitare zoom su iOS */
    line-height: 1.5;
    padding: 12px 8px;
    color: #1d2939;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

/* Placeholder */
.gi-faq-search-input::placeholder {
    color: #98a2b3;
    font-style: italic;
    font-size: 14px;
}

/* Rimuovi il pulsante "x" nativo dei browser WebKit */
.gi-faq-search-input::-webkit-search-cancel-button,
.gi-faq-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

/* ==========================================================================
   5. PULSANTE CANCELLA
   ========================================================================== */

.gi-faq-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    min-width: 40px;
    height: 40px;
    margin-right: 4px;
    border: none;
    background: #f2f4f7;
    border-radius: 8px;
    color: #667085;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    padding: 0;
}

.gi-faq-search-clear:hover {
    background: #fee4e2;
    color: #d92d20;
}

.gi-faq-search-clear:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

/* ==========================================================================
   6. BARRA DI STATO RISULTATI
   ========================================================================== */

.gi-faq-search-status {
    text-align: center;
    padding: 0.5rem 0;
    font-size: 14px;
    min-height: 1.5em;
    transition: opacity 0.3s ease;
}

.gi-faq-search-status:empty {
    display: none;
}

/* Stato: risultati trovati */
.gi-faq-search-status.has-results {
    color: #027a48;
    font-weight: 500;
}

/* Stato: nessun risultato */
.gi-faq-search-status.no-results {
    color: #b42318;
    font-weight: 500;
    padding: 1rem 0;
}

/* ==========================================================================
   7. SUGGERIMENTI RAPIDI (TAG CLOUD)
   ========================================================================== */

.gi-faq-search-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 0.75rem;
    padding: 0;
}

.gi-faq-suggestions-label {
    font-size: 13px;
    color: #667085;
    font-weight: 500;
    margin-right: 4px;
}

.gi-faq-suggestion-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #344054;
    background: #f2f4f7;
    border: 1px solid #e4e7ec;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.5;
    font-family: inherit;
}

.gi-faq-suggestion-tag:hover {
    background: #eff8ff;
    border-color: #1a73e8;
    color: #1a73e8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(26, 115, 232, 0.15);
}

.gi-faq-suggestion-tag:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.gi-faq-suggestion-tag:active {
    transform: translateY(0);
}

/* ==========================================================================
   8. EVIDENZIAZIONE TERMINI TROVATI
   ========================================================================== */

.gi-faq-highlight,
mark.gi-faq-highlight {
    background-color: #ffe066;
    color: inherit;
    padding: 1px 3px;
    border-radius: 3px;
    font-style: normal;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* ==========================================================================
   9. ANIMAZIONI FAQ ITEMS
   ========================================================================== */

.gi-faq-visible {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.gi-faq-hidden {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ==========================================================================
   10. ACCESSIBILITÀ: Screen Reader Only
   ========================================================================== */

.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ==========================================================================
   11. TEMA SCURO
   ========================================================================== */

.gi-faq-search-theme-dark .gi-faq-search-input-container {
    background: #1d2939;
    border-color: #475467;
}

.gi-faq-search-theme-dark .gi-faq-search-input-container:focus-within {
    border-color: #53b1fd;
    box-shadow: 0 0 0 4px rgba(83, 177, 253, 0.2);
}

.gi-faq-search-theme-dark .gi-faq-search-input {
    color: #f5f5f6;
}

.gi-faq-search-theme-dark .gi-faq-search-input::placeholder {
    color: #98a2b3;
}

.gi-faq-search-theme-dark .gi-faq-search-icon {
    color: #98a2b3;
}

.gi-faq-search-theme-dark .gi-faq-search-clear {
    background: #344054;
    color: #98a2b3;
}

.gi-faq-search-theme-dark .gi-faq-search-clear:hover {
    background: #7a271a;
    color: #fda29b;
}

.gi-faq-search-theme-dark .gi-faq-suggestion-tag {
    background: #344054;
    border-color: #475467;
    color: #d0d5dd;
}

.gi-faq-search-theme-dark .gi-faq-suggestion-tag:hover {
    background: #1d3a5c;
    border-color: #53b1fd;
    color: #53b1fd;
}

.gi-faq-search-theme-dark .gi-faq-search-status.has-results {
    color: #32d583;
}

.gi-faq-search-theme-dark .gi-faq-search-status.no-results {
    color: #fda29b;
}

/* ==========================================================================
   12. RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .gi-faq-search-wrapper {
        margin: 1rem auto;
        padding: 1rem;
    }

    .gi-faq-search-input {
        font-size: 16px; /* Mantieni 16px per evitare zoom iOS */
        padding: 10px 6px;
    }

    .gi-faq-search-input::placeholder {
        font-size: 13px;
    }

    .gi-faq-search-suggestions {
        gap: 6px;
    }

    .gi-faq-suggestion-tag {
        font-size: 12px;
        padding: 3px 10px;
    }
}

@media (max-width: 480px) {
    .gi-faq-search-wrapper {
        padding: 0.75rem;
    }

    .gi-faq-search-icon {
        width: 40px;
        min-width: 40px;
    }

    .gi-faq-suggestions-label {
        width: 100%;
        margin-bottom: 4px;
    }
}

/* ==========================================================================
   13. COMPATIBILITÀ CON TEMI WP COMUNI
   ========================================================================== */

/* Override per temi che forzano stili sugli input */
.gi-faq-search-wrapper input[type="search"] {
    box-sizing: border-box;
    margin: 0;
    max-width: 100%;
    height: auto;
}

/* Override per temi che aggiungono bordi o ombre sugli input */
.gi-faq-search-wrapper input[type="search"]:focus {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Assicura che il wrapper non sia influenzato dal tema */
.gi-faq-search-wrapper * {
    box-sizing: border-box;
}

/* ==========================================================================
   14. STAMPA
   ========================================================================== */

@media print {
    .gi-faq-search-wrapper {
        display: none !important;
    }

    .gi-faq-hidden {
        display: block !important;
        opacity: 1 !important;
    }
}
