/* ═══════════════════════════════════════════════════════════════
   NAT-LANG-ATTACH — چسباندن کشویی زبان به هدر
   ═══════════════════════════════════════════════════════════════ */

/* ─── پرچم ایران — ۳ نوار ─── */
.lang-switcher__flag.fa-flag {
    display: inline-block !important;
    width: 20px !important;
    height: 13px !important;
    border-radius: 2px !important;
    overflow: hidden !important;
    background: linear-gradient(to bottom,#239f40 0%,#239f40 33.333%,#ffffff 33.333%,#ffffff 66.666%,#da0000 66.666%,#da0000 100%) !important;
    box-shadow: 0 0 0 1px rgba(0,0,0,.12) !important;
    font-size: 0 !important;
    color: transparent !important;
    text-indent: -9999px !important;
    flex-shrink: 0 !important;
}
.lang-switcher__flag.fa-flag::before,
.lang-switcher__flag.fa-flag::after {
    display: none !important;
}

/* ─── موبایل — dropdown چسبیده به هدر ─── */
@media (max-width: 768px) {

    /* header باید relative باشد تا dropdown به آن بچسبد */
    html body .header {
        position: sticky !important;
        top: 0 !important;
        z-index: 99999 !important;
        overflow: visible !important;
    }
    html body .header .container,
    html body .header .header__inner {
        overflow: visible !important;
    }

    /* lang-switcher باید relative باشد */
    html body .lang-switcher {
        position: relative !important;
        display: inline-flex !important;
        align-items: center !important;
        overflow: visible !important;
    }

    /* trigger کوچک‌تر */
    html body .lang-switcher__trigger {
        padding: 6px 8px !important;
        gap: 4px !important;
        font-size: .72rem !important;
        height: 34px !important;
        display: inline-flex !important;
        align-items: center !important;
    }
    html body .lang-switcher__trigger svg.globe {
        width: 12px !important;
        height: 12px !important;
    }
    html body .lang-switcher__trigger svg.chev {
        width: 9px !important;
        height: 9px !important;
    }
    html body .lang-switcher__trigger #langLabel {
        max-width: 42px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* ═══ dropdown — absolute، چسبیده به هدر ═══ */
    html body .lang-switcher__dropdown {
        position: absolute !important;
        top: calc(100% + 6px) !important;
        left: 0 !important;
        right: auto !important;
        width: 200px !important;
        max-width: 200px !important;
        min-width: 0 !important;
        padding: 6px !important;
        border-radius: 12px !important;
        background: #fbf9f3 !important;
        border: 1px solid rgba(15,54,65,.14) !important;
        box-shadow: 0 16px 40px rgba(15,31,56,.35) !important;
        z-index: 999999 !important;
        transform: translateY(-4px) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        /* مطمئن شو از viewport بیرون نزند */
        right: auto !important;
    }

    /* اگر نزدیک لبه راست بود، به راست بچسبد */
    html body .lang-switcher.is-open .lang-switcher__dropdown {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
        pointer-events: auto !important;
    }

    /* دکمه‌های زبان */
    html body .lang-switcher__dropdown button {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
        padding: 9px 10px !important;
        border-radius: 8px !important;
        font-size: .82rem !important;
        font-weight: 700 !important;
        color: #1a1e22 !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
        text-align: right !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        line-height: 1 !important;
        min-height: 36px !important;
        font-family: inherit !important;
    }
    html body .lang-switcher__dropdown button:hover,
    html body .lang-switcher__dropdown button:active {
        background: rgba(42,110,128,.10) !important;
    }
    html body .lang-switcher__dropdown button.is-active {
        background: linear-gradient(135deg, #0F3641, #2A6E80) !important;
        color: #fbf9f3 !important;
    }
    html body .lang-switcher__dropdown button .lang-switcher__flag {
        flex-shrink: 0 !important;
        font-size: 1.05rem !important;
        width: auto !important;
        height: auto !important;
        background: none !important;
        box-shadow: none !important;
        text-indent: 0 !important;
        line-height: 1 !important;
    }
    html body .lang-switcher__dropdown button .lang-switcher__flag.fa-flag {
        width: 20px !important;
        height: 13px !important;
        border-radius: 2px !important;
        background: linear-gradient(to bottom,#239f40 0%,#239f40 33.333%,#ffffff 33.333%,#ffffff 66.666%,#da0000 66.666%,#da0000 100%) !important;
        box-shadow: 0 0 0 1px rgba(0,0,0,.12) !important;
    }

    /* ═══ حذف overlay که قبلاً بود (باعث تداخل می‌شد) ═══ */
    html body .lang-switcher.is-open::before,
    html body .lang-switcher.is-open::after {
        display: none !important;
        content: none !important;
    }

    /* اطمینان که header__actions اجازه overflow بدهد */
    html body .header__actions {
        overflow: visible !important;
        position: relative !important;
    }

    /* جستجو و بقیه دکمه‌های هدر — z-index پایین‌تر از dropdown */
    html body .header__search,
    html body .header__entry,
    html body .header__logout {
        position: relative !important;
        z-index: 1 !important;
    }

    /* lang-switcher بالاتر از بقیه هدر */
    html body .lang-switcher {
        z-index: 100 !important;
    }
}

/* ─── موبایل کوچک ─── */
@media (max-width: 480px) {
    html body .lang-switcher__dropdown {
        width: 190px !important;
        max-width: 190px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   دسکتاپ — رفع تداخل احتمالی
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
    html body .lang-switcher__dropdown {
        position: absolute !important;
        top: calc(100% + 6px) !important;
        left: 0 !important;
        width: auto !important;
        min-width: 170px !important;
        max-width: none !important;
    }
}