/* =========================================================
   WP AutoTranslate — Selettore lingua frontend
   ========================================================= */

/* Contenitore principale nel menu */
.wpat-lang-switcher {
    position: relative;
    list-style: none;
}

/* Lingua corrente (sempre visibile) */
.wpat-current-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: 500;
    white-space: nowrap;
    user-select: none;
    transition: background 0.2s ease;
}

.wpat-current-lang:hover {
    background: rgba(0, 0, 0, 0.07);
}

/* Freccia dropdown */
.wpat-arrow {
    font-size: 0.65em;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.wpat-lang-switcher:hover .wpat-arrow,
.wpat-lang-switcher.wpat-open .wpat-arrow {
    transform: rotate(180deg);
}

/* Emoji bandiera */
.wpat-flag {
    font-size: 1.2em;
    line-height: 1;
}

/* Dropdown */
.wpat-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 160px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 6px 0;
    margin: 4px 0 0;
    z-index: 9999;
    list-style: none;
}

/* Mostra il dropdown al hover o con classe .wpat-open */
.wpat-lang-switcher:hover .wpat-dropdown,
.wpat-lang-switcher.wpat-open .wpat-dropdown {
    display: block;
}

/* Singola opzione lingua */
.wpat-lang-option {
    list-style: none;
}

.wpat-lang-option a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
    font-size: 0.9em;
    transition: background 0.15s ease;
    white-space: nowrap;
}

.wpat-lang-option a:hover {
    background: #f5f5f5;
    color: #000;
}

/* Lingua attiva */
.wpat-lang-option.wpat-active a {
    font-weight: 600;
    color: #0073aa;
}

.wpat-lang-option.wpat-active a::after {
    content: '✓';
    margin-left: auto;
    font-size: 0.85em;
    color: #0073aa;
}

/* =========================================================
   Versione inline (shortcode [wpat_switcher])
   ========================================================= */
.wpat-lang-switcher-inline {
    display: inline-block;
    position: relative;
}

/* =========================================================
   [wpat_select] — Dropdown bandiera-only nel trigger
   ========================================================= */

.wpat-select-wrap {
    position: relative;
    display: inline-block;
}

.wpat-select-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 1.3em;
    line-height: 1;
    color: inherit;
    transition: background 0.2s ease;
    backdrop-filter: blur(4px);
}

/* Mantiene visibile la freccia anche quando il tema forza color:white sull'hover.
   Il tema usa: button:where(...):hover { color: var(--theme-color-bg_color) } = bianco.
   Forziamo il colore del trigger e della freccia con !important per battere quella regola. */
.wpat-select-trigger,
.wpat-select-trigger:hover,
.wpat-select-trigger:focus,
.wpat-select-trigger:active {
    color: inherit !important;
}

/* Forza anche il colore di tutti i figli del trigger (freccia, bandiera) */
.wpat-select-trigger *,
.wpat-select-trigger:hover *,
.wpat-select-trigger:focus *,
.wpat-select-trigger:active * {
    color: inherit !important;
}

.wpat-select-trigger:hover {
    background: rgba(255,255,255,0.22) !important;
    border-color: rgba(255,255,255,0.45) !important;
}

.wpat-select-arrow {
    font-size: 0.6em;
    opacity: 0.7;
    margin-left: 2px;
    display: inline-block !important;
    visibility: visible !important;
    color: currentColor !important;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Freccia visibile sull'hover — forza opacità e colore con !important */
.wpat-select-trigger:hover .wpat-select-arrow,
.wpat-select-wrap.wpat-select-open .wpat-select-arrow {
    opacity: 1 !important;
    transform: rotate(180deg);
    color: currentColor !important;
    visibility: visible !important;
    display: inline-block !important;
}

.wpat-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    list-style: none;
    margin: 0;
    padding: 6px 0;
    z-index: 99999;
    overflow: hidden;
}

.wpat-select-wrap.wpat-select-open .wpat-select-dropdown {
    display: block;
    animation: wpat-select-fade-in 0.15s ease;
}

@keyframes wpat-select-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wpat-select-option a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    text-decoration: none;
    color: #333;
    font-size: 0.95em;
    transition: background 0.15s ease;
    white-space: nowrap;
}

.wpat-select-option a:hover {
    background: #f5f5f5;
}

.wpat-select-option.wpat-select-active a {
    font-weight: 700;
    color: #1a1a1a;
}

.wpat-select-item-flag {
    font-size: 1.3em;
    line-height: 1;
    flex-shrink: 0;
}

.wpat-select-item-label {
    flex: 1;
}

.wpat-select-check {
    color: #2271b1;
    font-weight: 700;
    font-size: 1em;
    margin-left: auto;
}

/* =========================================================
   [wpat_flags] — Bandierine inline
   ========================================================= */

.wpat-flags-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.wpat-flag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 1;
    transition: transform 0.15s ease, opacity 0.15s ease;
    opacity: 0.55;
    font-size: var(--wpat-flag-size, 28px);
}

.wpat-flag-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}

.wpat-flag-btn.wpat-flag-active {
    opacity: 1;
    transform: scale(1.1);
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}

.wpat-flag-emoji {
    display: block;
    line-height: 1;
}

/* =========================================================
   Compatibilità menu Elementor / tema:
   quando [wpat_flags] è usato come etichetta di un item del menu,
   la .sub-arrow (freccia SmartMenus) non deve diventare bianca sull'hover.
   Il tema applica color:white al link sull'hover, rendendo invisibile
   la freccia SVG che eredita quel colore. Forziamo il colore originale.
   ========================================================= */

/* Mantiene visibile la freccia del menu quando il tema forza color:white sull'hover */
.wpat-flags-inline ~ .sub-arrow,
a:has(.wpat-flags-inline) .sub-arrow,
.elementor-item:hover .sub-arrow,
.elementor-item:focus .sub-arrow,
.elementor-item.highlighted .sub-arrow,
.elementor-item.elementor-item-active .sub-arrow {
    color: inherit !important;
    fill: currentColor !important;
    opacity: 1 !important;
}

/* Forza la freccia SVG a usare fill ereditato dal colore del testo */
.sub-arrow svg path {
    fill: currentColor;
}

/* Quando il tema usa pointer-background (color:white sull'hover),
   la freccia deve restare nel colore originale del menu */
.e--pointer-background .elementor-item:hover .sub-arrow,
.e--pointer-background .elementor-item:focus .sub-arrow,
.e--pointer-background .elementor-item.highlighted .sub-arrow {
    color: var(--wpat-arrow-color, rgba(0,0,0,0.6)) !important;
    fill: var(--wpat-arrow-color, rgba(0,0,0,0.6)) !important;
}

/* =========================================================
   Responsive: su mobile il dropdown si apre con click
   ========================================================= */
@media (max-width: 768px) {
    .wpat-lang-switcher:hover .wpat-dropdown {
        display: none; /* disabilita hover su mobile */
    }

    .wpat-lang-switcher.wpat-open .wpat-dropdown {
        display: block;
    }

    .wpat-dropdown {
        right: auto;
        left: 0;
    }
}
