/* ==========================================================================
   RTL — right-to-left mirror layer
   --------------------------------------------------------------------------
   Loaded ONLY when the active locale is a right-to-left script (see
   AppServiceProvider::boot -> $is_rtl). It is the last stylesheet on the page,
   so it overrides bootstrap.min.css, style.default.css, custom-<theme>.css and
   theme-upgrade.css without any of them needing to change.

   Everything here is a mirror of an existing LTR rule: what was on the left
   goes right and vice versa. Nothing new is introduced.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. BASE
   -------------------------------------------------------------------------- */
html[dir="rtl"] body,
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select,
html[dir="rtl"] button {
    /* Plus Jakarta Sans carries no Arabic glyphs — lead with a face that does */
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, sans-serif;
}
html[dir="rtl"] body { text-align: right; }

/* Numbers, currency codes, dates and references must stay LTR even inside an
   RTL paragraph, otherwise "246.80 RO" renders as "RO 80.246". */
html[dir="rtl"] .nvx-stat-value,
html[dir="rtl"] .nvx-breakdown-value,
html[dir="rtl"] .nvx-breakdown-pct,
html[dir="rtl"] .count-number,
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] .text-ltr {
    direction: ltr;
    unicode-bidi: embed;
}
html[dir="rtl"] .nvx-breakdown-value,
html[dir="rtl"] .nvx-breakdown-pct { text-align: left; }

/* --------------------------------------------------------------------------
   2. SHELL — sidebar / page / header
   -------------------------------------------------------------------------- */
html[dir="rtl"] .side-navbar {
    left: auto;
    right: 0;
    text-align: right;
    border-right: 0;
    border-left: 1px solid var(--border);
    box-shadow: -1px 0 0 rgba(22, 17, 43, .02);
    padding-left: 10px;
    padding-right: 10px;
}
html[dir="rtl"] .side-navbar.hide { left: auto; right: -50px; }

html[dir="rtl"] .page {
    margin-left: 0;
    margin-right: var(--sidebar-w);
    transition: margin-right var(--dur-slow) var(--ease-out), width var(--dur-slow) var(--ease-out);
}
html[dir="rtl"] .page.active { margin-right: 0; }

/* header */
html[dir="rtl"] .brand-big { margin-left: auto; margin-right: 14px; }
html[dir="rtl"] .navbar-holder { flex-direction: row; }
html[dir="rtl"] .nav-menu { padding-right: 0; }

/* --------------------------------------------------------------------------
   3. SIDEBAR MENU INTERNALS
   -------------------------------------------------------------------------- */
html[dir="rtl"] .side-navbar li a i {
    margin-right: 0;
    margin-left: 10px;
}

/* Collapse caret: only the anchor side moves (right -> left edge). The glyph
   itself stays fa-angle-left and keeps the LTR rotate(-90deg) on expand, so it
   points left when collapsed and down when open — inherited, not redeclared. */
html[dir="rtl"] .side-navbar li a[data-toggle="collapse"]::before {
    right: auto;
    left: 12px;
}

/* hover nudge follows the reading direction */
html[dir="rtl"] .side-navbar li a:hover,
html[dir="rtl"] .side-navbar li a:focus { transform: translateX(-2px); }
html[dir="rtl"] .side-navbar li ul li a:hover { transform: translateX(-3px); }

/* submenu: indent + guide line move to the right edge */
html[dir="rtl"] .side-navbar li ul {
    margin-left: 4px;
    margin-right: 26px;
    padding-left: 0;
    padding-right: 14px;
    border-left: 0;
    border-right: 1.5px solid var(--border);
}
html[dir="rtl"] .side-navbar li ul li a::after {
    left: auto;
    right: -15px;
}

/* --------------------------------------------------------------------------
   4. BOOTSTRAP UTILITIES
   -------------------------------------------------------------------------- */
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, html[dir="rtl"] .mx-auto { margin-left: auto !important; }
html[dir="rtl"] .mr-auto { margin-right: auto !important; }

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

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

/* --------------------------------------------------------------------------
   5. COMPONENTS
   -------------------------------------------------------------------------- */
/* dropdowns */
html[dir="rtl"] .dropdown-menu { text-align: right; left: auto; right: 0; }
html[dir="rtl"] .dropdown-menu-right { right: auto; left: 0; }
html[dir="rtl"] .dropdown-toggle::after { margin-left: 0; margin-right: .255em; }

/* style.default.css pins the LAST header menu with
   `nav.navbar .nav-menu li:last-child .dropdown-menu { right: 2rem }` — that
   selector scores (0,4,2), so the plain .dropdown-menu-right override above
   loses on specificity no matter how late this file loads. In RTL that last
   item sits at the LEFT edge of the header, and `right: 2rem` then drags the
   panel off-screen. Re-anchor it to the trigger with a heavier selector. */
html[dir="rtl"] nav.navbar .nav-menu li:last-child .dropdown-menu,
html[dir="rtl"] nav.navbar .nav-menu li .dropdown-menu {
    right: auto;
    left: 0;
    float: none;
}

/* The menu keeps its own 8px padding — never inherit a list indent here, or the
   items get squeezed past the min-width and the labels clip. */
html[dir="rtl"] .dropdown-menu { padding-left: 8px; padding-right: 8px; }
html[dir="rtl"] .dropdown-menu > li,
html[dir="rtl"] .dropdown-menu > .nav-item { padding-right: 0; }
html[dir="rtl"] .dropdown-menu > li > a,
html[dir="rtl"] .dropdown-menu .dropdown-item,
html[dir="rtl"] .dropdown-menu li a.btn-link { text-align: right; }
html[dir="rtl"] .dropdown-menu > li > a:hover,
html[dir="rtl"] .dropdown-menu .dropdown-item:hover,
html[dir="rtl"] .dropdown-menu li a.btn-link:hover { transform: translateX(-2px); }

/* tables */
html[dir="rtl"] .table th,
html[dir="rtl"] .table td { text-align: right; }
html[dir="rtl"] .table th.text-right,
html[dir="rtl"] .table td.text-right { text-align: left; }
html[dir="rtl"] .table thead th { text-align: right; }

/* forms */
html[dir="rtl"] label,
html[dir="rtl"] .col-form-label,
html[dir="rtl"] .form-control { text-align: right; }
html[dir="rtl"] .input-group > .input-group-prepend > .input-group-text { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
html[dir="rtl"] .input-group > .input-group-append > .input-group-text  { border-radius: var(--r-sm) 0 0 var(--r-sm); }
html[dir="rtl"] .custom-control,
html[dir="rtl"] .abc-checkbox,
html[dir="rtl"] .abc-radio { padding-left: 0; padding-right: 1.5rem; }
html[dir="rtl"] .abc-checkbox label::before,
html[dir="rtl"] .abc-checkbox label::after,
html[dir="rtl"] .abc-radio label::before,
html[dir="rtl"] .abc-radio label::after,
html[dir="rtl"] .custom-control-label::before,
html[dir="rtl"] .custom-control-label::after { left: auto; right: 0; }
html[dir="rtl"] label > input[type="checkbox"],
html[dir="rtl"] label > input[type="radio"] { margin-right: 0; margin-left: 8px; }

/* selects rendered by bootstrap-select */
html[dir="rtl"] .bootstrap-select .dropdown-toggle .filter-option { text-align: right; }
html[dir="rtl"] .bootstrap-select.btn-group .dropdown-toggle .caret { right: auto; left: 12px; }

/* nav tabs / pills */
html[dir="rtl"] .nav { padding-right: 0; }

/* lists
   ONLY plain prose lists get their marker indent mirrored. Every list that
   carries a class in this app is a component (dropdown, nav, tabs, sidebar
   menu, bootstrap-select) whose padding is already deliberate — flipping those
   pushes their contents out of the box. */
html[dir="rtl"] ul:not([class]),
html[dir="rtl"] ol:not([class]) { padding-left: 0; padding-right: 2rem; }

/* alerts + close button */
html[dir="rtl"] .alert-dismissible { padding-right: 1.25rem; padding-left: 4rem; }
html[dir="rtl"] .alert-dismissible .close { right: auto; left: 0; }

/* modals */
html[dir="rtl"] .modal-header .close { margin: -1rem auto -1rem -1rem; }
html[dir="rtl"] .modal-footer > :not(:first-child) { margin-left: 0; margin-right: .25rem; }

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

/* --------------------------------------------------------------------------
   6. DATATABLES
   -------------------------------------------------------------------------- */
html[dir="rtl"] .dataTables_wrapper .dataTables_filter { float: left; text-align: left; }
html[dir="rtl"] .dataTables_wrapper .dataTables_length { float: right; }
html[dir="rtl"] .dataTables_wrapper .dataTables_info   { float: right; }
html[dir="rtl"] .dataTables_wrapper .dataTables_paginate { float: left; }
html[dir="rtl"] .dataTables_filter label,
html[dir="rtl"] .dataTables_length label { text-align: left; }
html[dir="rtl"] table.dataTable thead .sorting::after,
html[dir="rtl"] table.dataTable thead .sorting_asc::after,
html[dir="rtl"] table.dataTable thead .sorting_desc::after { right: auto; left: .5em; }
html[dir="rtl"] div.dt-buttons { float: right; }

/* --------------------------------------------------------------------------
   7. DASHBOARD (nvx-*)
   -------------------------------------------------------------------------- */
html[dir="rtl"] .nvx-legend { justify-content: flex-start; }
html[dir="rtl"] .nvx-breakdown-bar span { inset: 0 0 0 auto; }
html[dir="rtl"] .nvx-stat::after { background: linear-gradient(-100deg, transparent 55%, var(--tint) 100%); }
html[dir="rtl"] .nvx-stat:hover .nvx-stat-icon { transform: scale(1.07) rotate(4deg); }
html[dir="rtl"] .nvx-empty { text-align: center; }

/* --------------------------------------------------------------------------
   8. POS
   -------------------------------------------------------------------------- */
html[dir="rtl"] .pos-page .side-navbar { left: auto; right: 0; }
html[dir="rtl"] .pos-cart-actions { direction: rtl; }

/* --------------------------------------------------------------------------
   9. MISC
   -------------------------------------------------------------------------- */
html[dir="rtl"] .fa-angle-left::before  { content: '\f105'; }
html[dir="rtl"] .fa-angle-right::before { content: '\f104'; }
html[dir="rtl"] .progress-bar { float: right; }

@media (max-width: 1024px) {
    html[dir="rtl"] .page { margin-right: 0; width: 100%; }
    html[dir="rtl"] .brand-big { margin-left: auto; margin-right: 10px; }
}

/* --------------------------------------------------------------------------
   10. V5 POLISH MIRRORS
   -------------------------------------------------------------------------- */
/* brand tick on card/modal headers sits on the reading edge */
html[dir="rtl"] .card-header::before,
html[dir="rtl"] .modal-title::before { margin-right: 0; margin-left: 10px; }

/* list-page toolbar buttons flow right-to-left */
html[dir="rtl"] .page section > .container-fluid > .btn,
html[dir="rtl"] .page section > .container-fluid > a.btn { margin: 0 0 16px 10px; }

/* row-hover accent moves to the right edge */
html[dir="rtl"] .table tbody tr:hover td:first-child { box-shadow: inset -3px 0 0 var(--brand-300); }

/* calendars keep their internal LTR grid — the plugins position and order
   cells assuming LTR; mirroring the grid scrambles week order and arrows */
html[dir="rtl"] .datepicker.dropdown-menu,
html[dir="rtl"] .daterangepicker,
html[dir="rtl"] .ui-timepicker-wrapper { direction: ltr; }

html[dir="rtl"] ul.ui-autocomplete { text-align: right; }

@media (max-width: 767px) {
    html[dir="rtl"] .page section > .container-fluid > .btn,
    html[dir="rtl"] .page section > .container-fluid > a.btn { margin: 0 0 12px 6px; }
}
