/*
 * lang.css - everything about languages. Loaded LAST so it can override the other files.
 *   1) the language menu (top bar + login page)
 *   2) fonts for Arabic, Urdu and Bengali
 *   3) right-to-left layout for Arabic / Urdu (<html dir="rtl">): the page is mirrored
 * The other CSS files are written for left-to-right; this file only flips what needs flipping.
 */

/* ---------- 1) language menu ---------- */
.lang-form { display: inline-flex; align-items: center; gap: 4px; margin: 0; padding: 0 4px 0 10px; height: 36px; border-radius: 999px; background: var(--seg-bg); color: var(--muted); }
.lang-form .lang-ic { display: inline-flex; }
.lang-form select {
  border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  padding: 4px 2px; cursor: pointer; max-width: 120px;
}
.lang-form select:focus { outline: 2px solid var(--primary); border-radius: 8px; }
.lang-form option { background: var(--surface-solid); color: var(--text); }
/* login page: menu in the top-left corner (the theme button is top-right) */
.login-lang { position: fixed; top: 20px; left: 16px; z-index: 5; }
/* very small phones: keep the top bar tidy */
@media (max-width: 420px) { .topbar .lang-form .lang-ic { display: none; } .topbar .lang-form { padding: 0 4px; } }

/* ---------- 2) fonts ---------- */
/* Windows / Android / iPhone already have fonts for these scripts; the list just prefers good ones. */
html:lang(ar) body, html:lang(ur) body {
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Naskh Arabic", "Geeza Pro", system-ui, sans-serif;
}
html:lang(bn) body {
  font-family: "Nirmala UI", "Noto Sans Bengali", "Hind Siliguri", "Bangla MN", "Kohinoor Bangla", system-ui, sans-serif;
}
/* Arabic letters are joined: extra letter spacing breaks them, so switch it off */
html:lang(ar) .pill, html:lang(ur) .pill, html:lang(ar) .nm-btn, html:lang(ur) .nm-btn,
html:lang(ar) .brand-2, html:lang(ur) .brand-2 { letter-spacing: 0; }

/* ---------- 3) right-to-left (Arabic / Urdu) ---------- */
/* page room for the floating side panel is now on the right */
@media (min-width: 821px) { [dir="rtl"] body.panel { padding-left: 0; padding-right: 96px; } }

/* side panel on the right */
[dir="rtl"] .rail { left: auto; right: 12px; }
[dir="rtl"] .rail-chev { right: auto; left: -11px; transform: rotate(180deg); }      /* arrow points into the page */
[dir="rtl"] .rail.expanded .rail-chev { transform: none; }
[dir="rtl"] .rail-item.on::before { left: auto; right: -8px; }
[dir="rtl"] .rail-item .badge { left: auto; right: calc(var(--tile) - 14px); }
[dir="rtl"] .rail-item .live-dot { left: auto; right: calc(var(--tile) - 11px); }
[dir="rtl"] .tip { left: auto; right: calc(100% + 14px); transform: translateY(-50%) translateX(4px); }
[dir="rtl"] .rail:not(.expanded) .rail-item:hover .tip { transform: translateY(-50%); }
[dir="rtl"] .avatar .online { right: auto; left: -1px; }
@media (max-width: 820px) {
  /* phone: the drawer slides in from the right */
  [dir="rtl"] .rail { left: auto; right: 0; transform: translateX(108%); border-radius: 30px 0 0 30px; }
  [dir="rtl"] .rail.open { transform: none; }
}

/* cards, stat boxes, pills */
[dir="rtl"] .stat { text-align: right; }
[dir="rtl"] .stat .live-dot { right: auto; left: 16px; }
[dir="rtl"] .pill-off { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .test-res { margin-left: 0; margin-right: 6px; }

/* tables and pager */
[dir="rtl"] .tbl th, [dir="rtl"] .tbl td { text-align: right; }
[dir="rtl"] .tbl th[data-k]::after { margin-left: 0; margin-right: 8px; }
[dir="rtl"] .ib { margin-right: 0; margin-left: 4px; }
[dir="rtl"] .pager button { margin-left: 0; margin-right: -1px; }
[dir="rtl"] .pager button:first-child { border-radius: 0 10px 10px 0; }
[dir="rtl"] .pager button:last-child { border-radius: 10px 0 0 10px; }
[dir="rtl"] .pager button:only-child { border-radius: 10px; }

/* pop-up window */
[dir="rtl"] .modal-x { right: auto; left: 12px; }
[dir="rtl"] .owner-links { text-align: right; }

/* login page: theme button and language menu swap corners, eye button on the left */
[dir="rtl"] .nm-theme { right: auto; left: 16px; }
[dir="rtl"] .login-lang { left: auto; right: 16px; }
[dir="rtl"] .nm-card .alert { text-align: right; }
[dir="rtl"] .nm-input { padding: 15px 20px 15px 46px; }
[dir="rtl"] .nm-eye { right: auto; left: 12px; }
[dir="rtl"] .lang-form { padding: 0 10px 0 4px; }

/* voucher names, MAC addresses, numbers and comments from the router stay left-to-right */
[dir="rtl"] .tbl td.copy, [dir="rtl"] #tbl td:nth-child(4), [dir="rtl"] #tbl td:nth-child(5),
[dir="rtl"] #tbl td:nth-child(6), [dir="rtl"] #tbl td:nth-child(7) { direction: ltr; unicode-bidi: isolate; }
/* profile and comment: direction follows their own text ("1-Day" stays "1-Day", Arabic stays Arabic) */
[dir="rtl"] #tbl td:nth-child(3), [dir="rtl"] #tbl td:nth-child(8) { unicode-bidi: plaintext; }
