/* ---------------------------------------------------------------
   Right-to-left pages (ROADMAP F66 step 2): loaded by base.html only when the page's language is Arabic, after
   Bootstrap's mirrored file (bootstrap.rtl.min.css). Our other stylesheets use start / end sides (margin-inline-start,
   inset-inline-end, text-align: end ...), so the menu, cards, toasts and tables turn with the page by themselves.
   This file keeps left-to-right what must stay so: numbers, prices, dates, symbols, charts and code.
   --------------------------------------------------------------- */

/* Text whose own letters decide its direction: "-3.5%", "2026-10-15 23:00", "BTC/USDT" read left-to-right, an
   Arabic phrase right-to-left (the Arabic words carry a right-to-left mark, libs/i18n.py), so a minus sign or a
   date never jumps to the wrong end inside an Arabic page */
[dir="rtl"] :is(td, th, span, b, strong, small, em, i, time, code, kbd, abbr, sup, sub, label, a, bdi, output, dd, dt) {
    unicode-bidi: plaintext;
}

/* table cells: plaintext would also turn a cell's "start" and "end" with its text (a number's start is the left), so
   the cells are placed by the page instead - text at the right, numbers columns (heads and values) at the left, as the
   English pages have them mirrored. :where() keeps the first rule weak, so a page's own centring still wins */
:where([dir="rtl"]) :is(td, th) { text-align: right; }
[dir="rtl"] :is(td.num, th.num, td.text_align_right, th.text_align_right) { text-align: left; }

/* typed numbers, prices, keys and addresses stay left-to-right in their boxes */
[dir="rtl"] :is(input[type="number"], input[inputmode="decimal"], input[inputmode="numeric"], input[type="email"],
               input[type="url"], input[type="tel"], input[type="password"], code, pre, kbd) {
    direction: ltr;
}
[dir="rtl"] :is(input[type="number"], input[inputmode="decimal"], input[inputmode="numeric"]) { text-align: right; }

/* charts are drawn left-to-right (time runs to the right, the price scale on the right), as on every Arabic trading
   site; tv_charts.js also marks its boxes dir="ltr". SVG text anchors follow the direction, so drawings stay ltr */
[dir="rtl"] :is(svg, canvas, .si-chart, .chart-box, .chart-main, .chart-body, .pt-chart, .perf-chart, .coin-chart,
               .mini-chart, .home-card-spark, .pf-card-spark, .usage-charts) {
    direction: ltr;
}

/* arrows that point "forward" / "back" turn with the page */
[dir="rtl"] :is(.cam-chevron, .start-tool-open > span[aria-hidden="true"], #evPrev, #evNext) {
    display: inline-block;
    transform: scaleX(-1);
}
[dir="rtl"] svg:has(use[href="#icon-logout"]),
[dir="rtl"] svg:has(use[href="#icon-send"]) { transform: scaleX(-1); }

/* Arabic letters need a little more line height than Latin ones */
[dir="rtl"] body { line-height: 1.6; }

/* upper case and letter spacing are for Latin letters: Arabic has no capitals and its letters join */
[dir="rtl"] :is(thead th, .text-uppercase) { letter-spacing: 0; }

/* the drop-down arrow of a select, and the changed-setting bar (app.css), on the start side's mirror */
[dir="rtl"] select { background-position: 11px calc(50% + 2px), 16px calc(50% + 2px); }
[dir="rtl"] .is-changed:is(select, input, textarea) { box-shadow: inset -3px 0 0 var(--accent); }
