/**
 * Sunya Theme - Language Switcher CSS
 * Stili per il selettore lingua WPML
 *
 * @package Sunya
 * @since 1.1.0
 */


/* ==========================================================================
   BASE
   ========================================================================== */

.sunya-lang {
    position: relative;
    display: inline-flex;
    align-items: center;
    font-size: 0.8125rem;
    line-height: 1.4;
}


/* ==========================================================================
   TRIGGER (pulsante lingua corrente — stile dropdown)
   ========================================================================== */

.sunya-lang__current {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.sunya-lang__current:hover,
.sunya-lang__current:focus-visible {
    background-color: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.1);
}

.sunya-lang__current:focus-visible {
    outline: 2px solid var(--sunya-color-primary, #2563eb);
    outline-offset: 2px;
}


/* ==========================================================================
   CHEVRON
   ========================================================================== */

.sunya-lang__chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.sunya-lang__current[aria-expanded="true"] .sunya-lang__chevron {
    transform: rotate(180deg);
}


/* ==========================================================================
   DROPDOWN PANEL
   ========================================================================== */

.sunya-lang__dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1000;
    min-width: auto;
    margin: 4px 0 0;
    padding: 4px 0;
    list-style: none;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
}

.sunya-lang__current[aria-expanded="true"] + .sunya-lang__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Allineamento dropdown a sinistra per topbar-left */
.sunya-lang--topbar .sunya-topbar__left .sunya-lang__dropdown {
    left: 0;
    right: auto;
}


/* ==========================================================================
   ITEM & LINK
   ========================================================================== */

.sunya-lang__item {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sunya-lang__link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    color: #374151;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sunya-lang__link:hover,
.sunya-lang__link:focus-visible {
    background-color: rgba(0, 0, 0, 0.04);
    color: var(--sunya-color-primary, #2563eb);
    text-decoration: none;
}

.sunya-lang__item--active .sunya-lang__link {
    font-weight: 600;
    color: var(--sunya-color-primary, #2563eb);
}


/* ==========================================================================
   FLAG & TEXT
   ========================================================================== */

.sunya-lang__flag {
    flex-shrink: 0;
    display: inline-block;
    width: 18px;
    height: 12px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.sunya-lang__name {
    flex-shrink: 0;
}

.sunya-lang__code {
    flex-shrink: 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}


/* ==========================================================================
   STILE: FLAGS (solo bandiere inline)
   ========================================================================== */

.sunya-lang--flags .sunya-lang__list {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.sunya-lang--flags .sunya-lang__link {
    display: block;
    padding: 2px;
    border-radius: 3px;
    line-height: 0;
}

.sunya-lang--flags .sunya-lang__link:hover,
.sunya-lang--flags .sunya-lang__link:focus-visible {
    background-color: rgba(0, 0, 0, 0.06);
}

.sunya-lang--flags .sunya-lang__flag {
    width: 22px;
    height: 15px;
}

.sunya-lang--flags .sunya-lang__item--active .sunya-lang__link {
    opacity: 1;
}

.sunya-lang--flags .sunya-lang__item:not(.sunya-lang__item--active) .sunya-lang__link {
    opacity: 0.6;
}

.sunya-lang--flags .sunya-lang__item:not(.sunya-lang__item--active) .sunya-lang__link:hover {
    opacity: 1;
}


/* ==========================================================================
   STILE: LIST / INLINE
   ========================================================================== */

.sunya-lang__list--inline {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.sunya-lang--list .sunya-lang__link,
.sunya-lang__list--inline .sunya-lang__link {
    padding: 4px 8px;
    border-radius: 4px;
}

.sunya-lang__list--inline .sunya-lang__item--active .sunya-lang__link {
    font-weight: 600;
    color: var(--sunya-color-primary, #2563eb);
}


/* ==========================================================================
   CONTESTO: TOPBAR
   ========================================================================== */

.sunya-lang--topbar {
    font-size: 0.75rem;
}

.sunya-lang--topbar .sunya-lang__current {
    padding: 2px 6px;
    color: inherit;
}

.sunya-lang--topbar .sunya-lang__current:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.sunya-lang--topbar .sunya-lang__dropdown {
    color: #374151;
}


/* ==========================================================================
   CONTESTO: HEADER
   ========================================================================== */

.sunya-lang--header {
    font-size: 0.8125rem;
}


/* ==========================================================================
   CONTESTO: MOBILE (dentro il menu mobile)
   ========================================================================== */

.sunya-lang--mobile {
    display: none;
    width: 100%;
    padding: 16px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 16px;
    font-size: 0.875rem;
}

.sunya-lang--mobile .sunya-lang__list,
.sunya-lang--mobile .sunya-lang__list--inline {
    flex-wrap: wrap;
    gap: 4px;
}

.sunya-lang--mobile .sunya-lang__link {
    padding: 8px 12px;
}

/* Dropdown mobile: inline, non posizionamento assoluto */
.sunya-lang--mobile .sunya-lang__dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: transparent;
    min-width: 0;
    padding: 0;
    margin: 8px 0 0;
}

.sunya-lang--mobile .sunya-lang__dropdown .sunya-lang__link {
    color: inherit;
}


/* ==========================================================================
   CONTESTO: MENU PRINCIPALE (ultima voce)
   ========================================================================== */

.sunya-lang-menu-item {
    position: relative;
    display: flex;
    align-items: center;
}

.sunya-lang--menu {
    margin-left: 0;
}

.sunya-lang--menu .sunya-lang__current {
    padding: 0.5rem 0.625rem;
    color: inherit;
    font-size: inherit;
}

.sunya-lang--menu .sunya-lang__dropdown {
    right: 0;
    left: auto;
}


/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 991px) {

    /* Nascondi switcher desktop nel topbar, header e menu su mobile */
    .sunya-lang--topbar,
    .sunya-lang--header,
    .sunya-lang-menu-item {
        display: none;
    }

    /* Mostra versione mobile dentro il menu */
    .sunya-nav--open .sunya-lang--mobile,
    .sunya-nav__menu-wrapper.sunya-nav--open .sunya-lang--mobile {
        display: block;
    }
}

@media (min-width: 992px) {

    /* Nascondi sempre la versione mobile su desktop */
    .sunya-lang--mobile {
        display: none !important;
    }
}
