/**
 * Language Switcher - Componente de troca de idioma
 *
 * Uso: <x-front.language-switcher /> em qualquer local do template.
 * Se nao incluido no template, aparece como flutuante via .lang-switcher-float.
 */

/* ========== DROPDOWN BASE ========== */
.lang-switcher {
    position: relative;
    display: inline-block;
    font-family: var(--site-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

.lang-switcher__toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.5;
}
.lang-switcher__toggle:hover {
    border-color: rgba(0,0,0,0.3);
    background: rgba(0,0,0,0.04);
}

.lang-switcher__code {
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-size: 0.8rem;
    font-weight: 600;
}
.lang-switcher__item .lang-switcher__code {
    display: inline-block;
    min-width: 24px;
    text-align: center;
    font-size: 0.75rem;
    color: #666;
    background: #f0f0f0;
    border-radius: 3px;
    padding: 1px 4px;
}
.lang-switcher__item--active .lang-switcher__code {
    color: var(--site-primary, #4e73df);
    background: #e6f0ff;
}

.lang-switcher__arrow {
    font-size: 0.6em;
    margin-left: 2px;
    transition: transform 0.2s ease;
}
.lang-switcher.open .lang-switcher__arrow {
    transform: rotate(180deg);
}

/* ========== DROPDOWN MENU ========== */
.lang-switcher__menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 150px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.15s ease;
    z-index: 1050;
}
.lang-switcher.open .lang-switcher__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-switcher__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: #444;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.15s ease;
}
.lang-switcher__item:hover {
    background: #f5f5f5;
    color: #333;
    text-decoration: none;
}
.lang-switcher__item--active {
    background: #f0f7ff;
    color: var(--site-primary, #4e73df);
    font-weight: 600;
}
.lang-switcher__item--active:hover {
    background: #e6f0ff;
}

.lang-switcher__name {
    flex: 1;
}

.lang-switcher__check {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--site-primary, #4e73df);
}

/* ========== VARIANTE: DENTRO DE NAVBAR ========== */
.navbar .lang-switcher__toggle,
.nav .lang-switcher__toggle,
header .lang-switcher__toggle {
    border-color: rgba(255,255,255,0.25);
    color: inherit;
}
.navbar .lang-switcher__toggle:hover,
.nav .lang-switcher__toggle:hover,
header .lang-switcher__toggle:hover {
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.1);
}

/* Navbar claro */
.navbar-light .lang-switcher__toggle {
    border-color: rgba(0,0,0,0.15);
    color: rgba(0,0,0,0.7);
}
.navbar-light .lang-switcher__toggle:hover {
    border-color: rgba(0,0,0,0.3);
    background: rgba(0,0,0,0.04);
}

/* ========== VARIANTE: FLUTUANTE (fallback no layout) ========== */
.lang-switcher-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1040;
}
.lang-switcher-float .lang-switcher__toggle {
    background: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 50px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    font-weight: 600;
}
.lang-switcher-float .lang-switcher__toggle:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transform: translateY(-1px);
    background: #fff;
}
.lang-switcher-float .lang-switcher__menu {
    top: auto;
    bottom: calc(100% + 8px);
    border-radius: 12px;
}

/* Ajuste quando cookie consent esta visivel */
#cookie-consent[style*="display: block"] ~ .lang-switcher-float {
    bottom: 80px;
}

@media (max-width: 576px) {
    .lang-switcher-float {
        bottom: 15px;
        right: 15px;
    }
    .lang-switcher-float .lang-switcher__toggle {
        padding: 7px 12px;
        font-size: 0.8rem;
    }
}
