/**
 * MedNova RTL Overrides
 * ─────────────────────────────────────────────────────────────────────────────
 * Loaded only when the page direction is right-to-left (see App\Support\Direction).
 *
 * The MedNova stylesheets themselves use logical properties and need no help.
 * What does need mirroring is everything underneath them: Bootstrap 4 utility
 * classes, ruang-admin, DataTables and the handful of inline `left:` / `right:`
 * offsets in the public views. Without this the dashboards rendered with the
 * sidebar, table controls and dropdowns all on the wrong side.
 * ─────────────────────────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════════════════════════════════════
   1. GLOBAL
   ═══════════════════════════════════════════════════════════════════════════ */

[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}

/* Latin-only strings — phone numbers, emails, URLs, times, money — stay LTR
   so digits and punctuation do not get reordered inside RTL paragraphs. */
[dir="rtl"] .mn-ltr,
[dir="rtl"] a[href^="tel:"],
[dir="rtl"] a[href^="mailto:"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="url"],
[dir="rtl"] input[type="number"],
[dir="rtl"] .mn-emergency-phone,
[dir="rtl"] .mn-topbar-item a[href^="tel:"] {
  direction: ltr;
  unicode-bidi: embed;
}

[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="url"],
[dir="rtl"] input[type="number"] {
  text-align: right;
}

/* Icons that point somewhere ("next", "send", "arrow-right") must flip. */
[dir="rtl"] .rtl-flip,
[dir="rtl"] [data-lucide="arrow-right"],
[dir="rtl"] [data-lucide="arrow-left"],
[dir="rtl"] [data-lucide="chevron-right"],
[dir="rtl"] [data-lucide="chevron-left"],
[dir="rtl"] [data-lucide="send"],
[dir="rtl"] [data-lucide="move-right"] {
  transform: scaleX(-1);
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. PUBLIC SITE
   ═══════════════════════════════════════════════════════════════════════════ */

[dir="rtl"] .mn-skip-link:focus {
  left: auto;
  right: var(--mn-space-4);
}

[dir="rtl"] .mn-lang-dropdown {
  right: auto;
  left: 0;
}

/* The drawer and its close button use logical insets and a flipped transform
   in the nav partial itself, so there is nothing to mirror here any more. */

[dir="rtl"] .mn-text-left  { text-align: right; }
[dir="rtl"] .mn-text-right { text-align: left; }

/* Custom selects draw their chevron as a background image pinned to the right. */
[dir="rtl"] select {
  background-position: left 10px center;
}
[dir="rtl"] .mn-filter-select {
  padding-inline-end: 10px;
  padding-inline-start: 28px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. BOOTSTRAP 4 UTILITIES (admin + legacy dashboard markup)
   ═══════════════════════════════════════════════════════════════════════════ */

[dir="rtl"] .text-left  { text-align: right !important; }
[dir="rtl"] .text-right { text-align: left  !important; }

[dir="rtl"] .float-left  { float: right !important; }
[dir="rtl"] .float-right { float: left  !important; }

[dir="rtl"] .ml-auto { margin-right: auto !important; margin-left: 0 !important; }
[dir="rtl"] .mr-auto { margin-left: auto !important; margin-right: 0 !important; }
[dir="rtl"] .mx-auto { margin-left: auto !important; margin-right: auto !important; }

[dir="rtl"] .mr-1 { margin-right: 0 !important; margin-left: .25rem !important; }
[dir="rtl"] .mr-2 { margin-right: 0 !important; margin-left: .5rem  !important; }
[dir="rtl"] .mr-3 { margin-right: 0 !important; margin-left: 1rem   !important; }
[dir="rtl"] .mr-4 { margin-right: 0 !important; margin-left: 1.5rem !important; }
[dir="rtl"] .mr-5 { margin-right: 0 !important; margin-left: 3rem   !important; }

[dir="rtl"] .ml-1 { margin-left: 0 !important; margin-right: .25rem !important; }
[dir="rtl"] .ml-2 { margin-left: 0 !important; margin-right: .5rem  !important; }
[dir="rtl"] .ml-3 { margin-left: 0 !important; margin-right: 1rem   !important; }
[dir="rtl"] .ml-4 { margin-left: 0 !important; margin-right: 1.5rem !important; }
[dir="rtl"] .ml-5 { margin-left: 0 !important; margin-right: 3rem   !important; }

[dir="rtl"] .pr-1 { padding-right: 0 !important; padding-left: .25rem !important; }
[dir="rtl"] .pr-2 { padding-right: 0 !important; padding-left: .5rem  !important; }
[dir="rtl"] .pr-3 { padding-right: 0 !important; padding-left: 1rem   !important; }
[dir="rtl"] .pl-1 { padding-left: 0 !important; padding-right: .25rem !important; }
[dir="rtl"] .pl-2 { padding-left: 0 !important; padding-right: .5rem  !important; }
[dir="rtl"] .pl-3 { padding-left: 0 !important; padding-right: 1rem   !important; }

[dir="rtl"] .input-group > .form-control:not(:last-child),
[dir="rtl"] .input-group > .custom-select:not(:last-child) {
  border-radius: 0 .25rem .25rem 0;
}
[dir="rtl"] .input-group > .form-control:not(:first-child),
[dir="rtl"] .input-group > .custom-select:not(:first-child) {
  border-radius: .25rem 0 0 .25rem;
}

[dir="rtl"] .custom-control {
  padding-left: 0;
  padding-right: 1.5rem;
}
[dir="rtl"] .custom-control-label::before,
[dir="rtl"] .custom-control-label::after {
  left: auto;
  right: -1.5rem;
}

[dir="rtl"] .dropdown-menu {
  text-align: right;
}
[dir="rtl"] .dropdown-menu-right {
  right: auto !important;
  left: 0 !important;
}
[dir="rtl"] .modal-header .close {
  margin: -1rem auto -1rem -1rem;
}
[dir="rtl"] .close { float: left; }

[dir="rtl"] .breadcrumb-item + .breadcrumb-item { padding-left: 0; padding-right: .5rem; }
[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before { padding-left: .5rem; padding-right: 0; float: right; }

/* ═══════════════════════════════════════════════════════════════════════════
   4. DATATABLES
   ═══════════════════════════════════════════════════════════════════════════ */

[dir="rtl"] .dataTables_wrapper .dataTables_filter { float: left; text-align: left; }
[dir="rtl"] .dataTables_wrapper .dataTables_length { float: right; }
[dir="rtl"] .dataTables_wrapper .dataTables_info   { float: right; }
[dir="rtl"] .dataTables_wrapper .dataTables_paginate { float: left; }
[dir="rtl"] .dataTables_wrapper .dataTables_filter input { margin-left: 0; margin-right: .5em; }
[dir="rtl"] table.dataTable thead th,
[dir="rtl"] table.dataTable thead td,
[dir="rtl"] table.dataTable tbody th,
[dir="rtl"] table.dataTable tbody td { text-align: right; }
[dir="rtl"] table.dataTable thead .sorting,
[dir="rtl"] table.dataTable thead .sorting_asc,
[dir="rtl"] table.dataTable thead .sorting_desc { background-position: left center; }

/* ═══════════════════════════════════════════════════════════════════════════
   5. ADMIN + USER DASHBOARD SHELL
   ═══════════════════════════════════════════════════════════════════════════ */

/* The shells already use logical properties; these cover the legacy
   ruang-admin sidebar and the odd hard-coded offset. */
[dir="rtl"] .mn-admin-shell .mn-sidebar { box-shadow: -2px 0 8px rgba(10, 22, 40, .05); }
[dir="rtl"] .mn-sidebar                 { box-shadow: -2px 0 8px rgba(10, 22, 40, .04); }

[dir="rtl"] .mn-admin-shell .mn-nav-link,
[dir="rtl"] .mn-sidebar-nav-link,
[dir="rtl"] .mn-admin-shell .mn-nav-group-title,
[dir="rtl"] .mn-sidebar-heading {
  text-align: right;
}

[dir="rtl"] .sidebar .nav-item .nav-link,
[dir="rtl"] .sidebar .sidebar-heading { text-align: right !important; }
[dir="rtl"] .navbar-nav { padding: 0 !important; }

/* Chart.js / legacy report canvases keep their own LTR coordinate space. */
[dir="rtl"] .chart-area,
[dir="rtl"] .chart-pie,
[dir="rtl"] .chart-bar { direction: ltr; }
