/* RTL Styles for Arabic Language */
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] body {
    font-family: 'Tajawal', 'Amiri', 'Cairo', 'Noto Sans Arabic', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    direction: rtl;
    text-align: right;
}

/* RTL Navbar */
html[dir="rtl"] .navbar-brand {
    margin-left: 0;
    margin-right: auto;
}

html[dir="rtl"] .navbar-nav {
    margin-left: auto;
    margin-right: 0;
}

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

/* RTL Sidebar */
html[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.1);
}

html[dir="rtl"] .sidebar .position-sticky {
    padding-right: 0;
    padding-left: 0;
    width: 100%;
}

html[dir="rtl"] .sidebar .nav-link {
    text-align: right;
    padding: 12px 20px;
    padding-right: 20px;
}

html[dir="rtl"] .sidebar .nav-link i {
    margin-left: 8px;
    margin-right: 0;
    float: right;
}

html[dir="rtl"] .nav.flex-column {
    padding-right: 0;
    margin-right: 0;
    width: 100%;
}

/* RTL Main Content */
html[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: 0;
}

@media (min-width: 768px) {
    html[dir="rtl"] .main-content {
        margin-left: 0;
        margin-right: 16.666667%;
    }
}

@media (min-width: 992px) {
    html[dir="rtl"] .main-content {
        margin-left: 0;
        margin-right: 16.666667%;
    }
}

/* RTL Card Headers - Right alignment for titles, left for badges */
html[dir="rtl"] .card-header.d-flex.justify-content-between {
    flex-direction: row-reverse;
}

html[dir="rtl"] .card-header h5 {
    text-align: right;
    margin-right: 0;
    margin-left: auto;
}

html[dir="rtl"] .card-header .badge {
    margin-left: 0;
    margin-right: auto;
}

/* RTL Icons in headers */
html[dir="rtl"] .card-header h5 i {
    margin-left: 8px;
    margin-right: 0;
}

/* RTL Tables */
html[dir="rtl"] .table {
    direction: rtl;
}

html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: right;
}

html[dir="rtl"] .table thead th:first-child {
    border-top-left-radius: 0;
    border-top-right-radius: 0.375rem;
}

html[dir="rtl"] .table thead th:last-child {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0;
}

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

html[dir="rtl"] .form-control,
html[dir="rtl"] .form-select {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .input-group-text {
    border-left: 1px solid #ced4da;
    border-right: 0;
}

/* RTL Buttons */
html[dir="rtl"] .btn i {
    margin-left: 8px;
    margin-right: 0;
}

html[dir="rtl"] .btn-group {
    direction: ltr; /* Keep button groups LTR for proper functionality */
}

/* RTL File Upload */
html[dir="rtl"] .file-preview .fas {
    margin-left: 8px;
    margin-right: 0;
}

/* RTL Badges and Status */
html[dir="rtl"] .badge {
    direction: rtl;
}

/* RTL Dashboard Stats */
html[dir="rtl"] .stats-card {
    text-align: right;
}

html[dir="rtl"] .stats-card h3 {
    direction: rtl;
}

/* RTL Quick Actions */
html[dir="rtl"] .quick-actions .btn {
    text-align: center; /* Keep centered for better appearance */
}

html[dir="rtl"] .quick-actions .btn i {
    margin: 0 0 8px 0; /* Remove side margins for stacked icons */
}

/* RTL Dropdown Menus */
html[dir="rtl"] .dropdown-menu {
    text-align: right;
    direction: rtl;
}

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

html[dir="rtl"] .dropdown-item i {
    margin-left: 8px;
    margin-right: 0;
    float: right;
}

/* RTL Timeline */
html[dir="rtl"] .timeline {
    padding-left: 0;
    padding-right: 30px;
}

html[dir="rtl"] .timeline::before {
    left: auto;
    right: 15px;
}

html[dir="rtl"] .timeline-item::before {
    left: auto;
    right: -23px;
}

/* RTL Alerts */
html[dir="rtl"] .alert {
    text-align: right;
    direction: rtl;
}

/* RTL Navigation Pills/Tabs */
html[dir="rtl"] .nav-pills .nav-link,
html[dir="rtl"] .nav-tabs .nav-link {
    text-align: right;
}

/* RTL Pagination */
html[dir="rtl"] .pagination {
    direction: ltr; /* Keep pagination LTR for proper functionality */
}

/* RTL Modal */
html[dir="rtl"] .modal-header {
    text-align: right;
}

html[dir="rtl"] .modal-body {
    text-align: right;
    direction: rtl;
}

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

/* Language Switcher */
.language-switcher {
    margin-left: 10px;
}

html[dir="rtl"] .language-switcher {
    margin-left: 0;
    margin-right: 10px;
}

.language-switcher .dropdown-toggle {
    border: none;
    background: transparent;
    color: white;
    font-size: 0.9rem;
}

.language-switcher .dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* RTL specific adjustments for better Arabic text rendering */
html[dir="rtl"] {
    font-feature-settings: "liga", "kern";
    text-rendering: optimizeLegibility;
}

/* Responsive adjustments for RTL */
@media (max-width: 767.98px) {
    html[dir="rtl"] .sidebar {
        position: relative;
        left: auto;
        right: auto;
    }

    html[dir="rtl"] .main-content {
        margin-right: 0;
    }
}