/* rtl-fixes.css — minimal RTL corrections for the standard (LTR) Bootstrap 5
   build when the document is dir="rtl" (Arabic). Bootstrap's logical properties
   handle most things; these patch the few physical ones that don't mirror. */

/* ── Consistent page spacing. Converted-to-Bootstrap screens lost app.css's
   per-screen padding, so guarantee breathing room on every page + common blocks. */
.page.active {
    padding: 22px 26px;
}
@media (max-width: 575.98px) {
    .page.active {
        padding: 16px 14px;
    }
}
/* spacing between stacked BS cards/sections inside a page */
.page .card,
.page .mk-card,
.page .alert,
.page .table-responsive {
    margin-bottom: 1rem;
}
/* filter chip bars need a gap before the list below them */
.page .chips,
.page .tabs,
.page .nav-pills {
    margin-bottom: 1rem;
}
.page .btn {
    margin-bottom: 0.15rem;
}
/* .page owns the padding now → strip .content's so it doesn't double up */
.content {
    padding-inline: 0 !important;
    padding-top: 0 !important;
    padding-bottom: calc(104px + env(safe-area-inset-bottom)) !important;
}

/* Topbar: app.css used negative margins that assumed .content had padding (now
   removed). Reset to a clean full-width sticky bar. */
.topbar {
    margin: 0 !important;
    padding: 10px 22px !important;
    position: sticky !important;
    top: 0;
    z-index: 1030;
}

/* ── Fixed sidebar (app.css uses position:sticky which breaks when the scroll
   root isn't the flex parent). Pin it fixed and offset the content. RTL-aware. */
#sidebar {
    position: fixed !important;
    top: 0;
    inset-inline-start: 0;
    height: 100vh;
    z-index: 1040;
}
.content {
    margin-inline-start: 248px; /* = sidebar width */
}
@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    [dir='rtl'] #sidebar {
        transform: translateX(100%);
    }
    #sidebar.open {
        transform: none !important;
    }
    .content {
        margin-inline-start: 0;
    }
}

[dir='rtl'] {
    text-align: right;
}

/* float/text utilities flip */
[dir='rtl'] .text-start {
    text-align: right !important;
}
[dir='rtl'] .text-end {
    text-align: left !important;
}
[dir='rtl'] .float-start {
    float: right !important;
}
[dir='rtl'] .float-end {
    float: left !important;
}

/* margin/padding start|end already mirror in BS5 (ms-/me-/ps-/pe-), but the
   legacy ml-/mr- (if any survive) do not — patch the common ones. */
[dir='rtl'] .me-auto {
    margin-right: 0 !important;
    margin-left: auto !important;
}
[dir='rtl'] .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* dropdowns / list groups: align to the right edge */
[dir='rtl'] .dropdown-menu-end {
    --bs-position: start;
}
[dir='rtl'] .list-group {
    text-align: right;
}

/* input groups: keep visual order natural in RTL */
[dir='rtl']
    .input-group
    > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(
        .invalid-feedback
    ) {
    margin-right: -1px;
    margin-left: 0;
}

/* modal close button to the left in RTL */
[dir='rtl'] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

/* offcanvas/sidebar slides from the right in RTL */
[dir='rtl'] .offcanvas-start {
    right: 0;
    left: auto;
    transform: translateX(100%);
}
[dir='rtl'] .offcanvas-start.show {
    transform: none;
}
