/* RTL Styles for Arabic Language Support */

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

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

/* Navigation and Sidebar RTL */
html[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
}

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

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

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

html[dir="rtl"] .sidebar .nav-link .nav-text {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* Sidebar Wrapper RTL */
html[dir="rtl"] .sidebar-wrapper {
    right: 0;
    left: auto;
}

html[dir="rtl"] #main {
    margin-right: 300px;
    margin-left: 0;
}

/* Sidebar Menu RTL */
html[dir="rtl"] .sidebar-wrapper .menu {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .sidebar-wrapper .menu .sidebar-link {
    text-align: right;
    padding-right: 1rem;
    padding-left: 0.5rem;
    direction: rtl;
}

html[dir="rtl"] .sidebar-wrapper .menu .sidebar-link i,
html[dir="rtl"] .sidebar-wrapper .menu .sidebar-link svg {
    margin-left: 1rem;
    margin-right: 0;
    float: right;
}

html[dir="rtl"] .sidebar-wrapper .menu .sidebar-link span {
    margin-right: 1rem;
    margin-left: 0;
    text-align: right;
}

/* Sidebar Item RTL */
html[dir="rtl"] .sidebar-wrapper .menu .sidebar-item {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .sidebar-wrapper .menu .sidebar-item.has-sub .sidebar-link:after {
    right: auto;
    left: 15px;
    transform: scaleX(-1); /* Flip the chevron for RTL */
}

/* Submenu RTL */
html[dir="rtl"] .sidebar-wrapper .menu .submenu {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .sidebar-wrapper .menu .submenu .submenu-item a {
    text-align: right;
    padding-right: 2rem;
    padding-left: 1rem;
    direction: rtl;
}

html[dir="rtl"] .sidebar-wrapper .menu .submenu .submenu-item a:hover {
    margin-right: 0.3rem;
    margin-left: 0;
}

/* Sidebar Search RTL */
html[dir="rtl"] .sidebar-item.sidebar-search {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .sidebar-item.sidebar-search .form-control {
    text-align: right;
    direction: rtl;
}

/* Header RTL */
html[dir="rtl"] .header {
    right: 0;
    left: auto;
}

html[dir="rtl"] .header .navbar-nav {
    direction: rtl;
}

html[dir="rtl"] .header .navbar-nav .nav-item {
    margin-right: 0;
    margin-left: 1rem;
}

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

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

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

html[dir="rtl"] .input-group {
    direction: rtl;
}

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

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

html[dir="rtl"] .input-group .input-group-text:first-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

html[dir="rtl"] .input-group .form-control:last-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* Buttons RTL */
html[dir="rtl"] .btn-group {
    direction: rtl;
}

html[dir="rtl"] .btn-group .btn:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

html[dir="rtl"] .btn-group .btn:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

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

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

html[dir="rtl"] .table .text-left {
    text-align: right !important;
}

html[dir="rtl"] .table .text-right {
    text-align: left !important;
}

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

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

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

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

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

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

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

html[dir="rtl"] .modal-footer .btn {
    margin-right: 0;
    margin-left: 0.5rem;
}

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

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

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

html[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    content: "\\";
    transform: scaleX(-1);
}

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

html[dir="rtl"] .pagination .page-item:first-child .page-link {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

html[dir="rtl"] .pagination .page-item:last-child .page-link {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

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

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

/* Nav Tabs RTL */
html[dir="rtl"] .nav-tabs {
    direction: rtl;
}

html[dir="rtl"] .nav-tabs .nav-link {
    text-align: right;
}

/* List Groups RTL */
html[dir="rtl"] .list-group {
    text-align: right;
}

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

/* Progress Bars RTL */
html[dir="rtl"] .progress {
    direction: rtl;
}

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

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

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

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

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

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

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

html[dir="rtl"] .dataTables_wrapper .dataTables_length {
    float: right;
    text-align: right;
}

html[dir="rtl"] .dataTables_wrapper .dataTables_filter {
    float: left;
    text-align: left;
}

html[dir="rtl"] .dataTables_wrapper .dataTables_info {
    float: right;
    text-align: right;
}

html[dir="rtl"] .dataTables_wrapper .dataTables_paginate {
    float: left;
    text-align: left;
}

html[dir="rtl"] .dataTables_wrapper .dataTables_paginate .paginate_button {
    margin-right: 0;
    margin-left: 2px;
}

/* Custom Components RTL */
html[dir="rtl"] .language-selector {
    text-align: right;
}

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

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

/* Icons RTL */
html[dir="rtl"] .fa-chevron-left:before {
    content: "\\f054"; /* fa-chevron-right */
}

html[dir="rtl"] .fa-chevron-right:before {
    content: "\\f053"; /* fa-chevron-left */
}

html[dir="rtl"] .fa-arrow-left:before {
    content: "\\f061"; /* fa-arrow-right */
}

html[dir="rtl"] .fa-arrow-right:before {
    content: "\\f060"; /* fa-arrow-left */
}

html[dir="rtl"] .fa-angle-left:before {
    content: "\\f105"; /* fa-angle-right */
}

html[dir="rtl"] .fa-angle-right:before {
    content: "\\f104"; /* fa-angle-left */
}

html[dir="rtl"] .fa-angle-double-left:before {
    content: "\\f101"; /* fa-angle-double-right */
}

html[dir="rtl"] .fa-angle-double-right:before {
    content: "\\f100"; /* fa-angle-double-left */
}

/* Float RTL */
html[dir="rtl"] .float-left {
    float: right !important;
}

html[dir="rtl"] .float-right {
    float: left !important;
}

/* Text Alignment RTL */
html[dir="rtl"] .text-left {
    text-align: right !important;
}

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

/* Margin and Padding RTL */
html[dir="rtl"] .ml-1, html[dir="rtl"] .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ml-2, html[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ml-3, html[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ml-4, html[dir="rtl"] .ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ml-5, html[dir="rtl"] .ms-5 { margin-right: 3rem !important; margin-left: 0 !important; }

html[dir="rtl"] .mr-1, html[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
html[dir="rtl"] .mr-2, html[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
html[dir="rtl"] .mr-3, html[dir="rtl"] .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
html[dir="rtl"] .mr-4, html[dir="rtl"] .me-4 { margin-left: 1.5rem !important; margin-right: 0 !important; }
html[dir="rtl"] .mr-5, html[dir="rtl"] .me-5 { margin-left: 3rem !important; margin-right: 0 !important; }

html[dir="rtl"] .pl-1, html[dir="rtl"] .ps-1 { padding-right: 0.25rem !important; padding-left: 0 !important; }
html[dir="rtl"] .pl-2, html[dir="rtl"] .ps-2 { padding-right: 0.5rem !important; padding-left: 0 !important; }
html[dir="rtl"] .pl-3, html[dir="rtl"] .ps-3 { padding-right: 1rem !important; padding-left: 0 !important; }
html[dir="rtl"] .pl-4, html[dir="rtl"] .ps-4 { padding-right: 1.5rem !important; padding-left: 0 !important; }
html[dir="rtl"] .pl-5, html[dir="rtl"] .ps-5 { padding-right: 3rem !important; padding-left: 0 !important; }

html[dir="rtl"] .pr-1, html[dir="rtl"] .pe-1 { padding-left: 0.25rem !important; padding-right: 0 !important; }
html[dir="rtl"] .pr-2, html[dir="rtl"] .pe-2 { padding-left: 0.5rem !important; padding-right: 0 !important; }
html[dir="rtl"] .pr-3, html[dir="rtl"] .pe-3 { padding-left: 1rem !important; padding-right: 0 !important; }
html[dir="rtl"] .pr-4, html[dir="rtl"] .pe-4 { padding-left: 1.5rem !important; padding-right: 0 !important; }
html[dir="rtl"] .pr-5, html[dir="rtl"] .pe-5 { padding-left: 3rem !important; padding-right: 0 !important; }

/* Border RTL */
html[dir="rtl"] .border-left { border-right: 1px solid #dee2e6 !important; border-left: 0 !important; }
html[dir="rtl"] .border-right { border-left: 1px solid #dee2e6 !important; border-right: 0 !important; }

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

/* Rounded Corners RTL */
html[dir="rtl"] .rounded-left { border-top-right-radius: 0.375rem !important; border-bottom-right-radius: 0.375rem !important; border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }
html[dir="rtl"] .rounded-right { border-top-left-radius: 0.375rem !important; border-bottom-left-radius: 0.375rem !important; border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }

/* Custom Admin Panel RTL */
html[dir="rtl"] .admin-sidebar {
    right: 0;
    left: auto;
}

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

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

html[dir="rtl"] .admin-header .navbar-brand {
    margin-right: 0;
    margin-left: 1rem;
}

html[dir="rtl"] .admin-header .navbar-nav {
    direction: rtl;
}

html[dir="rtl"] .admin-header .navbar-nav .nav-item {
    margin-right: 0;
    margin-left: 0.5rem;
}

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

html[dir="rtl"] .dashboard-card .card-icon {
    left: 1rem;
    right: auto;
}

html[dir="rtl"] .dashboard-card .card-content {
    margin-right: 3rem;
    margin-left: 0;
}

/* Statistics RTL */
html[dir="rtl"] .stat-item {
    text-align: right;
}

html[dir="rtl"] .stat-item .stat-icon {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Charts RTL */
html[dir="rtl"] .chart-container {
    direction: rtl;
}

/* Forms RTL */
html[dir="rtl"] .form-row {
    direction: rtl;
}

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

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

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

html[dir="rtl"] .form-check-label {
    padding-right: 0;
    padding-left: 1.25rem;
}

/* File Upload RTL */
html[dir="rtl"] .file-upload {
    text-align: right;
}

html[dir="rtl"] .file-upload .file-input {
    text-align: right;
}

/* Search Box RTL */
html[dir="rtl"] .search-box {
    direction: rtl;
}

html[dir="rtl"] .search-box .search-input {
    text-align: right;
}

html[dir="rtl"] .search-box .search-icon {
    right: 0.75rem;
    left: auto;
}

/* Notifications RTL */
html[dir="rtl"] .notification-item {
    text-align: right;
}

html[dir="rtl"] .notification-item .notification-icon {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* User Profile RTL */
html[dir="rtl"] .user-profile {
    text-align: right;
}

html[dir="rtl"] .user-profile .user-avatar {
    margin-left: 0.5rem;
    margin-right: 0;
}

html[dir="rtl"] .user-profile .user-info {
    text-align: right;
}

/* Settings Panel RTL */
html[dir="rtl"] .settings-panel {
    text-align: right;
}

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

html[dir="rtl"] .settings-panel .setting-label {
    text-align: right;
}

/* Loading Spinner RTL */
html[dir="rtl"] .loading-spinner {
    direction: rtl;
}

/* Error Messages RTL */
html[dir="rtl"] .error-message {
    text-align: right;
}

html[dir="rtl"] .error-message .error-icon {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Success Messages RTL */
html[dir="rtl"] .success-message {
    text-align: right;
}

html[dir="rtl"] .success-message .success-icon {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Warning Messages RTL */
html[dir="rtl"] .warning-message {
    text-align: right;
}

html[dir="rtl"] .warning-message .warning-icon {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Info Messages RTL */
html[dir="rtl"] .info-message {
    text-align: right;
}

html[dir="rtl"] .info-message .info-icon {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Responsive RTL */
@media (max-width: 768px) {
    html[dir="rtl"] .admin-sidebar {
        transform: translateX(100%);
    }

    html[dir="rtl"] .admin-sidebar.show {
        transform: translateX(0);
    }

    html[dir="rtl"] .admin-main-content {
        margin-right: 0;
    }
    
    html[dir="rtl"] .sidebar-wrapper {
        left: -300px;
        right: auto;
    }
    
    html[dir="rtl"] #main {
        margin-right: 0;
    }
}

/* Additional Sidebar RTL Fixes */
html[dir="rtl"] .sidebar-wrapper .menu .sidebar-item {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

html[dir="rtl"] .sidebar-wrapper .menu .sidebar-link {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    flex-direction: row-reverse;
}

html[dir="rtl"] .sidebar-wrapper .menu .sidebar-link i,
html[dir="rtl"] .sidebar-wrapper .menu .sidebar-link svg {
    order: 2;
}

html[dir="rtl"] .sidebar-wrapper .menu .sidebar-link span {
    order: 1;
}

/* Ensure system_users and role items are visible */
html[dir="rtl"] .sidebar-wrapper .menu .sidebar-item[data-name*="system_users"],
html[dir="rtl"] .sidebar-wrapper .menu .sidebar-item[data-name*="role"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Print RTL */
@media print {
    html[dir="rtl"] * {
        direction: rtl;
        text-align: right;
    }
}
#sidebar.active .sidebar-wrapper{
    right: 0;
    left: unset;
}
#main{
    margin-right: 300px;
    margin-left: unset;
}
ul .navbar-nav{
    margin-right: auto;
}
