/* RTL (Right-to-Left) Layout Support for Arabic */

/* Base RTL direction */
html[dir="rtl"],
body.rtl {
    direction: rtl;
    text-align: right;
}

/* Flip layout margins: Bootstrap is the LTR build, so ms-* (start) and me-* (end)
   must move to the other side, keeping the same size */
body.rtl .ms-1,
body.rtl .ms-2,
body.rtl .ms-3,
body.rtl .ms-4,
body.rtl .ms-5 {
    margin-left: 0 !important;
}

body.rtl .ms-1 { margin-right: .25rem !important; }
body.rtl .ms-2 { margin-right: .5rem !important; }
body.rtl .ms-3 { margin-right: 1rem !important; }
body.rtl .ms-4 { margin-right: 1.5rem !important; }
body.rtl .ms-5 { margin-right: 3rem !important; }

body.rtl .me-1,
body.rtl .me-2,
body.rtl .me-3,
body.rtl .me-4,
body.rtl .me-5 {
    margin-right: 0 !important;
}

body.rtl .me-1 { margin-left: .25rem !important; }
body.rtl .me-2 { margin-left: .5rem !important; }
body.rtl .me-3 { margin-left: 1rem !important; }
body.rtl .me-4 { margin-left: 1.5rem !important; }
body.rtl .me-5 { margin-left: 3rem !important; }

/* Navigation RTL adjustments */
body.rtl .top-navbar .nav-container {
    flex-direction: row-reverse;
}

body.rtl .desktop-nav {
    flex-direction: row-reverse;
}

body.rtl .nav-brand {
    flex-direction: row-reverse;
}

/* Mobile menu RTL */
body.rtl .mobile-menu-content {
    left: 0;
    right: auto;
    transform: translateX(-100%);
}

body.rtl .mobile-menu.active .mobile-menu-content {
    transform: translateX(0);
}

body.rtl .mobile-nav-item {
    flex-direction: row-reverse;
    text-align: right;
}

body.rtl .mobile-nav-item:hover {
    transform: translateX(-5px);
}

body.rtl .menu-close {
    left: 1rem;
    right: auto;
}

/* Form controls RTL */
body.rtl input,
body.rtl textarea,
body.rtl select {
    text-align: right;
}

body.rtl .form-label {
    text-align: right;
}

/* Tables RTL */
body.rtl table {
    direction: rtl;
}

body.rtl th,
body.rtl td {
    text-align: right;
}

/* Buttons and icons RTL */
body.rtl .btn i,
body.rtl .btn .bi {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Dropdown menus RTL */
body.rtl .dropdown-menu {
    text-align: right;
}

/* Cards and panels RTL */
body.rtl .card-body {
    text-align: right;
}

/* Lists RTL */
body.rtl ul,
body.rtl ol {
    padding-right: 2rem;
    padding-left: 0;
}

/* Syncfusion Grid RTL support */
body.rtl .e-grid {
    direction: rtl;
}

body.rtl .e-grid .e-headercell,
body.rtl .e-grid .e-rowcell {
    text-align: right;
}

/* Footer RTL */
body.rtl footer .row {
    flex-direction: row-reverse;
}

/* Language selector specific RTL */
body.rtl .language-selector {
    direction: ltr;
    /* Keep selector LTR for consistency */
}

body.rtl .language-selector .dropdown-menu {
    left: 0;
    right: auto;
}

/* Modals RTL Support */
body.rtl .modal-header {
    display: flex;
    justify-content: space-between;
}

body.rtl .modal-header .btn-close {
    margin-left: -.5rem !important;
    margin-right: auto !important;
}