/* Right-to-left (Arabic) adjustments.
   The stylesheets use logical properties (margin-inline-start, inset-inline-end,
   text-align: start, ...), so most of the layout mirrors by itself under
   <html dir="rtl">. This file holds only what logical properties cannot
   express. Every rule is scoped to [dir="rtl"]: left-to-right pages (English,
   French) are not affected. Conventions: docs/implementation/LOCALIZATION_ARCHITECTURE.md */

/* Arabic is cursive: letter-spacing breaks the joins, and it has no case. */
[dir="rtl"] body, [dir="rtl"] body * { letter-spacing: normal !important; }
[dir="rtl"] :is(h1, h2, h3, h4, h5, h6, .erp-kpi__label, th, label, summary) { text-transform: none; }

/* Off-canvas panels open from the other edge. */
@media (max-width: 860px) {
  html[dir="rtl"].sidebar-collapsed .console__sidebar { transform: translateX(100%); }
}
@media (max-width: 900px) {
  html[dir="rtl"]:not(.drawer-open) .erp-sidebar,
  html[dir="rtl"].sidebar-collapsed:not(.drawer-open) .erp-sidebar { transform: translateX(100%); }
}
[dir="rtl"] .erp-help-panel, [dir="rtl"] .erp-notif-panel, [dir="rtl"] .erp-collab-panel { transform: translateX(-100%); }
html[dir="rtl"].help-open .erp-help-panel, html[dir="rtl"].notif-open .erp-notif-panel,
html[dir="rtl"].collab-open .erp-collab-panel { transform: translateX(0); }

/* Directional icons point the other way; non-directional ones are untouched. */
[dir="rtl"] .erp-crumbs__trail .ic,
[dir="rtl"] .u-flip-rtl,
[dir="rtl"] .ic-chevron-right, [dir="rtl"] .ic-arrow-left { transform: scaleX(-1); }
[dir="rtl"] .erp-nav-area.is-folded .erp-nav-area__chev { transform: rotate(90deg); }
[dir="rtl"] .pco-step:not(:last-child)::after { transform: translateY(-50%) rotate(-135deg); }

/* Identifiers, codes, amounts, e-mail addresses, phone numbers and URLs keep
   their own left-to-right order inside Arabic text (never reversed). */
[dir="rtl"] :is(.mono, code, kbd, samp, bdi, .num, .erp-kpi__value, .money) { unicode-bidi: isolate; }
[dir="rtl"] :is(input[type="email"], input[type="tel"], input[type="url"], input[type="number"],
                input[type="date"], input[type="datetime-local"], input[type="time"], input[name*="iban" i],
                input[name*="bic" i], input[name*="phone" i], input[name*="email" i], input[name*="code" i],
                input[name*="reference" i], input[name*="sku" i], input[name*="barcode" i]) {
  direction: ltr; text-align: end;
}
[dir="rtl"] :is(a[href^="mailto:"], a[href^="tel:"], .ltr, [data-ltr]) { direction: ltr; unicode-bidi: isolate; display: inline-block; }
[dir="rtl"] pre { direction: ltr; text-align: left; }

/* Data visualisation keeps the left-to-right axis convention (time and
   quantities grow to the right): the plotted geometry is never mirrored, so a
   chart means the same thing in every language. Labels inside stay Arabic. */
[dir="rtl"] :is(.line-chart-box, .bar-chart, .bubble-chart, .donut-chart__svg, .gauge, .gauge__svg, .ino-gauge__t,
                .cf-chart-wrap, .plan-chart-wrap, .tgo-chart, .mat-chart, .fco-chart, .fco-br__t, .fco-bars,
                .sales-funnel__track, .c360-aging-bar, .oe-bar, .oe-hbar, .hro-bar, .mfo-bar, .dcx-bar,
                .dc-bars, .lg-bars, .mat-bars, .erp-kpi__spark, svg.chart) { direction: ltr; }
