/* RTL adjustments for Arabic (/sa). Loaded only when <html dir="rtl">. */

/* Tailwind 2 space-x utilities put the gap on the left; flip it for RTL rows. */
[dir="rtl"] [class*="space-x-"] > :not([hidden]) ~ :not([hidden]) {
  --tw-space-x-reverse: 1;
}

/* Physical text alignment utilities follow the reading direction. */
[dir="rtl"] .text-left { text-align: right; }
[dir="rtl"] .text-right { text-align: left; }

/* Latin-only values (emails, codes, numbers in inputs) stay left-to-right. */
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="number"],
[dir="rtl"] input[type="url"],
[dir="rtl"] code {
  direction: ltr;
  text-align: right;
}

/* Arabic glyphs are not in Inter; use a system Arabic font after it. */
[dir="rtl"] body {
  font-family: Inter, "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Arial, sans-serif;
}

/* Gradebook "Plan limits" popover: open toward the inside of the page (to the left) in RTL. */
[dir="rtl"] #journal-content .plan-limits-popover {
  left: auto;
  right: calc(100% + 10px);
  transform: translateX(4px);
}
[dir="rtl"] #journal-content .plan-limits-popover.visible { transform: none; }
[dir="rtl"] .plan-limits-popover { left: auto; right: 0; }
@media (max-width: 640px) {
  [dir="rtl"] #journal-content .plan-limits-popover {
    right: 0;
    left: auto;
    transform: translateY(4px);
  }
}

/* Weekend badge in the gradebook header: one line, no letter-spacing (it breaks Arabic joining). */
[dir="rtl"] .journal-table th .journal-weekend-label {
  letter-spacing: 0;
  white-space: nowrap;
}
