/* ==========================================
   استایل اصلی
   ========================================== */

:root {
    --bg: #f5f3f8;
    --white: #ffffff;
    --purple-50: #faf8ff;
    --purple-100: #f3eefc;
    --purple-200: #e4d8f7;
    --purple-300: #c4b0ee;
    --purple-400: #a78bfa;
    --purple-500: #8b5cf6;
    --purple-600: #7c3aed;
    --purple-700: #6d28d9;
    --purple-800: #5b21b6;
    --purple-900: #4c1d95;
    --text: #1e1b2e;
    --text-light: #6b647a;
    --text-muted: #a099b5;
    --border: #e8e3f0;
    --shadow-sm: 0 2px 8px rgba(76, 29, 149, 0.04);
    --shadow: 0 8px 30px rgba(76, 29, 149, 0.06);
    --shadow-lg: 0 20px 60px rgba(76, 29, 149, 0.1);
    --radius-sm: 10px;
    --radius: 18px;
    --radius-lg: 24px;
    --radius-full: 50px;
    --transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}
/* ==========================================
   فونت وزیرمتن (لوکال)
   ========================================== */
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.9;
    min-height: 100vh;
}

/* ==========================================
   پنل شناور کاربر (سمت چپ)
   ========================================== */
.floating-user-panel {
    position: fixed;
    left: 20px;
    bottom: 30px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.floating-toggle-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--purple-600);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
    transition: var(--transition);
    position: relative;
    z-index: 2;
}
.floating-toggle-btn:hover {
    background: var(--purple-700);
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.5);
}
.floating-toggle-btn.active {
    background: var(--purple-800);
    transform: rotate(180deg);
}

.floating-panel-content {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    width: 240px;
    display: none;
    flex-direction: column;
    gap: 12px;
    animation: slideUp 0.3s ease;
}
.floating-panel-content.open {
    display: flex;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.floating-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.floating-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--purple-100);
    color: var(--purple-600);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.floating-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.floating-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.floating-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.floating-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.floating-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    text-align: right;
}
.floating-action-btn:hover {
    background: var(--purple-50);
    color: var(--purple-700);
}
.floating-action-btn.logout-btn {
    color: #e11d48;
}
.floating-action-btn.logout-btn:hover {
    background: #ffe4e6;
    color: #be123c;
}

/* ==========================================
   منوی راست‌کلیک (Context Menu)
   ========================================== */
.context-menu {
    display: none;
    position: fixed;
    z-index: 2000;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 6px 0;
    animation: contextFadeIn 0.15s ease;
}

@keyframes contextFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s ease;
    border: none;
    width: 100%;
    text-align: right;
    background: transparent;
}
.context-menu-item:hover {
    background: var(--purple-50);
    color: var(--purple-700);
}
.context-menu-item.danger {
    color: #e11d48;
}
.context-menu-item.danger:hover {
    background: #ffe4e6;
    color: #be123c;
}

.context-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.context-row {
    cursor: pointer;
}
.context-row:hover {
    background: var(--purple-50) !important;
}

/* ==========================================
   Drag & Drop برای کتاب‌ها
   ========================================== */
.draggable-row {
    cursor: grab;
    transition: all 0.2s ease;
}
.draggable-row:active {
    cursor: grabbing;
}
.draggable-row.dragging {
    opacity: 0.5;
    background: var(--purple-100) !important;
    border: 2px dashed var(--purple-400);
}
.draggable-row.drag-over {
    border-top: 3px solid var(--purple-500) !important;
    background: var(--purple-50) !important;
}

.drag-handle-icon {
    color: var(--text-muted);
    margin-left: 8px;
    cursor: grab;
    vertical-align: middle;
}

/* ==========================================
   صفحه لاگین
   ========================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #f5f3f8 0%, #e8e3f0 50%, #f3eefc 100%);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    text-align: center;
}

.login-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--purple-600), var(--purple-400));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.3);
}

.login-card h3 { 
    text-align: center; 
    font-weight: 700; 
    color: var(--text); 
    margin-bottom: 8px;
}

.login-card .text-muted { 
    text-align: center; 
    margin-bottom: 24px; 
}

.login-card .form-label {
    text-align: right;
    display: block;
}

.login-card .form-control {
    text-align: right;
    direction: rtl;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 12px;
    margin-top: 8px;
}

.login-card .mb-3 {
    text-align: right;
}

/* ==========================================
   Top Navbar
   ========================================== */
.top-nav { position: sticky; top: 15px; z-index: 1000; margin: 0 15px; }

.nav-inner {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.nav-inner:hover { background: rgba(255, 255, 255, 0.85); box-shadow: var(--shadow-lg); }

.nav-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.brand-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--purple-600), var(--purple-400));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.brand-sub { font-size: 0.7rem; color: var(--text-muted); }

.nav-links { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }

.nav-link {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-radius: var(--radius-full);
    text-decoration: none; color: var(--text-light);
    font-size: 0.82rem; font-weight: 400;
    transition: var(--transition); white-space: nowrap; cursor: pointer;
}
.nav-link:hover { background: var(--purple-100); color: var(--purple-700); }
.nav-link.active { background: var(--purple-600); color: white; box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3); }

.mobile-logout-link {
    display: none !important;
    color: #e11d48 !important;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 8px;
}

.nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ==========================================
   Main Content
   ========================================== */
.main-area { padding: 30px 30px 100px; max-width: 1200px; margin: 0 auto; }
.content-container { animation: fadeIn 0.4s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   Stats Row
   ========================================== */
.stats-row { display: flex; gap: 18px; margin-bottom: 30px; flex-wrap: wrap; }

.stat-item {
    flex: 1; min-width: 140px;
    background: var(--white); border-radius: var(--radius);
    padding: 20px 24px; display: flex; align-items: center; gap: 16px;
    border: 1px solid var(--border); box-shadow: var(--shadow-sm); transition: var(--transition);
}
.stat-item:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.stat-icon-circle {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon-circle.purple { background: var(--purple-100); color: var(--purple-600); }
.stat-icon-circle.green { background: #d1fae5; color: #059669; }
.stat-icon-circle.blue { background: #e0f2fe; color: #0284c7; }
.stat-icon-circle.orange { background: #fff7ed; color: #ea580c; }
.stat-icon-circle.red { background: #ffe4e6; color: #e11d48; }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.stat-desc { font-size: 0.75rem; color: var(--text-muted); }

/* ==========================================
   Cards & Tables & Buttons & Forms
   ========================================== */
.card-custom {
    background: var(--white); border-radius: var(--radius); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm); margin-bottom: 24px; overflow: hidden;
}
.card-header-custom {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
}
.card-header-custom h5 { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.card-body-custom { padding: 24px; }

.table-custom { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; }
.table-custom thead th {
    background: var(--purple-50); padding: 14px 16px; font-weight: 500; font-size: 0.78rem;
    color: var(--purple-800); border-bottom: 2px solid var(--purple-200); white-space: nowrap;
}
.table-custom thead th:first-child { border-radius: 0 var(--radius-sm) 0 0; }
.table-custom thead th:last-child { border-radius: var(--radius-sm) 0 0 0; }
.table-custom tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 350; }
.table-custom tbody tr:hover td { background: var(--purple-50); }
.table-custom tbody tr:last-child td:first-child { border-radius: 0 0 var(--radius-sm) 0; }
.table-custom tbody tr:last-child td:last-child { border-radius: 0 0 0 var(--radius-sm); }
.table-custom tfoot td { font-weight: 700; background: var(--purple-50); }
.table-responsive { overflow-x: auto; }

.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 10px 20px;
    border-radius: var(--radius-full); font-size: 0.84rem; font-weight: 450; cursor: pointer;
    border: none; transition: var(--transition);
}
.btn-primary { background: var(--purple-600); color: white; box-shadow: 0 4px 14px rgba(124, 58, 237, 0.25); }
.btn-primary:hover { background: var(--purple-700); box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-light); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--purple-50); border-color: var(--purple-300); color: var(--purple-600); }
.btn-sm { padding: 6px 12px; font-size: 0.77rem; }
.btn-danger { background: #e11d48; color: white; }
.btn-danger:hover { background: #be123c; }
.btn-warning { background: #ea580c; color: white; }
.btn-info { background: #0284c7; color: white; }
.btn-success { background: #059669; color: white; }
.btn-outline-primary { background: transparent; border: 2px solid var(--purple-400); color: var(--purple-600); }
.btn-outline-primary:hover { background: var(--purple-500); color: white; border-color: var(--purple-500); }

.form-label { font-size: 0.82rem; font-weight: 450; color: var(--text-light); margin-bottom: 6px; display: block; }
.form-control, .form-select {
    width: 100%; padding: 11px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 350; background: var(--white); color: var(--text); transition: var(--transition);
}
.form-control:focus, .form-select:focus { outline: none; border-color: var(--purple-400); box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.06); }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-check-inline { display: inline-flex; align-items: center; gap: 6px; margin-left: 16px; margin-bottom: 8px; }
.form-check-label { font-size: 0.85rem; color: var(--text); }
.form-check-input:checked { background-color: var(--purple-600); border-color: var(--purple-600); }
.input-group-text { border: 1.5px solid var(--border); background: var(--white); color: var(--text-muted); }
.input-group .form-control { border-right: none; }

.badge-custom { display: inline-block; padding: 4px 12px; border-radius: var(--radius-full); font-size: 0.7rem; font-weight: 450; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #ffe4e6; color: #9f1239; }
.badge-danger-bold { background: #dc2626; color: #fff; font-weight: bold; animation: blink-badge 1s infinite; }
@keyframes blink-badge { 50% { opacity: 0.6; } }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-warning { background: #fff7ed; color: #9a3412; }
.badge-purple { background: var(--purple-100); color: var(--purple-700); }

.toast-wrap { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 9999; pointer-events: none; }
.custom-toast {
    background: var(--purple-800); color: white; padding: 14px 28px; border-radius: var(--radius-full);
    display: flex; align-items: center; gap: 10px; font-size: 0.86rem; font-weight: 400;
    box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(20px); transition: var(--transition); pointer-events: auto;
}
.custom-toast.show { opacity: 1; transform: translateY(0); }
.custom-toast.success { background: #059669; }
.custom-toast.error { background: #e11d48; }
.custom-toast.warning { background: #ea580c; }

.custom-modal { border-radius: var(--radius-lg); border: none; box-shadow: var(--shadow-lg); }
.custom-modal .modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.custom-modal .modal-body { padding: 24px; }
.custom-modal .modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); }

.alert-custom { padding: 16px 20px; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 18px; border-right: 4px solid; }
.alert-info { background: #e0f2fe; color: #075985; border-right-color: #0284c7; }
.alert-warning { background: #fff7ed; color: #9a3412; border-right-color: #ea580c; }
.alert-success { background: #d1fae5; color: #065f46; border-right-color: #059669; }
.alert-danger { background: #ffe4e6; color: #9f1239; border-right-color: #e11d48; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--purple-300); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple-400); }

/* ==========================================
   Mobile Bottom Tab Bar
   ========================================== */
.mobile-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 1100;
    padding: 6px 4px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    justify-content: space-around;
    align-items: center;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none !important;
    color: var(--text-muted);
    font-size: 0.58rem;
    font-weight: 500;
    padding: 6px 2px;
    flex: 1;
    transition: all 0.2s ease;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    border-radius: 10px;
    min-width: 0;
}

.tab-item.active {
    color: var(--purple-600);
    background: var(--purple-50);
}

.tab-item:active {
    transform: scale(0.95);
}

.tab-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ==========================================
   Mobile Responsive
   ========================================== */
@media (max-width: 900px) {
    .mobile-tab-bar {
        display: flex;
    }
    
    .main-area {
        padding-bottom: 80px;
    }
    
    .floating-user-panel {
        bottom: 80px;
        z-index: 999;
    }
    
    .toast-wrap {
        bottom: 90px;
    }
    
    .nav-links {
        display: none !important;
    }
    
    .nav-brand .brand-sub {
        display: none;
    }
    
    .mobile-logout-link {
        display: flex !important;
    }
    
    .top-nav {
        top: 0;
        margin: 0;
    }
    
    .nav-inner {
        border-radius: 0;
        padding: 10px 14px;
    }
}

@media (max-width: 768px) {
    .nav-inner { padding: 8px 12px; }
    .card-body-custom { padding: 12px; }
    .table-custom { font-size: 0.7rem; }
    .table-custom thead th { padding: 8px 6px; font-size: 0.65rem; }
    .table-custom tbody td { padding: 8px 6px; }
    .btn { padding: 6px 12px; font-size: 0.7rem; }
    .btn-sm { padding: 4px 8px; font-size: 0.65rem; }
    .form-control, .form-select { padding: 8px 10px; font-size: 0.75rem; }
    .stats-row { flex-direction: column; gap: 8px; }
    .stat-item { padding: 12px 14px; }
    .floating-user-panel { left: 8px; bottom: 80px; }
    .floating-panel-content { width: 200px; padding: 12px; }
    .floating-action-btn { padding: 8px 10px; font-size: 0.75rem; }
    .table-custom td .btn + .btn { margin-top: 4px; }
    .row.g-3 > [class*="col-"] { margin-bottom: 8px; }
    .card-header-custom { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 500px) {
    .nav-inner { padding: 8px 10px; gap: 8px; }
    .brand-name { font-size: 0.78rem; }
    .main-area { padding: 8px 6px 75px; }
    .table-custom { font-size: 0.65rem; }
    .table-custom thead th { padding: 6px 4px; font-size: 0.6rem; }
    .table-custom tbody td { padding: 6px 4px; }
    .btn { padding: 5px 10px; font-size: 0.65rem; }
    .btn-sm { padding: 3px 6px; font-size: 0.6rem; }
}

/* ==========================================
   Dark Theme
   ========================================== */
body.dark-theme {
    --bg: #0d1117; --white: #161b22; --purple-50: #1a1f2b; --purple-100: #21262d; --purple-200: #30363d;
    --purple-300: #484f58; --purple-400: #8b949e; --purple-500: #a78bfa; --purple-600: #7c3aed;
    --purple-700: #6d28d9; --purple-800: #5b21b6; --purple-900: #4c1d95;
    --text: #e6edf3; --text-light: #c9d1d9; --text-muted: #8b949e; --border: #30363d;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3); --shadow: 0 8px 30px rgba(0,0,0,0.4); --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);
    background: #0d1117; color: #e6edf3;
}
body.dark-theme .login-container { background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #1a1f2b 100%); }
body.dark-theme .nav-inner { background: rgba(22, 27, 34, 0.9); border-color: rgba(48, 54, 61, 0.6); }
body.dark-theme .nav-links { background: #161b22; border-color: #30363d; }
body.dark-theme .nav-link { color: #c9d1d9; }
body.dark-theme .nav-link:hover { background: rgba(139, 148, 158, 0.1); color: #e6edf3; }
body.dark-theme .mobile-logout-link { border-top-color: #30363d; }
body.dark-theme .mobile-tab-bar { background: #161b22; border-top-color: #30363d; }
body.dark-theme .tab-item { color: #8b949e; }
body.dark-theme .tab-item.active { color: #a78bfa; background: rgba(139, 92, 246, 0.1); }
body.dark-theme .card-custom, body.dark-theme .stat-item, body.dark-theme .login-card,
body.dark-theme .custom-modal .modal-content, body.dark-theme .form-control, body.dark-theme .form-select {
    background: #161b22; border-color: #30363d; color: #e6edf3;
}
body.dark-theme .floating-panel-content { background: #161b22; border-color: #30363d; }
body.dark-theme .floating-avatar { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
body.dark-theme .floating-action-btn { color: #c9d1d9; }
body.dark-theme .floating-action-btn:hover { background: #21262d; color: #e6edf3; }
body.dark-theme .floating-action-btn.logout-btn { color: #f85149; }
body.dark-theme .floating-action-btn.logout-btn:hover { background: rgba(248, 81, 73, 0.1); }
body.dark-theme .floating-user-info { border-bottom-color: #30363d; }
body.dark-theme .context-menu { background: #161b22; border-color: #30363d; }
body.dark-theme .context-menu-item:hover { background: #21262d; color: #e6edf3; }
body.dark-theme .context-menu-item.danger:hover { background: rgba(248, 81, 73, 0.1); }
body.dark-theme .context-menu-divider { background: #30363d; }
body.dark-theme .draggable-row.dragging { background: rgba(139, 92, 246, 0.1) !important; border-color: #6d28d9; }
body.dark-theme .draggable-row.drag-over { border-top-color: #a78bfa !important; background: rgba(139, 92, 246, 0.1) !important; }
body.dark-theme .card-header-custom { background: #1a1f2b; border-bottom-color: #30363d; }
body.dark-theme .table-custom thead th { background: #1a1f2b; color: #a78bfa; border-bottom-color: #30363d; }
body.dark-theme .table-custom tbody td { border-bottom-color: #21262d; }
body.dark-theme .table-custom tbody tr:hover td { background: #1a1f2b; }
body.dark-theme .table-custom tfoot td { background: #1a1f2b; }
body.dark-theme .form-control, body.dark-theme .form-select { background: #0d1117; border-color: #30363d; color: #e6edf3; }
body.dark-theme .form-control:focus, body.dark-theme .form-select:focus { border-color: #7c3aed; box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.1); }
body.dark-theme .btn-ghost { border-color: #30363d; color: #c9d1d9; }
body.dark-theme .btn-ghost:hover { background: #21262d; border-color: #484f58; }
body.dark-theme .alert-info { background: rgba(56, 139, 253, 0.1); color: #79c0ff; border-right-color: #58a6ff; }
body.dark-theme .alert-warning { background: rgba(210, 153, 34, 0.1); color: #e3b341; border-right-color: #d29922; }
body.dark-theme .alert-success { background: rgba(63, 185, 80, 0.1); color: #56d364; border-right-color: #3fb950; }
body.dark-theme .alert-danger { background: rgba(248, 81, 73, 0.1); color: #f85149; border-right-color: #f85149; }
body.dark-theme .badge-purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
body.dark-theme .stat-icon-circle.purple { background: rgba(139, 92, 246, 0.15); }
body.dark-theme .stat-icon-circle.green { background: rgba(63, 185, 80, 0.15); }
body.dark-theme .stat-icon-circle.blue { background: rgba(56, 139, 253, 0.15); }
body.dark-theme .stat-icon-circle.orange { background: rgba(210, 153, 34, 0.15); }
body.dark-theme .stat-icon-circle.red { background: rgba(248, 81, 73, 0.15); }
body.dark-theme .border-bottom { border-color: #21262d !important; }
body.dark-theme .text-muted { color: #8b949e !important; }
body.dark-theme .input-group-text { background: #21262d; border-color: #30363d; color: #c9d1d9; }
body.dark-theme .input-group .form-control { border-color: #30363d; }

.mobile-more-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1098;
}

.mobile-more-backdrop.show {
    display: block;
}

.mobile-more-menu {
    display: none;
    position: fixed;
    right: 12px;
    left: 12px;
    bottom: 76px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1099;
    padding: 10px;
    animation: mobileMoreUp 0.2s ease;
}

.mobile-more-menu.show {
    display: block;
}

.mobile-more-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    transition: var(--transition);
}

.mobile-more-item:hover,
.mobile-more-item:active {
    background: var(--purple-50);
    color: var(--purple-700);
}

.mobile-more-logout {
    color: #e11d48;
}

.mobile-more-logout:hover,
.mobile-more-logout:active {
    background: #ffe4e6;
    color: #be123c;
}

.mobile-more-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

@keyframes mobileMoreUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.dark-theme .mobile-more-backdrop {
    background: rgba(0, 0, 0, 0.45);
}

body.dark-theme .mobile-more-menu {
    background: #161b22;
    border-color: #30363d;
}

body.dark-theme .mobile-more-item {
    color: #e6edf3;
}

body.dark-theme .mobile-more-item:hover,
body.dark-theme .mobile-more-item:active {
    background: #21262d;
    color: #a78bfa;
}

body.dark-theme .mobile-more-logout {
    color: #f85149;
}

body.dark-theme .mobile-more-logout:hover,
body.dark-theme .mobile-more-logout:active {
    background: rgba(248, 81, 73, 0.1);
    color: #f85149;
}

body.dark-theme .mobile-more-divider {
    background: #30363d;
}



/* ==========================================
   Mobile Clean Fix - مرتب‌سازی نسخه موبایل
   ========================================== */

@media (max-width: 900px) {
    body {
        overflow-x: hidden;
    }

    .main-area {
        padding: 14px 10px 92px !important;
        max-width: 100%;
    }

    .card-custom {
        border-radius: 14px;
        margin-bottom: 14px;
    }

    .card-header-custom {
        padding: 14px;
        gap: 10px;
    }

    .card-header-custom h5 {
        font-size: 0.86rem;
        margin: 0;
    }

    .card-body-custom {
        padding: 14px;
    }

    .stats-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 14px;
    }

    .stat-item {
        min-width: 0;
        padding: 12px;
        gap: 10px;
        border-radius: 14px;
    }

    .stat-icon-circle {
        width: 38px;
        height: 38px;
    }

    .stat-value {
        font-size: 1.05rem;
    }

    .stat-desc {
        font-size: 0.66rem;
    }

    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
        border: 1px solid var(--border);
    }

    .table-responsive::after {
        content: 'برای دیدن همه ستون‌ها، جدول را به چپ و راست بکشید';
        display: block;
        padding: 8px 10px;
        font-size: 0.64rem;
        color: var(--text-muted);
        background: var(--purple-50);
        text-align: center;
        border-top: 1px solid var(--border);
    }

    .table-custom {
        min-width: 720px;
        font-size: 0.74rem;
        border-spacing: 0;
    }

    .table-custom thead th {
        padding: 9px 8px;
        font-size: 0.68rem;
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .table-custom tbody td {
        padding: 9px 8px;
        vertical-align: middle;
        white-space: nowrap;
    }

    .table-custom tbody td:last-child {
        min-width: 135px;
    }

    .table-custom td .btn,
    .table-custom td button.btn {
        min-height: 30px;
        padding: 5px 9px;
        font-size: 0.66rem;
        margin: 2px;
        border-radius: 999px;
        justify-content: center;
        white-space: nowrap;
    }

    .table-custom td .btn + .btn {
        margin-right: 3px;
    }

    .btn {
        padding: 8px 13px;
        font-size: 0.76rem;
        min-height: 36px;
        justify-content: center;
    }

    .btn-sm {
        padding: 5px 9px;
        font-size: 0.68rem;
        min-height: 30px;
    }

    .form-control,
    .form-select {
        padding: 9px 11px;
        font-size: 0.78rem;
        border-radius: 10px;
    }

    textarea.form-control {
        min-height: 92px;
    }

    .row.g-3 > [class*="col-"] {
        margin-bottom: 10px;
    }

    .modal-dialog {
        margin: 10px;
    }

    .custom-modal .modal-header,
    .custom-modal .modal-body,
    .custom-modal .modal-footer {
        padding: 14px;
    }

    .toast-wrap {
        bottom: 92px;
        width: calc(100% - 24px);
    }

    .custom-toast {
        width: 100%;
        justify-content: center;
        border-radius: var(--radius);
        padding: 12px 14px;
        font-size: 0.78rem;
    }

    .floating-user-panel {
        bottom: 82px;
        left: 10px;
        z-index: 999;
    }

    #currentDate {
        font-size: 0.68rem !important;
        max-width: 118px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 768px) {
    .brand-icon {
        width: 36px;
        height: 36px;
    }

    .brand-name {
        font-size: 0.82rem;
    }

    .mobile-tab-bar {
        padding: 7px 4px;
        padding-bottom: max(7px, env(safe-area-inset-bottom));
    }

    .tab-item {
        font-size: 0.55rem;
        gap: 2px;
        padding: 6px 1px;
    }

    .tab-item svg {
        width: 19px;
        height: 19px;
    }

    .floating-panel-content {
        width: 210px;
        padding: 12px;
    }

    .floating-toggle-btn {
        width: 44px;
        height: 44px;
    }

    .floating-action-btn {
        padding: 9px 10px;
        font-size: 0.75rem;
    }

    .card-header-custom {
        flex-direction: column;
        align-items: stretch;
    }

    .card-header-custom .btn,
    .card-header-custom .btn-group,
    .card-header-custom input,
    .card-header-custom select {
        width: 100%;
    }

    .badge-custom {
        font-size: 0.64rem;
        padding: 3px 9px;
    }
}

@media (max-width: 500px) {
    .main-area {
        padding: 10px 7px 88px !important;
    }

    .stats-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .stat-item {
        padding: 11px 12px;
    }

    .card-body-custom {
        padding: 11px;
    }

    .table-custom {
        min-width: 680px;
        font-size: 0.68rem;
    }

    .table-custom thead th {
        padding: 8px 6px;
        font-size: 0.62rem;
    }

    .table-custom tbody td {
        padding: 8px 6px;
    }

    .table-custom td .btn,
    .table-custom td button.btn {
        display: inline-flex;
        min-width: 62px;
        margin: 2px 1px;
        padding: 5px 7px;
        font-size: 0.62rem;
    }

    .btn {
        padding: 7px 11px;
        font-size: 0.7rem;
    }

    .btn-sm {
        padding: 4px 7px;
        font-size: 0.62rem;
    }

    .form-control,
    .form-select {
        padding: 8px 9px;
        font-size: 0.72rem;
    }

    .mobile-more-menu {
        right: 8px;
        left: 8px;
        bottom: 74px;
        border-radius: 16px;
    }

    .mobile-more-item {
        padding: 11px 12px;
        font-size: 0.8rem;
    }
}

/* اصلاح اسکرول جدول حضور و غیاب در موبایل */
@media (max-width: 768px) {
    #attSheet {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #attSheet .card-custom {
        min-width: 620px;
    }

    #attSheet .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #attSheet .table-custom {
        min-width: 600px;
        white-space: nowrap;
    }

    #attSheet select.form-select {
        min-width: 120px;
    }
}