@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

/* ===========================
   ریست و متغیرها
=========================== */
*, *::before, *::after {
    margin: 0; padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

:root {
    --primary: #6366F1;
    --primary-dark: #4F46E5;
    --primary-light: rgba(99,102,241,0.1);
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    --bg-body: #F0F4FF;
    --bg-card: rgba(255,255,255,0.72);
    --bg-sidebar: rgba(15,23,42,0.97);

    --glass-bg: rgba(255,255,255,0.6);
    --glass-bg-light: rgba(255,255,255,0.8);
    --glass-border: rgba(255,255,255,0.5);

    --border-color: rgba(100,116,139,0.15);
    --shadow-soft: 0 4px 24px rgba(0,0,0,0.06);
    --shadow-card: 0 2px 12px rgba(0,0,0,0.04);
    --shadow-sidebar: 4px 0 30px rgba(0,0,0,0.18);

    --sidebar-width: 272px;
    --header-height: 68px;
    --radius: 18px;
    --radius-sm: 12px;
    --radius-xs: 8px;

    --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ===========================
   بادی و پس‌زمینه
=========================== */
body {
    font-family: 'Vazirmatn', system-ui, sans-serif;
    background: var(--bg-body);
    background-image:
        radial-gradient(circle at 15% 15%, rgba(99,102,241,0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 80%, rgba(16,185,129,0.06) 0%, transparent 50%);
    min-height: 100vh;
    direction: rtl;
    color: var(--text-primary);
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99,102,241,0.06), transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(16,185,129,0.05), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ===========================
   سایدبار
=========================== */
.sidebar {
    position: fixed;
    top: 0; right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    box-shadow: var(--shadow-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition);
    border-left: 1px solid rgba(255,255,255,0.06);
    overflow: hidden;
}

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

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
}

.sidebar-header .logo i {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    box-shadow: 0 4px 14px rgba(99,102,241,0.45);
}

.close-btn {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: none;
    align-items: center; justify-content: center;
    font-size: 0.9rem;
    transition: var(--transition);
}

.close-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ناوبری سایدبار */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-nav ul { list-style: none; padding: 0 12px; }

.sidebar-nav ul li {
    margin-bottom: 2px;
}

.sidebar-nav ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.87rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.sidebar-nav ul li a i:first-child {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-nav ul li a:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}

.sidebar-nav ul li.active > a {
    background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(99,102,241,0.15));
    color: #fff;
    border: 1px solid rgba(99,102,241,0.35);
    font-weight: 600;
}

.sidebar-nav ul li.active > a::before {
    content: '';
    position: absolute;
    right: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

/* بج */
.badge {
    background: linear-gradient(135deg, var(--danger), #c0392b);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    margin-right: auto;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(239,68,68,0.4);
}

/* دراپ‌داون سایدبار */
.dropdown > .dropdown-toggle .arrow {
    margin-right: auto;
    font-size: 0.7rem;
    transition: transform var(--transition);
}

.dropdown.open > .dropdown-toggle .arrow { transform: rotate(180deg); }

.dropdown-menu {
    display: none;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    margin: 4px 0 4px 12px;
    border-right: 2px solid rgba(99,102,241,0.25);
    overflow: hidden;
}

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

.dropdown-menu li a {
    padding: 8px 14px;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.55) !important;
}

.dropdown-menu li a:hover { color: rgba(255,255,255,0.9) !important; }

/* فوتر سایدبار */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-footer .user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.sidebar-footer img {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(99,102,241,0.5);
    flex-shrink: 0;
}

.sidebar-footer .user-info h4 {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-info p {
    color: rgba(255,255,255,0.45);
    font-size: 0.75rem;
}

.logout-btn {
    width: 36px; height: 36px;
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--danger);
    text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0;
}

.logout-btn:hover { background: rgba(239,68,68,0.3); }

/* ===========================
   محتوای اصلی
=========================== */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    position: relative;
    z-index: 1;
    transition: margin var(--transition);
}

/* هدر بالا */
.top-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.menu-toggle {
    display: none;
    width: 40px; height: 40px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    align-items: center; justify-content: center;
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: var(--transition);
    flex-shrink: 0;
}

.menu-toggle:hover { background: var(--primary-light); color: var(--primary); }

.top-header .search-box {
    flex: 1;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 14px;
}

.top-header .search-box i { color: var(--text-muted); font-size: 0.9rem; }

.top-header .search-box input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--text-primary);
    width: 100%;
    outline: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
}

.header-btn {
    width: 38px; height: 38px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    transition: var(--transition);
    position: relative;
}

.header-btn:hover { background: var(--primary-light); color: var(--primary); }

.notification-dot {
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    position: absolute;
    top: 6px; left: 6px;
    border: 2px solid #fff;
}

/* داشبورد محتوا */
.dashboard-content {
    padding: 28px;
}

/* ===========================
   کارت‌های شیشه‌ای
=========================== */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 24px;
}

/* ===========================
   صفحه تایتل
=========================== */
.page-title { margin-bottom: 24px; }
.page-title h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; color: var(--text-primary); }
.page-title p { color: var(--text-secondary); font-size: 0.9rem; }

/* ===========================
   کارت‌های آمار
=========================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 100%; height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card:nth-child(1)::before { background: linear-gradient(90deg, var(--primary), #818CF8); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--success), #34D399); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--warning), #FCD34D); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, var(--danger), #FB7185); }

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

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}

.stat-card:nth-child(1) .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card:nth-child(2) .stat-icon { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-card:nth-child(3) .stat-icon { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-card:nth-child(4) .stat-icon { background: rgba(239,68,68,0.1); color: var(--danger); }

.stat-info h3 { font-size: 1.8rem; font-weight: 800; color: var(--text-primary); }
.stat-info p { font-size: 0.85rem; color: var(--text-secondary); }

.stat-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ===========================
   جداول
=========================== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    background: rgba(99,102,241,0.06);
    padding: 12px 16px;
    text-align: right;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

tbody tr {
    transition: var(--transition);
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

tbody tr:hover { background: rgba(99,102,241,0.03); }

tbody td {
    padding: 13px 16px;
    vertical-align: middle;
    color: var(--text-primary);
}

/* ===========================
   دکمه‌ها
=========================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-xs);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,0.35); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,0.45); }
.btn-secondary { background: var(--glass-bg); border-color: var(--border-color); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--glass-bg-light); color: var(--text-primary); }
.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: #fff; }
.btn-warning { background: linear-gradient(135deg, var(--warning), #D97706); color: #fff; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #DC2626); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; border-radius: 6px; }
.btn-outline { background: transparent; border-color: var(--border-color); color: var(--text-secondary); }

/* ===========================
   بِج‌های وضعیت
=========================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
}

.badge-success { background: rgba(16,185,129,0.12); color: #059669; }
.badge-warning { background: rgba(245,158,11,0.12); color: #D97706; }
.badge-danger { background: rgba(239,68,68,0.12); color: #DC2626; }
.badge-info { background: rgba(59,130,246,0.12); color: #2563EB; }
.badge-secondary { background: rgba(100,116,139,0.12); color: #475569; }

/* ===========================
   فرم‌ها
=========================== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.required { color: var(--danger); }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    background: var(--glass-bg-light);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.form-textarea { resize: vertical; min-height: 90px; }

/* ===========================
   آلرت‌ها
=========================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-xs);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 500;
}

.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); color: #065F46; }
.alert-danger  { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25); color: #991B1B; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.25); color: #92400E; }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.25); color: #1E40AF; }

/* ===========================
   پگیناتور
=========================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding-top: 16px;
    flex-wrap: wrap;
}

.page-link {
    min-width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    padding: 0 10px;
}

.page-link:hover { background: var(--primary-light); color: var(--primary); }
.page-link.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-color: var(--primary); box-shadow: 0 3px 10px rgba(99,102,241,0.35); }

/* ===========================
   اوورلی موبایل
=========================== */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    cursor: pointer;
    transition: opacity 0.3s ease;
}
.overlay.active { display: block; }

/* ===========================
   ریسپانسیو
=========================== */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(272px);
        box-shadow: none;
    }
    .sidebar.active {
        transform: translateX(0);
        box-shadow: -8px 0 40px rgba(0,0,0,0.35);
    }
    .main-content {
        margin-right: 0 !important;
        width: 100%;
    }
    .menu-toggle { display: flex; }
    .close-btn { display: flex; }

    /* جلوگیری از اسکرول پشت sidebar */
    body.sidebar-open {
        overflow: hidden;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        max-width: 300px;
        transform: translateX(300px);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .top-header { padding: 0 14px; gap: 10px; }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; }
    .dashboard-content { padding: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .top-header { padding: 0 12px; gap: 8px; }
    .top-header .search-box { display: none; }
    .main-content { margin-right: 0 !important; }
    
    /* جداول روی موبایل */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; }
}
