/* Arabic: right-to-left layout and the language switch (assets/js/i18n.js).
   Bootstrap's RTL build flips its own classes (ms-/me-, text-start/end...);
   these rules mirror the POS's own layout from style.css. Loaded on every
   page in both languages - the rules only apply under html[dir="rtl"]. */

html[dir="rtl"] body {
  font-family: 'Cairo', 'Inter', 'Segoe UI', Tahoma, sans-serif;
}
/* Letter spacing breaks joined Arabic letters apart. */
html[dir="rtl"] body * { letter-spacing: normal !important; }

/* Sidebar on the right, page beside it */
[dir="rtl"] .sidebar { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--sb-border); }
[dir="rtl"] .page-wrapper { margin-left: 0; margin-right: var(--sb-w); transition: margin-right var(--tr); }
[dir="rtl"] .app-layout.sidebar-collapsed .page-wrapper { margin-left: 0; margin-right: var(--sb-icon-w); }
[dir="rtl"] .sidebar-collapse-btn { margin-left: 0; margin-right: auto; }
[dir="rtl"] .sidebar-collapse-btn i, [dir="rtl"] .bi-chevron-left, [dir="rtl"] .bi-chevron-right,
[dir="rtl"] .bi-arrow-left, [dir="rtl"] .bi-arrow-right, [dir="rtl"] .bi-arrow-right-short,
[dir="rtl"] .bi-box-arrow-right, [dir="rtl"] .bi-arrow-return-left { display: inline-block; transform: scaleX(-1); }
@media (max-width: 991px) {
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  [dir="rtl"] .app-layout.sidebar-open .sidebar { transform: translateX(0); }
  [dir="rtl"] .page-wrapper { margin-right: 0 !important; }
}

/* Small pieces of style.css that sit on one side */
[dir="rtl"] .input-group .form-control:not(:first-child) { border-left: 1px solid var(--input-border, #dee2e6) !important; border-right: none !important; }
[dir="rtl"] .input-group .form-control:not(:last-child) { border-right: 1px solid var(--input-border, #dee2e6) !important; border-left: none !important; }
[dir="rtl"] .inv-chip-label { margin-right: 0; margin-left: 2px; }
[dir="rtl"] .inv-chip-toggle { margin-left: 0; margin-right: auto; }
[dir="rtl"] .inv-clear { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .att-dot { margin-right: 0; margin-left: 4px; }
[dir="rtl"] .att-steps { padding-left: 0; padding-right: 1.2rem; }
[dir="rtl"] .rc-items-table thead th:first-child, [dir="rtl"] .rc-items-table td:first-child { padding-left: .5rem !important; padding-right: 12px !important; }
[dir="rtl"] .rpt-pl td:last-child { text-align: left; }
[dir="rtl"] .num, [dir="rtl"] td.num, [dir="rtl"] th.num { text-align: left; }
/* Page styles (pages/pos.php, reports.php, purchase_orders.php) */
[dir="rtl"] .pos-tab .close-tab { margin-left: 0; margin-right: 8px; }
[dir="rtl"] .pos-tab-count { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .pos-tab.is-fresh::after { right: auto; left: 4px; }
[dir="rtl"] .pos-sync-note { margin-left: 0; margin-right: 6px; }
[dir="rtl"] .pos-net-detail { text-align: right; }
[dir="rtl"] .pos-tab-unsaved { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .fav-chips .quick-shortcut-btn { text-align: right; }
[dir="rtl"] .quick-shortcut-dismiss { right: auto; left: -6px; }
[dir="rtl"] .rpt-card h5 .rpt-sub { margin-left: 0; margin-right: auto; }
[dir="rtl"] .nut-group li { border-left: 0; border-right: 3px solid; }
[dir="rtl"] .rpt-barrow .val, [dir="rtl"] .rpt-table td.num, [dir="rtl"] .rpt-table th.num { text-align: left; }
[dir="rtl"] .po-search > .bi-search { left: auto; right: 14px; }
[dir="rtl"] .po-search-hint { right: auto; left: 12px; }
[dir="rtl"] .po-clear { margin-left: 0; margin-right: auto; }
@media (max-width: 767px) { [dir="rtl"] .po-clear { margin-right: 0; } }
/* Barcode labels print as designed, whatever the language */
[dir="rtl"] .label-sheet, [dir="rtl"] .label-twin { direction: ltr; }

/* Codes, phone numbers, amounts typed in boxes stay left-to-right */
[dir="rtl"] input[type="number"], [dir="rtl"] input[type="tel"], [dir="rtl"] input[type="email"],
[dir="rtl"] input[type="url"], [dir="rtl"] .font-monospace, [dir="rtl"] code { direction: ltr; unicode-bidi: plaintext; }
[dir="rtl"] input[type="number"] { text-align: right; }

/* ---------------------------------------------------------------- switching */

/* Arabic page still being translated as it loads: keep it hidden a moment. */
html.i18n-loading body { visibility: hidden; }

/* The quick fade while the language changes in place. */
body { transition: opacity .14s ease, filter .14s ease; }
html.i18n-switching body { opacity: .15; filter: blur(3px); }
@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
  html.i18n-switching body { filter: none; }
}

/* EN | ع switch (top bar and sign-in page) */
.lang-switch {
  position: relative; display: inline-flex; align-items: center;
  height: 34px; padding: 3px; border-radius: 999px;
  background: var(--input-bg, rgba(127,127,127,.12)); border: 1px solid var(--input-border, rgba(127,127,127,.25));
  direction: ltr; /* EN stays on the left in both languages, so the switch never jumps */
}
.lang-switch button {
  position: relative; z-index: 1; border: 0; background: none; cursor: pointer;
  min-width: 38px; height: 26px; padding: 0 10px; border-radius: 999px;
  font: 600 12.5px/1 'Inter', 'Cairo', sans-serif; color: var(--text-muted, #6b7280);
  transition: color .2s ease;
}
.lang-switch button[data-lang-switch="ar"] { font-family: 'Cairo', sans-serif; font-size: 14px; }
.lang-switch button.is-active { color: #fff; }
.lang-switch button:focus-visible { outline: 2px solid var(--accent, #10b981); outline-offset: 2px; }
.lang-switch .lang-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border-radius: 999px; background: var(--accent, #10b981);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  transition: transform .28s cubic-bezier(.3, 1.4, .5, 1);
}
html[lang="ar"] .lang-switch .lang-thumb { transform: translateX(100%); }
.lang-switch-float { position: fixed; top: 14px; right: 14px; z-index: 1050; }
[dir="rtl"] .lang-switch-float { right: auto; left: 14px; }
@media print { .lang-switch, .lang-switch-float { display: none !important; } }
