/* =====================================================================================
 * ANI I18N — استایل سوییچر زبان
 * =====================================================================================
 * File    : css/ani-i18n.css
 * Date    : 1405/07/27
 * Author  : Dr. Ehsan Shirsan (Ani Holding)
 * Author  : Aniyar (AI Architect)
 * ===================================================================================== */

/* ═══════════════════════════════════════════════════════════════════
 *  🎛️ سوییچر زبان — پایین-چپ صفحه (دور از دکمه‌های اصلی)
 * ═══════════════════════════════════════════════════════════════════
 *  روی همه صفحات نمایش داده می‌شود تا کاربر هر جا بتواند زبان را عوض کند.
 *  در PWA/موبایل هم کار می‌کند.
 * ═══════════════════════════════════════════════════════════════════ */
.ani-lang-switcher {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: calc(16px + env(safe-area-inset-left, 0px));
    z-index: 99998;

    display: flex;
    gap: 3px;
    padding: 4px;
    border-radius: 14px;

    background: rgba(17, 24, 39, .82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .32);
    border: 1px solid rgba(255, 255, 255, .1);
}

.ani-lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;

    min-width: 46px;
    height: 34px;
    padding: 0 9px;

    border: none;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, .7);

    font-family: inherit;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .5px;

    cursor: pointer;
    transition: background .15s, color .15s, transform .12s;
    -webkit-tap-highlight-color: transparent;
}

.ani-lang-btn:hover {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.ani-lang-btn:active {
    transform: scale(.94);
}

.ani-lang-btn.active {
    background: #2D7A5F;
    color: #fff;
    box-shadow: 0 2px 10px rgba(45, 122, 95, .5);
}

.ani-lang-flag {
    font-size: .82rem;
    line-height: 1;
}

.ani-lang-code {
    font-size: .62rem;
    opacity: .9;
}

/* روی صفحه‌های کوچک فقط پرچم */
@media (max-width: 360px) {
    .ani-lang-code { display: none; }
    .ani-lang-btn { min-width: 38px; padding: 0 7px; }
}

/* اگر صفحه نوار پایین دارد (bottom-nav)، سوییچر بالاتر بیاید */
body:has(.bottom-nav) .ani-lang-switcher {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}

/* ─── چاپ: مخفی ─── */
@media print {
    .ani-lang-switcher { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
 *  🌐 پشتیبانی از LTR برای انگلیسی
 * ═══════════════════════════════════════════════════════════════════
 *  با تغییر dir روی <html>، مرورگر خودش چیدمان را آینه می‌کند.
 *  فقط چند مورد که باید دستی اصلاح شوند:
 * ═══════════════════════════════════════════════════════════════════ */

html[dir="ltr"] body {
    text-align: left;
}

/* اعداد و کدها همیشه LTR */
html[dir="ltr"] .ani-mono,
html[dir="ltr"] pre,
html[dir="ltr"] code {
    direction: ltr;
    text-align: left;
}

/* آیکون‌های جهت‌دار در LTR برعکس شوند */
html[dir="ltr"] .ani-flip-rtl {
    transform: scaleX(-1);
}

/* در RTL فرم‌ها راست‌چین، در LTR چپ‌چین */
html[dir="ltr"] input,
html[dir="ltr"] textarea,
html[dir="ltr"] select {
    text-align: left;
}

/* ═══════════════════════════════════════════════════════════════════
 *  🔤 فونت برای هر زبان
 * ═══════════════════════════════════════════════════════════════════
 *  Vazirmatn فارسی و عربی را پوشش می‌دهد.
 *  برای انگلیسی هم خوانا است.
 * ═══════════════════════════════════════════════════════════════════ */
html[lang="ar"] body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

html[lang="en"] body {
    font-family: 'Vazirmatn', 'Segoe UI', -apple-system, Roboto, sans-serif;
    letter-spacing: .1px;
}

/* ═══════════════════════════════════════════════════════════════════
 *  🌙 سازگاری با تم تاریک (سوییچر خودش تیره است، پس مشکلی ندارد)
 * ═══════════════════════════════════════════════════════════════════ */
@media (prefers-color-scheme: light) {
    .ani-lang-switcher {
        background: rgba(17, 24, 39, .9);
    }
}

/* ═══════════════════════════════════════════════════════════════════
 *  🔤 فونت برای اردو و پشتو (۱۴۰۵/۰۷/۲۷)
 * ═══════════════════════════════════════════════════════════════════
 *  Vazirmatn اردو و پشتو را هم پوشش می‌دهد (هر دو خط عربی-فارسی)
 * ═══════════════════════════════════════════════════════════════════ */
html[lang="ur"] body,
html[lang="ps"] body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

/* اعداد اردو/پشتو */
html[lang="ur"] .ani-num,
html[lang="ps"] .ani-num {
    font-variant-numeric: normal;
}
/* ===== ANI mobile fix: language switcher always visible above bottom nav ===== */
@media (max-width: 900px) {
  .ani-lang-switcher, #aniLangSwitcher {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    max-width: calc(100vw - 24px);
    bottom: calc(86px + env(safe-area-inset-bottom, 0px)) !important;
    left: 50% !important; transform: translateX(-50%) !important;
    z-index: 100001 !important;
    -webkit-overflow-scrolling: touch;
  }
  body:has(.bottom-nav) .ani-lang-switcher,
  body:has(.ani-bottom-nav) .ani-lang-switcher,
  body:has(#aniBottomNav) .ani-lang-switcher,
  body.has-bottom-nav .ani-lang-switcher {
    bottom: calc(86px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .ani-lang-btn { flex: 0 0 auto !important; min-width: 44px !important; }
}
@media (max-width: 380px) { .ani-lang-btn { min-width: 40px !important; padding: 0 6px !important; } }

/* ═══════════════════════════════════════════════════════════════
 *  🌐 کمبوی کوچک زبان در نوار بالا (جایگزین نوار بزرگ)
 * ═══════════════════════════════════════════════════════════════ */
#aniLangSwitcher.ani-lang-combo {
    position: fixed !important;
    top: 8px !important;
    bottom: auto !important;
    left: 50% !important; transform: translateX(-50%) !important;
    z-index: 100002;
    display: flex !important;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 3px 9px;
    border-radius: 10px;
    background: rgba(17, 24, 39, .88);
    border: 1px solid rgba(255, 255, 255, .14);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: none !important;
    overflow: visible !important;
    flex-wrap: nowrap !important;
}
#aniLangSwitcher .ani-lang-globe { font-size: .82rem; line-height: 1; }
#aniLangSwitcher.ani-lang-combo select {
    background: transparent;
    border: 0;
    outline: none;
    color: #eaf4ef;
    font-family: inherit;
    font-size: .72rem;
    font-weight: 800;
    cursor: pointer;
    max-width: 118px;
    padding: 2px 2px;
    direction: ltr;
}
#aniLangSwitcher.ani-lang-combo select option { background: #111827; color: #eaf4ef; }
@media (max-width: 900px) {
    #aniLangSwitcher.ani-lang-combo { top: 6px !important; left: 50% !important; transform: translateX(-50%) !important; height: 28px; padding: 2px 7px; }
    #aniLangSwitcher.ani-lang-combo select { max-width: 96px; font-size: .68rem; }
}

/* ═══════════════════════════════════════════════════════════════
 *  🌐 اختصار دو حرفی زبان‌ها — همه هدرها
 * ═══════════════════════════════════════════════════════════════ */
#aniLangSwitcher.ani-lang-chips {
    position: fixed !important;
    top: 8px !important;
    bottom: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    display: flex !important;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 12px;
    background: rgba(17, 24, 39, .9);
    border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .32);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100002;
    max-width: calc(100vw - 16px);
    overflow-x: auto;
    flex-wrap: nowrap !important;
    scrollbar-width: none;
}
#aniLangSwitcher.ani-lang-chips::-webkit-scrollbar { display: none; }
#aniLangSwitcher.ani-lang-chips .ani-lang-btn {
    flex: 0 0 auto;
    min-width: 30px;
    height: 24px;
    padding: 0 6px;
    border-radius: 7px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    color: #cfe9dc;
    font-size: .6rem;
    font-weight: 900;
    letter-spacing: .6px;
    cursor: pointer;
    transition: .15s;
}
#aniLangSwitcher.ani-lang-chips .ani-lang-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
#aniLangSwitcher.ani-lang-chips .ani-lang-btn.active {
    background: linear-gradient(135deg, #3ddc97, #0f9d6a);
    color: #04231a;
    border-color: transparent;
}
@media (max-width: 640px) {
    #aniLangSwitcher.ani-lang-chips { top: 6px !important; padding: 3px 5px; }
    #aniLangSwitcher.ani-lang-chips .ani-lang-btn { min-width: 26px; height: 22px; font-size: .55rem; padding: 0 5px; }
}


/* ═══════════════════════════════════════════════════════════════
 *  🌐 کمبوی زبان در هدر — یک دکمه + منوی بازشو
 * ═══════════════════════════════════════════════════════════════ */
#aniLangSwitcher.ani-lang-combo2 {
    position: fixed !important;
    top: 8px !important;
    bottom: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 100002;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    max-width: none !important;
    overflow: visible !important;
}
#aniLangSwitcher .ani-lang-current {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 10px;
    border-radius: 10px;
    background: rgba(17, 24, 39, .92);
    border: 1px solid rgba(255, 255, 255, .16);
    color: #eaf7f1;
    font-family: inherit;
    font-size: .64rem;
    font-weight: 900;
    letter-spacing: .5px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
#aniLangSwitcher .ani-lang-current:hover { border-color: rgba(61, 220, 151, .45); }
#aniLangSwitcher .ani-lang-globe { font-size: .8rem; }
#aniLangSwitcher .ani-lang-caret { font-size: .55rem; color: #9db8ad; }
#aniLangSwitcher .ani-lang-menu {
    position: absolute;
    top: 36px;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    min-width: 190px;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border-radius: 13px;
    background: #0b1a20;
    border: 1px solid rgba(255, 255, 255, .14);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
    display: none;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
}
#aniLangSwitcher.open .ani-lang-menu { display: flex; }
#aniLangSwitcher .ani-lang-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 9px;
    border: 0;
    background: transparent;
    color: #cfe9dc;
    font-family: inherit;
    font-size: .72rem;
    cursor: pointer;
    text-align: right;
}
#aniLangSwitcher .ani-lang-item:hover { background: rgba(255, 255, 255, .07); }
#aniLangSwitcher .ani-lang-item b {
    min-width: 28px;
    font-size: .58rem;
    font-weight: 900;
    color: #9db8ad;
    direction: ltr;
}
#aniLangSwitcher .ani-lang-item.active { background: rgba(61, 220, 151, .16); }
#aniLangSwitcher .ani-lang-item.active b, #aniLangSwitcher .ani-lang-item.active span { color: #9ff0cb; }
@media (max-width: 640px) {
    #aniLangSwitcher.ani-lang-combo2 { top: 6px !important; }
    #aniLangSwitcher .ani-lang-current { height: 27px; padding: 0 8px; font-size: .6rem; }
    #aniLangSwitcher .ani-lang-menu { min-width: 170px; }
}


/* ═══ ویجت کارت‌خوان / NFC (IRID) ═══ */
#aniCardWidget{position:fixed;bottom:calc(var(--bottom-nav-height,72px) + 14px);left:12px;z-index:9995;
  display:flex;flex-direction:column;gap:6px;align-items:flex-start;font-family:'Vazirmatn',Tahoma,sans-serif}
#aniCardStatus{font-size:.58rem;font-weight:800;color:#cfe9dc;background:rgba(13,27,42,.92);
  border:1px solid rgba(255,255,255,.16);border-radius:999px;padding:5px 10px;backdrop-filter:blur(8px);
  direction:ltr;max-width:70vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#aniCardStatus.ok{color:#9ff0cb;border-color:rgba(61,220,151,.5)}
#aniCardStatus.warn{color:#ffe9a8;border-color:rgba(244,196,48,.5)}
#aniCardLoginBtn{font-size:.6rem;font-weight:900;padding:8px 12px;border-radius:10px;border:1px solid rgba(61,220,151,.45);
  background:rgba(15,61,46,.95);color:#c9f7e6;cursor:pointer}
#aniCardInput{width:min(78vw,320px);padding:9px 12px;border-radius:11px;border:1px solid rgba(61,220,151,.5);
  background:#0b1a20;color:#eaf7f1;font-size:.72rem;direction:ltr;text-align:left;outline:none}
#aniCardMsg{font-size:.56rem;color:#9db8ad;max-width:70vw}
@media(min-width:900px){#aniCardWidget{bottom:18px;left:16px}}
