/*
  Arabic right-to-left layout (founder 2026-11-07).

  i18n.js sets <html dir="rtl"> ONLY when Arabic is selected, and every rule here is scoped to
  html[dir="rtl"] — the other eleven languages never match a single selector in this file.

  Two concerns, kept separate:
  1. LAYOUT mirrors: the sidebar moves to the right, start/end alignment and edge accents swap.
  2. DATA never mirrors: numbers, prices, percentages, dates, tickers and charts keep their own
     left-to-right order. Every text element is a bidi paragraph of its own (unicode-bidi: plaintext),
     so "−1.3%", "+28%", "$8.4M" or "16.61 → 26.56" read the same as in English, while an Arabic
     sentence still flows right-to-left. Charts and canvases stay LTR so axes never flip.
*/

/* ── 2 · data keeps its own direction ── */
html[dir="rtl"] body *:not(svg):not(svg *):not(canvas) { unicode-bidi: plaintext; }
html[dir="rtl"] svg, html[dir="rtl"] canvas,
html[dir="rtl"] [id*="Chart"], html[dir="rtl"] [class*="chart"], html[dir="rtl"] .tv-chart,
html[dir="rtl"] code, html[dir="rtl"] pre, html[dir="rtl"] kbd,
html[dir="rtl"] input[type="number"], html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="url"] {
  direction: ltr;
}
/* a chart container is LTR inside, but still sits where the RTL layout puts it */
html[dir="rtl"] [id*="Chart"] { text-align: left; }

/* ── 1 · shell ── */
html[dir="rtl"] #sidebar { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--b1); }
html[dir="rtl"] #main { left: 0; right: var(--sidebar); }
html[dir="rtl"] .sb-item.active::before { left: auto; right: 0; border-radius: 1px 0 0 1px; }
html[dir="rtl"] .sb-badge { margin-left: 0; margin-right: auto; }
html[dir="rtl"] #nodalStaleBanner { left: 12px; right: calc(var(--sidebar) + 12px); }
html[dir="rtl"] #macroAlert { right: auto !important; left: 24px; }
html[dir="rtl"] #sc-bubble, html[dir="rtl"] #sc-window { right: auto !important; left: 24px; }
html[dir="rtl"] #sc-badge { right: auto; left: -3px; }
html[dir="rtl"] #flaskPanel { right: auto !important; left: 12px; }

@media (max-width: 767px) {
  html[dir="rtl"] #sidebar { transform: translateX(100%); }
  html[dir="rtl"] #sidebar.mob-open { transform: translateX(0); }
  html[dir="rtl"] #main { right: 0; }
  html[dir="rtl"] #nodalStaleBanner { left: 12px; right: 12px; }
  html[dir="rtl"] #macroAlert, html[dir="rtl"] #sc-bubble, html[dir="rtl"] #sc-window { left: 16px; }
}

/* ── 1 · content: start/end swap for the alignments and accents written inline in Scanner.html ── */
html[dir="rtl"] th, html[dir="rtl"] td { text-align: right; }
html[dir="rtl"] [style*="text-align:left"] { text-align: right !important; }
html[dir="rtl"] [style*="text-align:right"] { text-align: left !important; }
html[dir="rtl"] [style*="margin-left:auto"] { margin-left: 0 !important; margin-right: auto !important; }
/* inline border-left accents (status rails) stay on the left: CSS cannot read their inline colour to mirror it. */
html[dir="rtl"] .tmg-tag { right: auto; left: 8px; }
html[dir="rtl"] .nh-i { margin-left: 0; margin-right: 5px; }
/* Monospace value cells: JetBrains Mono has no Arabic letters, and the generic `monospace` fallback
   draws Arabic unjoined ("ت خ ف ي ض ا ت"). Digits keep the mono face; Arabic words fall to sans. */
html[dir="rtl"] .mono { font-family: "JetBrains Mono", system-ui, "Segoe UI", sans-serif; }
/* Help pop-up section headings are letter-spaced uppercase Latin; spacing pulls Arabic letters apart. */
html[dir="rtl"] .nh-pop .nh-lbl { letter-spacing: 0; text-transform: none; font-family: inherit; font-size: 11px; }
