html[dir="rtl"] body {
    direction: rtl;
}

html[dir="ltr"] body {
    direction: ltr;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Sidebar follows page direction via flex row (sidebar is first column in DOM) */
@media (min-width: 769px) {
    html[dir="ltr"] .sidebar {
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    html[dir="rtl"] .sidebar {
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    }
}

html[dir="ltr"] .mobile-sidebar {
    right: auto;
    left: -100%;
}

html[dir="ltr"] .mobile-sidebar.active {
    left: 0;
    right: auto;
}

html[dir="ltr"] .mobile-toggle {
    right: auto;
    left: 15px;
}

html[dir="ltr"] main.col-md-9 {
    margin-right: 0 !important;
    margin-left: auto !important;
}

html[dir="rtl"] main.col-md-9 {
    margin-left: 0 !important;
    margin-right: auto !important;
}

html[dir="ltr"] .menu-toggle-icon {
    transform: rotate(90deg);
}

html[dir="ltr"] .menu-section-header.collapsed .menu-toggle-icon {
    transform: rotate(0deg);
}

html[dir="ltr"] .sidebar .nav-link i,
html[dir="ltr"] .mobile-sidebar .nav-link i {
    margin-left: 0;
    margin-right: 10px;
}

html[dir="ltr"] .sidebar .nav-link:hover,
html[dir="ltr"] .sidebar .nav-link.active,
html[dir="ltr"] .mobile-sidebar .nav-link:hover,
html[dir="ltr"] .mobile-sidebar .nav-link.active {
    transform: translateX(5px);
}

html[dir="ltr"] .menu-section-header .menu-toggle-icon {
    margin-right: 0;
    margin-left: 10px;
}

html[dir="rtl"] .menu-section-header.collapsed .menu-toggle-icon {
    transform: rotate(90deg);
}

html[dir="ltr"] .menu-sub-items .nav-item {
    padding-right: 0;
    padding-left: 5px;
}

html[dir="ltr"] .text-start {
    text-align: left !important;
}

html[dir="ltr"] .me-2 {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

html[dir="ltr"] .ms-2 {
    margin-right: 0.5rem !important;
    margin-left: 0 !important;
}

html[dir="ltr"] .dropdown-menu {
    text-align: left;
}

html[dir="ltr"] .student-search-dropdown {
    text-align: left;
}

html[dir="ltr"] .border-left-primary,
html[dir="ltr"] .border-left-success,
html[dir="ltr"] .border-left-info,
html[dir="ltr"] .border-left-warning,
html[dir="ltr"] .border-left-danger,
html[dir="ltr"] .border-left-secondary,
html[dir="ltr"] .border-left-dark,
html[dir="ltr"] .border-left-purple {
    border-left: none !important;
    border-right: 0.25rem solid !important;
}

html[dir="ltr"] .border-left-primary { border-right-color: #4e73df !important; }
html[dir="ltr"] .border-left-success { border-right-color: #1cc88a !important; }
html[dir="ltr"] .border-left-info { border-right-color: #36b9cc !important; }
html[dir="ltr"] .border-left-warning { border-right-color: #f6c23e !important; }
html[dir="ltr"] .border-left-danger { border-right-color: #e74a3b !important; }
html[dir="ltr"] .border-left-secondary { border-right-color: #858796 !important; }
html[dir="ltr"] .border-left-dark { border-right-color: #5a5c69 !important; }
html[dir="ltr"] .border-left-purple { border-right-color: #6f42c1 !important; }

html[dir="ltr"] .lang-switch .btn.active {
    font-weight: bold;
}

/* Bootstrap form-check/radio/checkbox: align control to the right in RTL */
html[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.5em;
}

html[dir="rtl"] .form-check .form-check-input {
    float: right;
    margin-left: 0;
    margin-right: -1.5em;
}

html[dir="rtl"] .form-check-inline {
    margin-right: 0;
    margin-left: 1rem;
}

html[dir="rtl"] .form-switch {
    padding-left: 0;
    padding-right: 2.5em;
}

html[dir="rtl"] .form-switch .form-check-input {
    margin-left: 0;
    margin-right: -2.5em;
    background-position: right center;
}

html[dir="rtl"] .form-switch .form-check-input:checked {
    background-position: left center;
}

html[dir="rtl"] .form-check-reverse {
    padding-left: 1.5em;
    padding-right: 0;
    text-align: left;
}

html[dir="rtl"] .form-check-reverse .form-check-input {
    float: left;
    margin-left: -1.5em;
    margin-right: 0;
}

html[dir="rtl"] .form-switch.form-check-reverse {
    padding-left: 2.5em;
    padding-right: 0;
}

html[dir="rtl"] .form-switch.form-check-reverse .form-check-input {
    margin-left: -2.5em;
    margin-right: 0;
}

/* Bootstrap input-group: fix joined border-radius in RTL (LTR Bootstrap CSS loaded) */
html[dir="rtl"] .input-group:not(.has-validation) > .form-floating:not(:last-child) > .form-control,
html[dir="rtl"] .input-group:not(.has-validation) > .form-floating:not(:last-child) > .form-select,
html[dir="rtl"] .input-group:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),
html[dir="rtl"] .input-group.has-validation > .form-floating:nth-last-child(n+3) > .form-control,
html[dir="rtl"] .input-group.has-validation > .form-floating:nth-last-child(n+3) > .form-select,
html[dir="rtl"] .input-group.has-validation > :nth-last-child(n+3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: var(--bs-border-radius);
    border-bottom-right-radius: var(--bs-border-radius);
}

html[dir="rtl"] .input-group.input-group-sm:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),
html[dir="rtl"] .input-group.input-group-sm.has-validation > :nth-last-child(n+3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) {
    border-top-right-radius: var(--bs-border-radius-sm);
    border-bottom-right-radius: var(--bs-border-radius-sm);
}

html[dir="rtl"] .input-group.input-group-lg:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),
html[dir="rtl"] .input-group.input-group-lg.has-validation > :nth-last-child(n+3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) {
    border-top-right-radius: var(--bs-border-radius-lg);
    border-bottom-right-radius: var(--bs-border-radius-lg);
}

html[dir="rtl"] .input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback),
html[dir="rtl"] .input-group > .form-floating:not(:first-child) > .form-control,
html[dir="rtl"] .input-group > .form-floating:not(:first-child) > .form-select {
    margin-left: 0;
    margin-right: calc(var(--bs-border-width) * -1);
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--bs-border-radius);
    border-bottom-left-radius: var(--bs-border-radius);
}

html[dir="rtl"] .input-group.input-group-sm > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    border-top-left-radius: var(--bs-border-radius-sm);
    border-bottom-left-radius: var(--bs-border-radius-sm);
}

html[dir="rtl"] .input-group.input-group-lg > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    border-top-left-radius: var(--bs-border-radius-lg);
    border-bottom-left-radius: var(--bs-border-radius-lg);
}

/* Bootstrap form-select: move dropdown arrow to the left in RTL */
html[dir="rtl"] .form-select {
    padding: 0.375rem 0.75rem 0.375rem 2.25rem;
    background-position: left 0.75rem center;
}

html[dir="rtl"] .form-select-sm {
    padding-right: 0.5rem;
}

html[dir="rtl"] .form-select-lg {
    padding-right: 1rem;
}

html[dir="rtl"] .form-select[multiple],
html[dir="rtl"] .form-select[size]:not([size="1"]) {
    padding-left: 0.75rem;
    background-image: none;
}
