/* 
 * RTL (Right-to-Left) Support Stylesheet
 * This file contains all RTL-specific styles for Arabic and other RTL languages
 * Updated: 2026-04-23 - Consolidated and removed conflicts
 */

/* Global RTL Settings */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* Layout Adjustments */
[dir="rtl"] .layout-wrapper,
[dir="rtl"] .layout-container,
[dir="rtl"] .layout-page,
[dir="rtl"] .content-wrapper {
    direction: rtl;
}

/* ========================================
   RTL SIDEBAR POSITIONING
   ======================================== */

/* Desktop - sidebar on right */
@media (min-width: 1200px) {
    [dir="rtl"] .layout-menu {
        right: 0 !important;
        left: auto !important;
    }
    
    [dir="rtl"] .layout-page {
        margin-right: 260px !important;
        margin-left: 0 !important;
        padding-right: 0 !important;
        padding-left: 0 !important;
    }
}

/* Mobile - sidebar overlay from right */
@media (max-width: 1199.98px) {
    [dir="rtl"] .layout-menu {
        right: 0 !important;
        left: auto !important;
        transform: translate3d(100%, 0, 0) !important;
    }
    
    [dir="rtl"].layout-menu-expanded .layout-menu,
    [dir="rtl"] .layout-menu-expanded .layout-menu {
        transform: translate3d(0, 0, 0) !important;
    }
}

/* ========================================
   RTL NAVBAR AND SPACING
   ======================================== */

[dir="rtl"] .navbar-nav {
    padding-right: 0;
}

[dir="rtl"] .navbar-nav .nav-item {
    direction: rtl;
}

[dir="rtl"] .navbar-nav-right {
    flex-direction: row-reverse;
}

/* RTL spacing utilities */
[dir="rtl"] .ms-auto {
    margin-right: auto !important;
    margin-left: 0 !important;
}

[dir="rtl"] .me-3 {
    margin-left: 1rem !important;
    margin-right: 0 !important;
}

[dir="rtl"] .me-2 {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

[dir="rtl"] .me-1 {
    margin-left: 0.25rem !important;
    margin-right: 0 !important;
}

[dir="rtl"] .ms-3 {
    margin-right: 1rem !important;
    margin-left: 0 !important;
}

[dir="rtl"] .ms-2 {
    margin-right: 0.5rem !important;
    margin-left: 0 !important;
}

/* Dropdown RTL Adjustments */
[dir="rtl"] .dropdown-menu {
    text-align: right;
}

[dir="rtl"] .dropdown-menu-end {
    right: auto;
    left: 0;
}

[dir="rtl"] .dropdown-menu-start {
    right: 0;
    left: auto;
}

/* Language Dropdown */
[dir="rtl"] .language-dropdown {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .language-dropdown .dropdown-item {
    text-align: right;
}

[dir="rtl"] .language-dropdown .dropdown-item a {
    direction: rtl;
}

/* Card RTL Adjustments */
[dir="rtl"] .card-body {
    text-align: right;
}

[dir="rtl"] .card-header {
    text-align: right;
}

/* Table RTL Adjustments */
[dir="rtl"] .table {
    direction: rtl;
}

[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

/* ========================================
   RTL FORMS AND COMPONENTS
   ======================================== */

/* Form RTL Adjustments */
[dir="rtl"] .form-control,
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] textarea {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .form-label {
    text-align: right;
}

/* Card RTL Adjustments */
[dir="rtl"] .card-body,
[dir="rtl"] .card-header {
    text-align: right;
}

/* Button RTL Adjustments */
[dir="rtl"] .btn {
    direction: rtl;
}

[dir="rtl"] .btn i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* ========================================
   RTL COMPREHENSIVE FIXES - User Management
   ======================================== */

/* Select2 RTL */
[dir="rtl"] .select2-container {
    text-align: right !important;
    direction: rtl !important;
}
[dir="rtl"] .select2-container .select2-selection--single .select2-selection__rendered {
    padding-right: 12px !important;
    padding-left: 20px !important;
    text-align: right !important;
}
[dir="rtl"] .select2-container .select2-selection--single .select2-selection__arrow {
    right: auto !important;
    left: 1px !important;
}
[dir="rtl"] .select2-container .select2-selection--multiple .select2-selection__choice {
    float: right !important;
    margin-left: 5px !important;
    margin-right: 0 !important;
}
[dir="rtl"] .select2-container .select2-search--inline {
    float: right !important;
}
[dir="rtl"] .select2-results__option {
    text-align: right !important;
    direction: rtl !important;
}
[dir="rtl"] .select2-dropdown {
    direction: rtl !important;
}

/* DataTable RTL */
[dir="rtl"] .bootstrap-table .fixed-table-container.fixed-height .fixed-table-body {
    direction: rtl;
}
[dir="rtl"] .bootstrap-table .table th, 
[dir="rtl"] .bootstrap-table .table td {
    text-align: right !important;
}
[dir="rtl"] .pagination {
    direction: ltr;
    justify-content: flex-start !important;
}
[dir="rtl"] .pagination .page-item:first-child .page-link {
    border-radius: 0 0.25rem 0.25rem 0 !important;
}
[dir="rtl"] .pagination .page-item:last-child .page-link {
    border-radius: 0.25rem 0 0 0.25rem !important;
}

/* Input Group RTL */
[dir="rtl"] .input-group:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) {
    border-radius: 0 0.375rem 0.375rem 0 !important;
}
[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 !important;
    border-radius: 0.375rem 0 0 0.375rem !important;
}
[dir="rtl"] .input-group-text {
    border-radius: 0 0.375rem 0.375rem 0 !important;
}
[dir="rtl"] .input-group > .form-control:not(:first-child) {
    border-radius: 0.375rem 0 0 0.375rem !important;
}

/* Modal RTL */
[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem 0 !important;
}
[dir="rtl"] .modal-footer {
    justify-content: flex-start !important;
}

/* Form Check RTL */
[dir="rtl"] .form-check {
    padding-right: 1.5em !important;
    padding-left: 0 !important;
}
[dir="rtl"] .form-check .form-check-input {
    float: right !important;
    margin-right: -1.5em !important;
    margin-left: 0 !important;
}
[dir="rtl"] .form-switch {
    padding-right: 2.5em !important;
}
[dir="rtl"] .form-switch .form-check-input {
    margin-right: -2.5em !important;
}

/* Toastr RTL */
[dir="rtl"] .toast {
    direction: rtl !important;
    text-align: right !important;
}
[dir="rtl"] .toast-title {
    direction: rtl !important;
}
[dir="rtl"] #toast-container > div {
    direction: rtl !important;
    text-align: right !important;
}
[dir="rtl"] #toast-container > .toast:before {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

/* SweetAlert2 RTL */
[dir="rtl"] .swal2-popup {
    direction: rtl !important;
}
[dir="rtl"] .swal2-actions {
    direction: ltr !important;
}

/* Dropdown Menu RTL */
[dir="rtl"] .dropdown-menu {
    text-align: right !important;
}
[dir="rtl"] .dropdown-item i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

/* Breadcrumb RTL */
[dir="rtl"] .breadcrumb-item + .breadcrumb-item {
    padding-right: 0.5rem !important;
    padding-left: 0 !important;
}
[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    float: right !important;
    padding-right: 0 !important;
    padding-left: 0.5rem !important;
}

/* Nav Tabs RTL */
[dir="rtl"] .nav-tabs .nav-link {
    margin-right: 0 !important;
    margin-left: 0.125rem !important;
}

/* Alert Icon RTL */
[dir="rtl"] .alert i,
[dir="rtl"] .alert .alert-icon {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

/* Badge RTL */
[dir="rtl"] .badge i {
    margin-left: 0.25rem !important;
    margin-right: 0 !important;
}

/* Table RTL */
[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right !important;
}

/* List Group RTL */
[dir="rtl"] .list-group {
    padding-right: 0 !important;
}

/* Accordion RTL */
[dir="rtl"] .accordion-body {
    text-align: right !important;
}

/* Signature Pad RTL */
[dir="rtl"] .signature-wrapper canvas {
    direction: ltr !important;
}

/* File Upload RTL */
[dir="rtl"] .file-upload-wrapper {
    direction: rtl !important;
}

/* Custom Scrollbar for RTL */
[dir="rtl"] ::-webkit-scrollbar {
    direction: ltr;
}

/* Action Buttons in Tables RTL */
[dir="rtl"] .btn-group .btn:first-child {
    border-radius: 0 0.25rem 0.25rem 0 !important;
}
[dir="rtl"] .btn-group .btn:last-child {
    border-radius: 0.25rem 0 0 0.25rem !important;
}
[dir="rtl"] .btn-group > .btn:not(:first-child) {
    border-radius: 0 !important;
}

/* Progress Bar RTL */
[dir="rtl"] .progress-bar {
    float: right !important;
}

/* Spinner/Icon alignment in RTL buttons */
[dir="rtl"] .btn .bx,
[dir="rtl"] .btn .bx-spin {
    display: inline-block;
    vertical-align: middle;
}

/* Fix for Modal footer in RTL */
[dir="rtl"] .modal-footer > :not(:last-child) {
    margin-left: 0.5rem;
    margin-right: 0;
}
[dir="rtl"] .modal-footer > :not(:first-child) {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* Offcanvas RTL */
[dir="rtl"] .offcanvas-end {
    right: auto !important;
    left: 0 !important;
    transform: translateX(100%) !important;
}
[dir="rtl"] .offcanvas.show.offcanvas-end {
    transform: none !important;
}
