/* =========================================================
   RTL overrides — loaded ONLY when active language == 'ar'
   Applies right-to-left layout site-wide.
   ========================================================= */

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

/* ---------- Base text direction ---------- */
body.rtl p,
body.rtl h1,
body.rtl h2,
body.rtl h3,
body.rtl h4,
body.rtl h5,
body.rtl h6,
body.rtl span,
body.rtl li,
body.rtl label,
body.rtl a,
body.rtl div {
    text-align: inherit;
}

/* Keep code / numbers / ltr-forced bits readable */
body.rtl .ltr,
body.rtl input[type="tel"],
body.rtl input[type="email"],
body.rtl input[type="url"],
body.rtl code,
body.rtl pre,
body.rtl .force-ltr {
    direction: ltr;
    text-align: left;
    unicode-bidi: embed;
}

/* ---------- Flex / row reversal ---------- */
body.rtl .row {
    flex-direction: row-reverse;
}

body.rtl .d-flex:not(.flex-keep-ltr) {
    flex-direction: row-reverse;
}

/* Utility to opt-out of reversal on a specific flex row */
body.rtl .flex-keep-ltr,
body.rtl .rtl-keep {
    flex-direction: row !important;
    direction: ltr;
}

/* ---------- Bootstrap float helpers ---------- */
body.rtl .float-left,
body.rtl .pull-left {
    float: right !important;
}
body.rtl .float-right,
body.rtl .pull-right {
    float: left !important;
}

/* ---------- Text alignment utilities ---------- */
body.rtl .text-left {
    text-align: right !important;
}
body.rtl .text-right {
    text-align: left !important;
}

/* ---------- Margins / paddings mirroring (Bootstrap spacing) ---------- */
body.rtl .ml-auto,
body.rtl .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}
body.rtl .mr-auto,
body.rtl .me-auto {
    margin-right: 0 !important;
    margin-left: auto !important;
}

/* ---------- Lists ---------- */
body.rtl ul,
body.rtl ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

/* ---------- Forms / inputs ---------- */
body.rtl input,
body.rtl textarea,
body.rtl select {
    text-align: right;
    direction: rtl;
}

body.rtl .form-check {
    padding-right: 1.5em;
    padding-left: 0;
}
body.rtl .form-check .form-check-input {
    float: right;
    margin-right: -1.5em;
    margin-left: 0;
}

/* ---------- Dropdowns / menus ---------- */
body.rtl .dropdown-menu {
    right: 0;
    left: auto;
    text-align: right;
}

/* ---------- Icons that imply direction ---------- */
body.rtl .mdi-chevron-left::before,
body.rtl .mdi-arrow-left::before {
    content: "\F0142"; /* chevron-right */
}
body.rtl .mdi-chevron-right::before,
body.rtl .mdi-arrow-right::before {
    content: "\F0141"; /* chevron-left */
}

/* Generic icon flip helper */
body.rtl .rtl-flip-icon {
    transform: scaleX(-1);
    display: inline-block;
}

/* ---------- Navigation ---------- */
body.rtl .navbar-nav {
    padding-right: 0;
}

/* ---------- Breadcrumb separators ---------- */
body.rtl .breadcrumb-item + .breadcrumb-item {
    padding-right: 0.5rem;
    padding-left: 0;
}
body.rtl .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-right: 0;
    padding-left: 0.5rem;
}

/* ---------- Border radius mirroring for grouped inputs ---------- */
body.rtl .input-group > :first-child {
    border-radius: 0 0.25rem 0.25rem 0;
}
body.rtl .input-group > :last-child {
    border-radius: 0.25rem 0 0 0.25rem;
}
