/* RTL overrides for frontend interface when using Arabic */

/* General RTL adjustments */
html[dir="rtl"] body {
    text-align: right;
}

/* Fix navbar in RTL mode */
html[dir="rtl"] .navbar-nav {
    padding-right: 0;
}

html[dir="rtl"] .navbar-nav .nav-link {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

html[dir="rtl"] .navbar-nav .dropdown-menu {
    right: 0;
    left: auto;
    text-align: right;
}

html[dir="rtl"] .dropdown-item {
    text-align: right;
}

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

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

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

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

/* Fix icons and badges in RTL */
html[dir="rtl"] .bi {
    margin-left: 0.25rem;
    margin-right: 0;
}

html[dir="rtl"] .badge {
    margin-right: 0.25rem;
    margin-left: 0;
}

/* Fix form elements in RTL */
html[dir="rtl"] .form-label {
    text-align: right;
}

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

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

html[dir="rtl"] .input-group > .form-control {
    border-radius: 0 0.25rem 0.25rem 0;
}

html[dir="rtl"] .input-group > .input-group-text {
    border-radius: 0.25rem 0 0 0.25rem;
}

html[dir="rtl"] .input-group > .btn:last-child {
    border-radius: 0.25rem 0 0 0.25rem;
}

html[dir="rtl"] .input-group > .btn:first-child {
    border-radius: 0 0.25rem 0.25rem 0;
}

/* Fix calendar components for RTL */
html[dir="rtl"] .fc-direction-ltr {
    direction: rtl !important;
}

html[dir="rtl"] .fc .fc-toolbar {
    flex-direction: row-reverse;
}

html[dir="rtl"] .fc .fc-toolbar-title {
    text-align: right;
}

html[dir="rtl"] .fc .fc-toolbar-chunk {
    display: flex;
}

html[dir="rtl"] .fc .fc-button-group {
    flex-direction: row-reverse;
}

html[dir="rtl"] .fc-direction-ltr .fc-button-group > .fc-button:not(:first-child) {
    margin-right: -1px;
    margin-left: 0;
    border-radius: 0.25rem 0 0 0.25rem;
}

html[dir="rtl"] .fc-direction-ltr .fc-button-group > .fc-button:not(:last-child) {
    border-radius: 0 0.25rem 0.25rem 0;
}

html[dir="rtl"] .fc-direction-ltr .fc-daygrid-event.fc-event-start,
html[dir="rtl"] .fc-direction-ltr .fc-daygrid-event.fc-event-end {
    margin-right: 2px;
    margin-left: 0;
}

html[dir="rtl"] .fc-h-event .fc-event-main {
    text-align: right;
}

/* Fix modal dialogs for RTL */
html[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

html[dir="rtl"] .modal-footer {
    justify-content: flex-start;
}

/* Fix progress bars for RTL */
html[dir="rtl"] .progress-bar {
    float: right;
}

/* Fix tables for RTL */
html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: right;
}

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

/* Fix for date and time pickers in RTL */
html[dir="rtl"] .flatpickr-calendar {
    direction: rtl;
}

html[dir="rtl"] .flatpickr-current-month {
    right: 7.5%;
    left: auto;
}

html[dir="rtl"] .flatpickr-months .flatpickr-prev-month {
    right: auto;
    left: 0;
}

html[dir="rtl"] .flatpickr-months .flatpickr-next-month {
    right: 0;
    left: auto;
}

/* Fix charts for RTL */
html[dir="rtl"] .chart-container {
    direction: ltr; /* Charts should stay LTR for correct data representation */
}

/* Fix dashboard cards for RTL */
html[dir="rtl"] .card-body {
    text-align: right;
}

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

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

/* Fix list groups for RTL */
html[dir="rtl"] .list-group-item {
    text-align: right;
}

/* Fix pagination for RTL */
html[dir="rtl"] .pagination {
    padding-right: 0;
}

html[dir="rtl"] .page-item:first-child .page-link {
    border-radius: 0 0.25rem 0.25rem 0;
}

html[dir="rtl"] .page-item:last-child .page-link {
    border-radius: 0.25rem 0 0 0.25rem;
}

/* Fix for select2 components in RTL */
html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow {
    left: 1px;
    right: auto;
}

html[dir="rtl"] .select2-results {
    text-align: right;
}

html[dir="rtl"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    float: right;
    margin-right: 0;
    margin-left: 5px;
}

/* Fix for tabs in RTL */
html[dir="rtl"] .nav-tabs {
    padding-right: 0;
}

html[dir="rtl"] .nav-tabs .nav-item {
    margin-left: 2px;
    margin-right: 0;
}

/* Fix accordion for RTL */
html[dir="rtl"] .accordion-button::after {
    margin-left: 0;
    margin-right: auto;
}

/* Fix for alert components in RTL */
html[dir="rtl"] .alert-dismissible {
    padding-right: 1rem;
    padding-left: 4rem;
}

html[dir="rtl"] .alert-dismissible .btn-close {
    left: 0;
    right: auto;
}

/* Responsive tables in RTL */
@media (max-width: 767.98px) {
    html[dir="rtl"] .mobile-table tbody td {
        text-align: left;
        padding-right: 50%;
        padding-left: 0.75rem;
    }
    
    html[dir="rtl"] .mobile-table tbody td:before {
        right: 0.75rem;
        left: auto;
        text-align: right;
        width: 45%;
        padding-right: 0;
        padding-left: 0.5rem;
    }
} 