/*
 * Right-to-left fixes. Loaded only on RTL pages (UiTranslationTemplateHandler adds it
 * after every other stylesheet in <head>).
 *
 * Layout mirroring itself comes from the Limitless theme's /css/rtl/ build and
 * bootstrap.rtl.min.css (swapped in by the handler) plus the logical CSS properties in
 * the app's own stylesheets. This file only covers what those cannot.
 */

/* Arabic typeface first; Latin text inside Arabic UI falls through to the existing fonts. */
html[dir="rtl"] body,
html[dir="rtl"] .btn,
html[dir="rtl"] .form-control,
html[dir="rtl"] .form-select,
html[dir="rtl"] .dropdown-menu,
html[dir="rtl"] .modal,
html[dir="rtl"] .tooltip,
html[dir="rtl"] .popover,
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3,
html[dir="rtl"] h4, html[dir="rtl"] h5, html[dir="rtl"] h6 {
	font-family: "IBM Plex Sans Arabic", "Tajawal", "Segoe UI", Tahoma, "Inter", "Plus Jakarta Sans", sans-serif;
}

/* Arabic has no capitals and does not survive letter-spacing. */
html[dir="rtl"] .text-uppercase,
html[dir="rtl"] [style*="text-transform: uppercase"],
html[dir="rtl"] [style*="text-transform:uppercase"] {
	letter-spacing: 0 !important;
}

/* Directional icons point the other way. */
html[dir="rtl"] i[class*="arrow-left"],
html[dir="rtl"] i[class*="arrow-right"],
html[dir="rtl"] i[class*="caret-left"],
html[dir="rtl"] i[class*="caret-right"],
html[dir="rtl"] i[class*="chevron-left"],
html[dir="rtl"] i[class*="chevron-right"],
html[dir="rtl"] i[class*="angle-left"],
html[dir="rtl"] i[class*="angle-right"],
html[dir="rtl"] i[class*="arrow-square-out"],
html[dir="rtl"] i[class*="sign-out"],
html[dir="rtl"] i[class*="sign-in"],
html[dir="rtl"] i[class*="arrow-bend"],
html[dir="rtl"] i[class*="arrow-u-"],
html[dir="rtl"] i[class*="list-bullets"],
html[dir="rtl"] i[class*="text-align-left"],
html[dir="rtl"] i[class*="text-align-right"] {
	display: inline-block;
	transform: scaleX(-1);
}

/* Things that are always left-to-right: code, addresses, numbers people type. */
html[dir="rtl"] code,
html[dir="rtl"] pre,
html[dir="rtl"] kbd,
html[dir="rtl"] samp,
html[dir="rtl"] .ltr,
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[type="password"] {
	direction: ltr;
	unicode-bidi: isolate;
}
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[type="password"] {
	text-align: right;
}

/* Mixed content: an English course title or name inside Arabic UI keeps its own order
   (no "(Course 101" with the bracket jumping), while the cell still aligns right. */
html[dir="rtl"] td,
html[dir="rtl"] th,
html[dir="rtl"] li,
html[dir="rtl"] label,
html[dir="rtl"] option,
html[dir="rtl"] .badge,
html[dir="rtl"] .dropdown-item,
html[dir="rtl"] .card-title,
html[dir="rtl"] .breadcrumb-item,
html[dir="rtl"] [data-user-content] {
	unicode-bidi: plaintext;
}

/* Third-party widgets that do not mirror on their own. */
html[dir="rtl"] .dataTables_wrapper .dataTables_filter { text-align: left; }
html[dir="rtl"] .dataTables_wrapper .dataTables_length,
html[dir="rtl"] .dataTables_wrapper .dataTables_info { text-align: right; }
html[dir="rtl"] .dataTables_wrapper .dataTables_paginate { text-align: left; }
html[dir="rtl"] table.dataTable thead th,
html[dir="rtl"] table.dataTable tbody td { text-align: right; }
html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow { left: 1px; right: auto; }
html[dir="rtl"] .select2-container .select2-selection--single .select2-selection__rendered { padding-left: 20px; padding-right: 8px; }
html[dir="rtl"] .driver-popover,
html[dir="rtl"] .jconfirm .jconfirm-box { direction: rtl; text-align: right; }
html[dir="rtl"] .fc { direction: rtl; }
html[dir="rtl"] .powertip,
html[dir="rtl"] #powerTip { direction: rtl; text-align: right; }

/* Charts and canvas-drawn widgets keep LTR axes. */
html[dir="rtl"] canvas,
html[dir="rtl"] .apexcharts-canvas,
html[dir="rtl"] .chart-container svg { direction: ltr; }

/* Float utilities the RTL theme build does not flip in the old Bootstrap 4 names. */
html[dir="rtl"] .float-left  { float: right !important; }
html[dir="rtl"] .float-right { float: left !important; }
html[dir="rtl"] .text-left   { text-align: right !important; }
html[dir="rtl"] .text-right  { text-align: left !important; }
html[dir="rtl"] .ml-auto { margin-left: 0 !important; margin-right: auto !important; }
html[dir="rtl"] .mr-auto { margin-right: 0 !important; margin-left: auto !important; }
