/* ==========================================================================
   Language Switcher — cycling flag button
   Mirrors the Windows installer control
   (installer-app/src/renderer/components/LanguageSwitcher.{tsx,css}):
   same zh -> ru -> en -> fa order, same wrap-around on click, same flag SVGs.
   Restyled for the site instead of the installer's absolute footer.
   Primary placement: top news banner, left of the close X (.news-banner).
   Fallback placement: site header (.site-header .header-content).
   ========================================================================== */

.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    /* Логический паддинг: на RTL-страницах (фарси) кнопка зеркалится, и
       физический padding-left отодвигал флаг от края. Отступ должен быть
       только со стороны подписи (начало строки), флаг — вплотную к краю. */
    padding: 0;
    padding-inline-start: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    cursor: pointer;
    overflow: hidden;
    font-family: inherit;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    flex: 0 0 auto;
}

.lang-switch:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(0, 217, 126, 0.55);
    transform: translateY(-1px);
}

.lang-switch:active {
    transform: translateY(0);
}

.lang-switch:focus-visible {
    outline: 2px solid var(--primary, #00D97E);
    outline-offset: 2px;
}

.lang-switch__label {
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    color: var(--text-secondary, #9CA3AF);
    white-space: nowrap;
    transition: color 0.2s ease;
}

.lang-switch:hover .lang-switch__label {
    color: var(--text-primary, #E5E7EB);
}

.lang-switch__flag {
    width: 44px;
    height: 100%;
    object-fit: cover;
    display: block;
    flex: 0 0 auto;
}

/* Farsi label needs a font that has Arabic-script glyphs */
.lang-switch__label:lang(fa) {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

/* --- Placement in the news banner ---------------------------------------- */

/* Banner children carry explicit flex order (track 1, dots 2, CTA 3, close 5);
   order 4 slots the switcher in directly to the left of the close X. */
.news-banner .lang-switch {
    order: 4;
    height: 30px;
}

/* --- Placement in the header (fallback, pages without the banner) -------- */

.site-header .lang-switch {
    margin-left: 0.75rem;
}

/* Mobile: header-content is a 3-column grid (mobile-fixes.css:66) — logo |
   auth | burger. The injected button had no grid cell of its own and broke
   that layout, and on phones it is redundant anyway: the language is chosen
   in the cabinet (Overview -> language row) or in the app settings. Removed
   from the header entirely; the news-banner placement is unaffected. */
@media (max-width: 768px) {
    .site-header .lang-switch {
        display: none !important;
    }

    .lang-switch__label {
        display: none;
    }

    .lang-switch {
        padding: 0;
    }

    .lang-switch__flag {
        width: auto;
        object-fit: contain;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lang-switch,
    .lang-switch__label {
        transition: none;
    }

    .lang-switch:hover {
        transform: none;
    }
}
