/* RTL Support for Arabic language */
[dir="rtl"] {
    /* Text alignment */
    text-align: right;
    
    /* Reverse flex direction */
    .flex-row {
        flex-direction: row-reverse;
    }
    
    /* Reverse margins and paddings */
    .ml-auto {
        margin-left: 0 !important;
        margin-right: auto !important;
    }
    
    .mr-auto {
        margin-right: 0 !important;
        margin-left: auto !important;
    }
    
    .ml-1, .ml-2, .ml-3, .ml-4, .ml-5, .ml-6, .ml-8, .ml-10 {
        margin-left: 0 !important;
        margin-right: 0.25rem !important;
    }
    
    .mr-1, .mr-2, .mr-3, .mr-4, .mr-5, .mr-6, .mr-8, .mr-10 {
        margin-right: 0 !important;
        margin-left: 0.25rem !important;
    }
    
    .pl-1, .pl-2, .pl-3, .pl-4, .pl-5, .pl-6, .pl-8, .pl-10 {
        padding-left: 0 !important;
        padding-right: 0.25rem !important;
    }
    
    .pr-1, .pr-2, .pr-3, .pr-4, .pr-5, .pr-6, .pr-8, .pr-10 {
        padding-right: 0 !important;
        padding-left: 0.25rem !important;
    }
    
    /* Reverse borders */
    .border-l {
        border-left: none !important;
        border-right: 1px solid;
    }
    
    .border-r {
        border-right: none !important;
        border-left: 1px solid;
    }
    
    /* Reverse text alignment */
    .text-left {
        text-align: right !important;
    }
    
    .text-right {
        text-align: left !important;
    }
    
    /* Reverse floats */
    .float-left {
        float: right !important;
    }
    
    .float-right {
        float: left !important;
    }
    
    /* Reverse grid columns */
    .grid-cols-1, .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        direction: rtl;
    }
    
    /* Reverse space between */
    .space-x-1 > :not([hidden]) ~ :not([hidden]),
    .space-x-2 > :not([hidden]) ~ :not([hidden]),
    .space-x-3 > :not([hidden]) ~ :not([hidden]),
    .space-x-4 > :not([hidden]) ~ :not([hidden]) {
        --tw-space-x-reverse: 1;
    }
    
    /* Reverse icons */
    .transform {
        transform: scaleX(-1);
    }
    
    /* Dropdown menus */
    .dropdown-menu {
        left: auto;
        right: 0;
    }
    
    /* Tables */
    table th, table td {
        text-align: right;
    }
    
    /* Forms */
    .form-group label {
        text-align: right;
    }
    
    /* Navigation */
    .nav-item {
        float: right;
    }
    
    /* Breadcrumbs */
    .breadcrumb-item {
        float: right;
    }
    
    .breadcrumb-item + .breadcrumb-item::before {
        float: right;
        padding-right: 0;
        padding-left: 0.5rem;
    }
    
    /* Buttons with icons */
    .btn-icon {
        direction: rtl;
    }
    
    /* Sidebar */
    .sidebar {
        right: 0;
        left: auto;
    }
}

/* Font settings for Arabic */
html[lang="ar"] {
    font-family: 'Tajawal', 'Noto Sans Arabic', sans-serif;
}

/* Specific component overrides */
[dir="rtl"] .timetable-grid {
    direction: rtl;
}

[dir="rtl"] .card-header {
    text-align: right;
}

[dir="rtl"] .dropdown-menu-right {
    right: auto;
    left: 0;
}

/* Fix for input groups */
[dir="rtl"] .input-group > .input-group-prepend > .btn,
[dir="rtl"] .input-group > .input-group-prepend > .input-group-text,
[dir="rtl"] .input-group > .input-group-append:not(:last-child) > .btn,
[dir="rtl"] .input-group > .input-group-append:not(:last-child) > .input-group-text,
[dir="rtl"] .input-group > .input-group-append:last-child > .btn:not(:last-child):not(.dropdown-toggle),
[dir="rtl"] .input-group > .input-group-append:last-child > .input-group-text:not(:last-child) {
    border-radius: 0 0.25rem 0.25rem 0;
}

[dir="rtl"] .input-group > .form-control:not(:first-child),
[dir="rtl"] .input-group > .custom-select:not(:first-child) {
    border-radius: 0.25rem 0 0 0.25rem;
}

/* Fix timetable specific styles */
[dir="rtl"] .timetable th,
[dir="rtl"] .timetable td {
    text-align: center !important;
}

/* Fix fixed columns in timetable */
[dir="rtl"] .fixed-column-date {
    left: auto !important;
    right: 0 !important;
}

[dir="rtl"] .fixed-column-total {
    right: auto !important;
    left: 0 !important;
}
