
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* ── Logo: flip image+text order in RTL ─────────────────────── */
html[dir="rtl"] a.logo {
    flex-direction: row-reverse;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Container ─────────────────────────────────────────────────────────── */
.language-toggle {
    display: flex;
    align-items: center;
}

/* ── Pill track ─────────────────────────────────────────────────────────── */
.lang-switch {
    position: relative;
    display: flex;
    align-items: center;
    width: 192px;
    height: 40px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 4px 14px rgba(0,0,0,0.12);
    transition: box-shadow 0.25s ease;
}

html:not([dir="rtl"]) .lang-switch {
    background: rgba(15, 23, 42, 0.07);
    border-color: rgba(15, 23, 42, 0.13);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.07);
}

.lang-switch:hover {
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 6px 20px rgba(0,0,0,0.18);
}

.lang-switch:focus-within {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.45),
                inset 0 1px 3px rgba(0,0,0,0.10);
}

/* ── Sliding thumb ──────────────────────────────────────────────────────── */
.lang-switch__thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 6px);
    height: calc(100% - 8px);
    border-radius: 999px;
    background: linear-gradient(135deg, #ffffff 0%, #ddeeff 100%);
    box-shadow: 0 2px 8px rgba(27, 60, 75, 0.22), 0 1px 3px rgba(0,0,0,0.12);
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.25s ease,
                box-shadow 0.25s ease;
    will-change: transform;
    pointer-events: none;
}

.lang-switch[data-active="ar"] .lang-switch__thumb {
    transform: translateX(calc(100% + 4px));
    background: linear-gradient(135deg, #e8fff4 0%, #c4f0dc 100%);
    box-shadow: 0 2px 10px rgba(39, 174, 96, 0.28), 0 1px 3px rgba(0,0,0,0.10);
}

/* ── Option buttons ─────────────────────────────────────────────────────── */
.lang-switch__option {
    flex: 1;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    background: none;
    border-radius: 999px;
    padding: 0 8px;
    height: 100%;
    cursor: pointer;
    transition: color 0.25s ease, transform 0.2s ease, opacity 0.25s ease;
    white-space: nowrap;
    user-select: none;
    overflow: hidden;
}

/* ── Flag ───────────────────────────────────────────────────────────────── */
.lang-switch__flag {
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

/* ── Text group ─────────────────────────────────────────────────────────── */
.lang-switch__label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
    gap: 1px;
}

/* Short code — always visible */
.lang-switch__code {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1;
}

/* Full language name — visible on wider screens */
.lang-switch__name {
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0.75;
    line-height: 1;
}

/* ── Inactive state ─────────────────────────────────────────────────────── */
.lang-switch__option {
    color: #1b3c4b;
}

html:not([dir="rtl"]) .lang-switch__option {
    color: rgba(15, 23, 42, 0.42);
}

/* ── Active state ───────────────────────────────────────────────────────── */
.lang-switch[data-active="en"] .lang-switch__option--en,
.lang-switch[data-active="ar"] .lang-switch__option--ar {
    color: #3D735C;
    transform: scale(1.04);
}

.lang-switch[data-active="en"] .lang-switch__option--en .lang-switch__flag,
.lang-switch[data-active="ar"] .lang-switch__option--ar .lang-switch__flag {
    transform: scale(1.12);
}

/* ── Hover on inactive ──────────────────────────────────────────────────── */
.lang-switch[data-active="en"] .lang-switch__option--ar:hover,
.lang-switch[data-active="ar"] .lang-switch__option--en:hover {
    color: rgba(255, 255, 255, 0.85);
    opacity: 1;
}

html:not([dir="rtl"]) .lang-switch[data-active="en"] .lang-switch__option--ar:hover,
html:not([dir="rtl"]) .lang-switch[data-active="ar"] .lang-switch__option--en:hover {
    color: rgba(15, 23, 42, 0.70);
}

/* Active button stays dark on hover */
.lang-switch[data-active="en"] .lang-switch__option--en:hover,
.lang-switch[data-active="ar"] .lang-switch__option--ar:hover {
    color: #1b3c4b;
}

/* ── Click ripple ───────────────────────────────────────────────────────── */
.lang-switch__option::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.lang-switch__option:active::after {
    opacity: 1;
}

.lang-switch__option:focus-visible {
    outline: none;
}

/* ─────────────────────────────────────────────────────────────────────────
   RESPONSIVE BREAKPOINTS
   ───────────────────────────────────────────────────────────────────────── */

/* Tablet: hide the full name, keep flag + code */
@media (max-width: 1024px) {
    .lang-switch {
        width: 148px;
        height: 38px;
    }

    .lang-switch__name {
        display: none;
    }

    .lang-switch__label {
        align-items: center;
    }

    .lang-switch__code {
        font-size: 0.75rem;
    }

    .lang-switch__flag {
        font-size: 1rem;
    }
}

/* Mobile nav open: compact pill — flag + code still visible */
@media (max-width: 768px) {
    .lang-switch {
        width: 128px;
        height: 36px;
        padding: 3px;
    }

    .lang-switch__thumb {
        top: 3px;
        left: 3px;
        width: calc(50% - 5px);
        height: calc(100% - 6px);
    }

    .lang-switch[data-active="ar"] .lang-switch__thumb {
        transform: translateX(calc(100% + 2px));
    }

    .lang-switch__option {
        gap: 4px;
        padding: 0 6px;
    }

    .lang-switch__flag {
        font-size: 0.95rem;
    }

    .lang-switch__code {
        font-size: 0.70rem;
    }
}

/* Very small screens: flag only */
@media (max-width: 400px) {
    .lang-switch {
        width: 88px;
        height: 34px;
        padding: 3px;
    }

    .lang-switch__thumb {
        width: calc(50% - 4px);
        height: calc(100% - 6px);
    }

    .lang-switch[data-active="ar"] .lang-switch__thumb {
        transform: translateX(calc(100% + 1px));
    }

    .lang-switch__label {
        display: none;
    }

    .lang-switch__flag {
        font-size: 1.2rem;
    }
}
