/*
 * RTL overrides for Arabic. Loaded LAST and only when <html dir="rtl">.
 *
 * The flexbox sidebar/content structure and Bootstrap's logical margin utilities (ms-*/me-*) mirror
 * automatically under dir="rtl". These rules fix everything that uses *physical* left/right — the
 * app's custom CSS, Bootstrap's physical float/text utilities, form controls, dropdowns, and
 * DataTables chrome.
 */

[dir="rtl"] body {
    text-align: right;
    font-family: 'Tajawal', 'Cairo', 'Roboto', sans-serif;
}

/* ---- Bootstrap physical utilities that do NOT flip on their own ---- */
[dir="rtl"] .text-end   { text-align: left !important; }
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .float-end   { float: left !important; }
[dir="rtl"] .float-start { float: right !important; }

/* Form select arrow + check/radio sit on the correct side. */
[dir="rtl"] .form-select {
    background-position: left 0.75rem center;
    padding-right: 0.75rem;
    padding-left: 2.25rem;
    text-align: right;
}
[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.5em;
}
[dir="rtl"] .form-check .form-check-input {
    float: right;
    margin-left: 0;
    margin-right: -1.5em;
}
[dir="rtl"] .form-control,
[dir="rtl"] .form-label,
[dir="rtl"] label,
[dir="rtl"] .control-label {
    text-align: right;
}

/* Dropdowns / modal close button. */
[dir="rtl"] .dropdown-menu { text-align: right; }
[dir="rtl"] .modal-header .btn-close { margin: -0.5rem auto -0.5rem -0.5rem; }
[dir="rtl"] .ms-auto { margin-left: 0 !important; margin-right: auto !important; }

/* ---- App custom layout (layout-new.css + inline _Layout styles) ---- */
/* The sidebar is `position: fixed; left: 0` and `.main` uses physical `margin-left`
   (both from the CDN site.css) — neither mirrors under dir="rtl". Pin the sidebar to
   the right edge and push the main content to the left. */
[dir="rtl"] .sideBar {
    left: auto !important;
    right: 0 !important;
    border-right: none !important;
    border-left: 1px solid #F0F1F3 !important;
}
[dir="rtl"] .main {
    margin-left: 0 !important;
    margin-right: auto !important;
}
/* Responsive: below 820px the CDN reserves space for the left fixed sidebar with
   physical margin-left (67px collapsed / 252px open) — mirror those to the right. */
@media (max-width: 820px) {
    [dir="rtl"] .sideMenuClosed .main,
    [dir="rtl"] .main {
        margin-left: 0 !important;
        margin-right: 67px !important;
    }
    [dir="rtl"] .main {
        margin-right: 252px !important;
    }
}
/* Sidebar menu RTL fixes — the CDN/UA use physical left/right that do not mirror:
   0. The menu <ul> keeps the user-agent default `padding-inline-start: 40px`. Bootstrap only zeroes
      the physical `padding-left`, which is the LEFT (inline-end) in RTL — so the inline-start (right)
      keeps the 40px, indenting the whole menu from the right edge. Zero it. */
[dir="rtl"] #menuCOll,
[dir="rtl"] .sideMenu .navbar-nav {
    padding-inline-start: 0 !important;
    padding-right: 0 !important;
}
/* 1. The nav-link icon has `margin-right` (4px, 10px on hover). In RTL that gap lands on the right
      EDGE instead of between the icon and its label — flip to margin-left. */
[dir="rtl"] .navbar-nav .nav-item .nav-link i {
    margin-right: 0 !important;
    margin-left: 4px !important;
}
[dir="rtl"] .navbar-nav .nav-item .nav-link:hover i {
    margin-right: 0 !important;
    margin-left: 10px !important;
}
/* 2. The dropdown caret is pinned with `right: 18px`, so in RTL it overlaps the icon on the right
      instead of sitting in the empty gutter — mirror it to the left edge. */
[dir="rtl"] .navbar-nav .nav-item.hasDrop .nav-link:after {
    right: auto !important;
    left: 18px !important;
}
/* 3. Submenu bullet dash `:before` uses margin-right — flip to margin-left. */
[dir="rtl"] .navbar-nav .nav-item .subMenu a:before {
    margin-right: 0;
    margin-left: 7px;
}
[dir="rtl"] .margin-left-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .margin-left { margin-left: 0 !important; margin-right: 11px !important; }
[dir="rtl"] .userAvatar { margin-left: 0 !important; margin-right: .98rem !important; }
[dir="rtl"] .language-switcher { margin-right: 0 !important; margin-left: auto !important; }
[dir="rtl"] .notification-dropdown { right: auto !important; left: 18px !important; }
[dir="rtl"] .margin-left-auto .badge { right: auto !important; left: -4px !important; }
[dir="rtl"] .sidebar-search .search-icon { right: auto; left: 10px; }

/* Select2 single-select internals. */
[dir="rtl"] .select2-container .select2-selection--single .select2-selection__rendered {
    padding-left: 20px;
    padding-right: 16px;
    text-align: right;
}
[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow {
    right: auto;
    left: 7px;
}

/* ---- DataTables chrome ---- */
[dir="rtl"] .dataTables_wrapper { text-align: right; }
[dir="rtl"] .dataTables_wrapper .dataTables_filter { text-align: left; }
[dir="rtl"] .dataTables_wrapper .dataTables_filter input { margin-right: 0.5em; margin-left: 0; }
[dir="rtl"] .dataTables_wrapper .dataTables_length { text-align: right; }
[dir="rtl"] .dataTables_wrapper .dataTables_paginate { text-align: left; }
[dir="rtl"] table.dataTable,
[dir="rtl"] table.dataTable th,
[dir="rtl"] table.dataTable td { text-align: right; }
[dir="rtl"] .html5buttons { justify-content: flex-start; }
[dir="rtl"] .btnCon { text-align: left; }

/* Icons that sit before text keep a right-side gap in RTL. */
[dir="rtl"] .me-2 { margin-right: 0 !important; margin-left: .5rem !important; }
[dir="rtl"] .ms-1 { margin-left: 0 !important; margin-right: .25rem !important; }
[dir="rtl"] .ms-2 { margin-left: 0 !important; margin-right: .5rem !important; }
