/* General RTL adjustments */
body {
    direction: rtl;
    text-align: right;
    font-family: 'Vazirmatn', 'IRANSans', sans-serif; /* Prioritize Persian fonts */
    background-color: #f8f9fa; /* Light background */
}

/* Typography */
h1, h2, h3, h4, h5, h6, .font-vazirmatn {
    font-family: 'Vazirmatn', 'IRANSans', sans-serif;
}

/* Main Container */
.container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

/* Dashboard Header */
.dashboard-header {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,.05);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.dashboard-header .form-control {
    border-radius: 5px;
    border-color: #ced4da;
}

.dashboard-header .btn-primary {
    background-color: #6f42c1; /* Purple primary color */
    border-color: #6f42c1;
    font-weight: bold;
}

.dashboard-header .btn-primary:hover {
    background-color: #5a35a0;
    border-color: #5a35a0;
}

/* User Table */
.user-table-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,.05);
    overflow-x: auto; /* For responsive tables */
}

.table {
    margin-bottom: 0; /* Remove default table margin */
}

.table thead th {
    background-color: #f2f2f7;
    color: #495057;
    font-weight: bold;
    border-bottom: 2px solid #dee2e6;
    vertical-align: middle;
    padding: 12px 15px;
    white-space: nowrap;
}

.table tbody tr {
    border-bottom: 1px solid #e9ecef;
}

.table tbody tr:last-child {
    border-bottom: none;
}

.table tbody td {
    padding: 12px 15px;
    vertical-align: middle;
    white-space: nowrap;
}

/* Sortable headers */
.sortable-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Align text to right in RTL */
}

.sortable-header i {
    margin-right: 5px; /* Space between text and icon in RTL */
    margin-left: 0;
    font-size: 0.8em;
    color: #adb5bd;
}

.sortable-header.asc i.fa-sort-up {
    color: #6f42c1;
}

.sortable-header.desc i.fa-sort-down {
    color: #6f42c1;
}

/* Badges */
.badge {
    padding: 0.5em 0.75em;
    border-radius: 0.35rem;
    font-weight: bold;
    font-size: 0.85em;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-secondary {
    background-color: #e2e3e5;
    color: #383d41;
}

.badge-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Kebab menu */
.dropdown-toggle::after {
    display: none; /* Hide default caret */
}

.dropdown-menu {
    text-align: right; /* Align dropdown items to right in RTL */
    left: auto !important; /* Override Bootstrap's left positioning */
    right: 0 !important; /* Position dropdown to the right */
}

/* Pagination */
.pagination {
    justify-content: center;
    padding: 20px 0;
    margin-bottom: 0;
}

.page-item.active .page-link {
    background-color: #6f42c1;
    border-color: #6f42c1;
}

.page-link {
    color: #6f42c1;
}

.page-link:hover {
    color: #5a35a0;
}

/* Modal Form */
.modal-header {
    border-bottom: 1px solid #dee2e6;
    padding: 15px 20px;
    flex-direction: row-reverse; /* RTL header */
}

.modal-title {
    font-weight: bold;
    color: #343a40;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    font-weight: bold;
    color: #495057;
    margin-bottom: 0.5rem;
}

.form-control {
    border-radius: 5px;
    border-color: #ced4da;
}

.form-check-input:checked {
    background-color: #6f42c1;
    border-color: #6f42c1;
}

/* Toggle Switch */
.form-check.form-switch {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Align switch to the right in RTL */
    padding-right: 2.5em; /* Adjust padding for switch */
    padding-left: 0;
}

.form-check.form-switch .form-check-input {
    margin-left: 0.75em; /* Space between switch and label in RTL */
    margin-right: -2.25em; /* Adjust input position */
    float: none; /* Remove float */
}

.form-check-label {
    margin-bottom: 0;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    padding: 15px 20px;
    justify-content: flex-start; /* Align buttons to the right in RTL */
}

.modal-footer .btn {
    margin-left: 10px; /* Space between buttons in RTL */
    margin-right: 0;
}

.modal-footer .btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
}

.modal-footer .btn-secondary:hover {
    background-color: #5a6268;
    border-color: #5a6268;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }
    .dashboard-header .input-group,
    .dashboard-header .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    .dashboard-header .btn {
        margin-bottom: 0;
    }
    .dashboard-header .input-group {
        order: 1; /* Search bar first */
    }
    .dashboard-header .d-flex {
        order: 2; /* Filters and add button second */
        width: 100%;
        justify-content: space-between;
    }
    .dashboard-header .d-flex > * {
        flex-grow: 1;
        margin-left: 5px;
        margin-right: 5px;
    }
    .dashboard-header .d-flex > *:last-child {
        margin-left: 0;
    }
    .dashboard-header .d-flex > *:first-child {
        margin-right: 0;
    }
}
