html[dir="rtl"],
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
    font-family: "Tajawal", "Public Sans", sans-serif;
}

/* Brand color override: dark blue */
:root {
    --bs-primary: #0d3b8e;
    --bs-primary-rgb: 13, 59, 142;
    --bs-link-color: #0d3b8e;
    --bs-link-hover-color: #0a2f72;
}

html[dir="rtl"] .btn-primary,
html[dir="rtl"] .bg-primary {
    background-color: #0d3b8e !important;
    border-color: #0d3b8e !important;
}

html[dir="rtl"] .btn-outline-primary {
    color: #0d3b8e !important;
    border-color: #0d3b8e !important;
}

html[dir="rtl"] .btn-outline-primary:hover {
    background-color: #0d3b8e !important;
    color: #fff !important;
}

html[dir="rtl"] .text-primary {
    color: #0d3b8e !important;
}

html[dir="rtl"] .menu-link,
html[dir="rtl"] .navbar-nav .nav-link,
html[dir="rtl"] .form-label,
html[dir="rtl"] .form-check-label,
html[dir="rtl"] .card-body {
    text-align: right;
}

html[dir="rtl"] .layout-menu .menu-link > div {
    margin-right: 0.5rem;
}

/* Keep main sidebar on the right in RTL */
html[dir="rtl"] .layout-menu {
    right: 0;
    left: auto;
}

html[dir="rtl"] .layout-page,
html[dir="rtl"] .content-wrapper {
    direction: rtl;
}

/* Desktop: content should leave space for right sidebar */
@media (min-width: 1200px) {
    html[dir="rtl"] .layout-menu-fixed:not(.layout-menu-collapsed) .layout-page,
    html[dir="rtl"] .layout-menu-fixed-offcanvas:not(.layout-menu-collapsed) .layout-page {
        padding-right: 16.25rem !important;
        padding-left: 0 !important;
    }

    html[dir="rtl"] .layout-menu-fixed.layout-menu-collapsed .layout-page,
    html[dir="rtl"] .layout-menu-fixed-offcanvas.layout-menu-collapsed .layout-page {
        padding-right: 5.25rem !important;
        padding-left: 0 !important;
    }

    html[dir="rtl"] .layout-content-navbar .content-wrapper {
        width: 100%;
        max-width: 100%;
    }

    /* Keep detached navbar aligned with RTL sidebar offsets */
    html[dir="rtl"] .layout-navbar-fixed .layout-navbar.navbar-detached {
        width: calc(100% - (1.625rem * 2) - 16.25rem);
    }

    html[dir="rtl"] .layout-navbar-fixed.layout-menu-collapsed .layout-navbar.navbar-detached {
        width: calc(100% - (1.625rem * 2) - 5.25rem);
    }
}

/* Tablet/Mobile: collapsed menu should slide from the right */
@media (max-width: 1199.98px) {
    html[dir="rtl"] .layout-menu {
        transform: translateX(100%);
        right: 0;
        left: auto;
    }

    html[dir="rtl"] .layout-menu-expanded .layout-menu {
        transform: translateX(0);
    }

    html[dir="rtl"] .layout-page {
        padding-right: 0;
        padding-left: 0;
    }

    html[dir="rtl"] .layout-overlay {
        right: 0;
        left: auto;
    }
}

html[dir="rtl"] .layout-navbar .navbar-nav {
    margin-right: 0;
    margin-left: auto;
}

/* Keep user actions block pinned to far-left in RTL navbar */
html[dir="rtl"] .layout-navbar .navbar-user-actions {
    margin-right: auto !important;
    margin-left: 0 !important;
}

html[dir="rtl"] .form-check .form-check-input {
    float: right;
    margin-right: 0;
    margin-left: 0.5rem;
}

html[dir="rtl"] .form-check {
    padding-right: 1.5em;
    padding-left: 0;
}

html[dir="rtl"] .input-group > .form-control {
    border-radius: 0 0.375rem 0.375rem 0;
}

html[dir="rtl"] .input-group > .input-group-text {
    border-radius: 0.375rem 0 0 0.375rem;
}

/* Global table spacing/readability */
html[dir="rtl"] .table > :not(caption) > * > * {
    padding: 0.95rem 0.85rem;
    vertical-align: middle;
}

/* DataTables: keep header cells centered for better readability */
html[dir="rtl"] .dataTables_wrapper table.dataTable thead th,
html[dir="rtl"] .dataTables_wrapper table.dataTable thead td {
    text-align: center !important;
}
