/* ══════════════════════════════════════════════════════════════
   AM Business Admin Panel – CSS
   Dark/Light Themes  •  RTL/LTR Support  •  Modern UI
   ══════════════════════════════════════════════════════════════ */

/* ──────────── Reset & Variables ──────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light Theme */
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --bg-hover: #f1f5f9;
    --bg-badge: #e0e7ff;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;
    --text-inverse: #ffffff;

    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #e0e7ff;
    --accent-soft: rgba(99, 102, 241, 0.1);

    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;

    --sidebar-width: 270px;
    --topbar-height: 70px;
    --font-sans: 'Inter', 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ──────────── Dark Theme ──────────── */
.theme-dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #0c1222;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --bg-hover: #334155;
    --bg-badge: #312e81;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;

    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: #312e81;
    --accent-soft: rgba(129, 140, 248, 0.15);

    --success-light: #064e3b;
    --warning-light: #78350f;
    --danger-light: #7f1d1d;
    --info-light: #1e3a5f;

    --border: #334155;
    --border-light: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* ──────────── Base ──────────── */
html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

/* ──────────── Layout ──────────── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ──────────── Sidebar ──────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    inset-inline-start: 0;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition), background var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    color: #fff;
    letter-spacing: -0.5px;
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-sidebar);
    font-size: 1.3rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section {
    padding: 16px 14px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.3);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-sidebar);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}

.nav-item i {
    font-size: 1.2rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-badge {
    margin-inline-start: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ──────────── Main Content ──────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-right: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin var(--transition);
}

/* ──────────── Top Bar ──────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    transition: background var(--transition), border var(--transition);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1.2rem;
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.page-heading {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
}

.topbar-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
}

/* ──────────── Dropdown ──────────── */
.dropdown { position: relative; }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 170px;
    padding: 6px;
    display: none;
    z-index: 200;
}

.dropdown-menu.show { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: background var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ──────────── Page Content ──────────── */
.page-content {
    flex: 1;
    padding: 28px;
}

/* ──────────── Cards ──────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* ──────────── Dashboard Stats ──────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: var(--accent-light); color: var(--accent); }

.stat-info h4 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-info p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ──────────── Tables ──────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 13px 18px;
    text-align: start;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
}

table th {
    background: var(--bg-input);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

table tr:hover td {
    background: var(--bg-hover);
}

table td {
    color: var(--text-primary);
}

/* ──────────── Buttons ──────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.btn-group {
    display: flex;
    gap: 6px;
}

/* ──────────── Forms ──────────── */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;
    padding-right: 36px;
    padding-left: 14px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 20px;
}

/* ──────────── Tabs ──────────── */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-secondary);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ──────────── Badges ──────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-accent { background: var(--accent-light); color: var(--accent); }

/* ──────────── Toasts ──────────── */
.toast-container {
    position: fixed;
    top: 20px;
    inset-inline-end: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    transition: all 0.3s ease;
}

.toast-hide {
    opacity: 0;
    transform: translateX(20px);
}

.toast-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-message {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ──────────── Modal ──────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

/* ──────────── Empty State ──────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 20px;
}

/* ──────────── Image Preview ──────────── */
.image-preview {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 2px solid var(--border);
}

/* ──────────── Responsive ──────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close-btn {
        display: flex;
    }

    .main-content {
        margin-inline-start: 0;
        margin-left: 0;
        margin-right: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .page-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 16px;
    }

    .card-header {
        padding: 16px;
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    [dir="rtl"] .card-header {
        align-items: flex-end;
    }

    .tabs {
        overflow-x: auto;
    }

    table th, table td {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}

/* ──────────── Login Page ──────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    color: #fff;
    margin: 0 auto 20px;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.login-card .form-group {
    text-align: start;
}

.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    margin-top: 8px;
}

.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.88rem;
    font-weight: 500;
    text-align: start;
}

/* ──────────── Scrollbar ──────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ══════════════════════════════════════════════════════════════
   RTL Adjustments for Farsi (fa)
   Uses BOTH logical AND physical properties for maximum compat
   ══════════════════════════════════════════════════════════════ */

/* ── Font ── */
[dir="rtl"] {
    font-family: 'Vazirmatn', 'Inter', sans-serif;
}

[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3,
[dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6,
[dir="rtl"] p, [dir="rtl"] span, [dir="rtl"] label,
[dir="rtl"] td, [dir="rtl"] th, [dir="rtl"] a,
[dir="rtl"] input, [dir="rtl"] textarea, [dir="rtl"] select {
    font-family: 'Vazirmatn', 'Inter', sans-serif;
}

/* ── Sidebar: move to RIGHT side ── */
[dir="rtl"] .sidebar {
    left: auto !important;
    right: 0 !important;
}

/* ── Sidebar Logo ── */
[dir="rtl"] .sidebar-logo {
    flex-direction: row-reverse;
    text-align: right;
}

/* ── Sidebar Nav Items ── */
[dir="rtl"] .nav-item {
    flex-direction: row-reverse;
    text-align: right;
    justify-content: flex-end;
}

[dir="rtl"] .nav-item i {
    margin-left: 0;
    margin-right: 0;
}

[dir="rtl"] .nav-badge {
    margin-inline-start: auto;
    margin-inline-end: 0;
    margin-right: auto;
    margin-left: 0;
}

/* ── Main Content: offset for right sidebar ── */
[dir="rtl"] .main-content {
    margin-left: 0 !important;
    margin-right: var(--sidebar-width) !important;
}

/* ── Topbar ── */
[dir="rtl"] .topbar-left {
    flex-direction: row-reverse;
}

[dir="rtl"] .topbar-right {
    flex-direction: row-reverse;
}

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

/* ── Card Header ── */
[dir="rtl"] .card-header {
    flex-direction: row-reverse;
}

/* ── Stat Cards ── */
[dir="rtl"] .stat-card {
    flex-direction: row-reverse;
    text-align: right;
}

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

/* ── Tables ── */
[dir="rtl"] table {
    direction: rtl;
}

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

/* ── Buttons ── */
[dir="rtl"] .btn-group {
    flex-direction: row-reverse;
}

/* ── Form Actions ── */
[dir="rtl"] .form-actions {
    flex-direction: row-reverse;
}

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

/* ── Toasts ── */
[dir="rtl"] .toast {
    flex-direction: row-reverse;
}

[dir="rtl"] .toast-hide {
    transform: translateX(-20px);
}

/* ── Modal ── */
[dir="rtl"] .modal-header {
    flex-direction: row-reverse;
}

/* ── Dropdowns ── */
[dir="rtl"] .dropdown-menu {
    text-align: right;
}

[dir="rtl"] .dropdown-item {
    flex-direction: row-reverse;
}

/* ── Login Page ── */
[dir="rtl"] .login-card {
    text-align: center;
}

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

/* ── Toast Container ── */
[dir="rtl"] .toast-container {
    left: 20px;
    right: auto;
}

/* ══════════════════════════════════════════════════════════════
   RTL Responsive
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Sidebar hidden off-screen to the RIGHT */
    [dir="rtl"] .sidebar {
        left: auto !important;
        right: 0 !important;
        transform: translateX(100%);
    }

    [dir="rtl"] .sidebar.open {
        transform: translateX(0);
    }

    /* No offset on mobile */
    [dir="rtl"] .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    [dir="rtl"] .card-header {
        align-items: flex-end;
    }
}

@media (max-width: 480px) {
    [dir="rtl"] .topbar {
        padding: 0 12px;
    }

    [dir="rtl"] .page-heading {
        font-size: 1.1rem;
    }

    [dir="rtl"] .stat-card {
        padding: 16px;
    }

    [dir="rtl"] .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }

    [dir="rtl"] .stat-info h4 {
        font-size: 1.3rem;
    }
}

/* ──────────── Utility ──────────── */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }
.mt-2 { margin-top: 16px !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
