.language-switcher {
    position: relative;
    min-width: 116px;
}

.language-switcher__trigger {
    width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: var(--ems-neutral-0);
    border-radius: 10px;
    padding: 0.44rem 0.66rem;
    cursor: pointer;
    color: var(--ems-neutral-700);
    font-size: 0.87rem;
    line-height: 1;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.language-switcher__trigger.dropdown-toggle::after {
    display: none;
}

.language-switcher__trigger:hover {
    border-color: rgba(37, 99, 235, 0.42);
    background: #f8fbff;
}

.language-switcher__trigger:focus-visible {
    outline: none;
    border-color: rgba(37, 99, 235, 0.7);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.language-switcher__label {
    color: var(--ems-neutral-500);
    font-weight: 600;
}

.language-switcher__icon {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--ems-primary-700);
}

.language-switcher__value {
    font-weight: 700;
    letter-spacing: 0.3px;
}

.language-switcher__caret {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--ems-neutral-500);
    transition: transform 0.18s ease;
}

.language-switcher__menu {
    display: none;
    position: absolute;
    right: 0;
    left: auto;
    top: calc(100% + 0.4rem);
    min-width: 210px;
    max-width: min(280px, calc(100vw - 24px));
    max-height: min(22rem, calc(100vh - 6rem));
    background: var(--ems-neutral-0);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.14);
    padding: 0.35rem;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1200;
}

.language-switcher.show {
    z-index: 1250;
}

.language-switcher__menu.dropdown-menu[data-bs-popper] {
    inset: calc(100% + 0.4rem) 0 auto auto !important;
    right: 0 !important;
    left: auto !important;
    margin-top: 0 !important;
    transform: none !important;
}

.language-switcher__menu.show {
    display: block;
}

.language-switcher__trigger[aria-expanded="true"] .language-switcher__caret {
    transform: rotate(180deg);
}

.language-switcher__form {
    margin: 0;
}

.language-switcher__option {
    width: 100%;
    border: 0;
    background: transparent;
    border-radius: 9px;
    padding: 0.5rem 0.62rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #1e293b;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
}

.language-switcher__option:hover {
    background: var(--ems-neutral-100);
}

.language-switcher__option.dropdown-item:active {
    color: #1e293b;
    background: var(--ems-neutral-100);
}

.language-switcher__option:focus-visible {
    outline: none;
    background: var(--ems-neutral-200);
}

.language-switcher__option-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 24px;
    border-radius: 999px;
    background: var(--ems-primary-50);
    color: var(--ems-primary-700);
    font-weight: 700;
    font-size: 0.72rem;
}

.language-switcher__option-label {
    flex: 1;
    white-space: nowrap;
}

.language-switcher__option-check {
    opacity: 0;
    color: var(--ems-success-strong);
    font-weight: 700;
}

.language-switcher__option.is-active {
    background: #ecfeff;
}

.language-switcher__option.is-active .language-switcher__option-check {
    opacity: 1;
}

.language-switcher--mobile {
    width: 100%;
    min-width: 0;
}

.language-switcher--mobile .language-switcher__trigger {
    width: 100%;
    min-height: 44px;
    border-radius: 10px;
}

.language-switcher--mobile .language-switcher__menu {
    left: 0;
    right: auto;
    width: 100%;
    min-width: 0;
}

.language-switcher--sidebar {
    width: 100%;
    min-width: 0;
}

.language-switcher--sidebar .language-switcher__trigger {
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
    padding: 0.62rem 0.72rem;
}

/* Menyu düymənin ÜSTÜNDƏ açılır — sürüşən sidebar-ın dibi onu kəsirdi
   («altda dil itir, kəsilir»). ⚠️ Bootstrap açılanda menyuya
   `data-bs-popper="static"` yazır və `.dropdown-menu[data-bs-popper]
   { top: 100% }` ilə mövqeyi geri alır; ona görə atributlu variant da
   burada, daha yüksək spesifiklikdə verilir. */
.language-switcher--sidebar .language-switcher__menu,
.language-switcher--sidebar .language-switcher__menu[data-bs-popper] {
    /* `!important` — çünki yuxarıdakı ümumi `[data-bs-popper]` qaydası
       Popper-i məğlub etmək üçün `inset … !important` işlədir; sidebar
       variantı onu ancaq eyni gücdə, daha sonra gələn qayda ilə əvəz edə bilər. */
    inset: auto auto calc(100% + 0.4rem) 0 !important;
    width: 100%;
    min-width: 0;
    margin-top: 0 !important;
    margin-bottom: 0;
}

.language-switcher--floating {
    min-width: 0;
}

.language-switcher--floating .language-switcher__trigger {
    gap: 0.45rem;
    min-width: 0;
    padding: 0.55rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.12);
}

.language-switcher--floating .language-switcher__value {
    min-width: 1.8rem;
    text-align: center;
}

.language-switcher--floating .language-switcher__menu {
    min-width: 220px;
}

@media (max-width: 640px) {
    .language-switcher--floating .language-switcher__menu {
        right: 0;
        left: auto;
        min-width: 0;
        width: min(280px, calc(100vw - 32px));
    }

    .language-switcher--floating .language-switcher__menu.dropdown-menu[data-bs-popper] {
        width: min(280px, calc(100vw - 32px)) !important;
        max-width: min(280px, calc(100vw - 32px));
    }
}
