:root {
    --primary-color: #1f1f2e;
    --secondary-color: #4f4f66;
    --accent-color: #4c6ef5;
    --text-light: #f8f9fa;
    --text-gray: #a2abb3;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --sidebar-width: 240px;
    --sidebar-collapsed: 50px;
    --topbar-height: 50px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazir', sans-serif;
}

html, body {
    overflow-x: hidden;
    height: 100%;
}

body {
    background-color: #e3e8ef;
    color: #333;
    position: relative;
}

/* سایدبار */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: var(--text-light);
    height: 100vh;
    position: fixed;
    z-index: 1050;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .menu-text,
.sidebar.collapsed .menu-icon {
    display: none;
}

.sidebar.collapsed a {
    justify-content: center;
    padding: 12px;
}

.sidebar a {
    color: var(--text-gray);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.sidebar a:hover {
    background-color: var(--secondary-color);
    color: var(--text-light);
    border-right-color: var(--accent-color);
}

.sidebar a.active {
    background-color: var(--secondary-color);
    color: var(--text-light);
    border-right-color: var(--accent-color);
}

.submenu {
    background-color: var(--secondary-color);
    padding-right: 30px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.submenu.show {
    max-height: 500px;
}

.submenu a {
    padding: 10px 15px;
    font-size: 0.9rem;
}

.menu-icon {
    transition: transform 0.3s ease;
    margin-right: auto;
}

.rotate-180 {
    transform: rotate(180deg);
}

.sidebar-header {
    padding: 20px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.sidebar-header .logo {
    width: 40px;
    height: 40px;
    background: var(--accent-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin: 0 auto 10px;
}

.sidebar-menu {
    overflow-y: auto;
    flex-grow: 1;
    padding-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* محتوای اصلی */
.main-content {
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s ease;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content.collapsed {
    margin-right: var(--sidebar-collapsed);
    width: calc(100% - var(--sidebar-collapsed));
}

.top-bar {
    height: var(--topbar-height);
    background: var(--primary-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 25px;
    justify-content: space-between;
    position: sticky;
    top: 0;
    flex-shrink: 0;
}

.content {
    padding: 25px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* پروفایل کاربر */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    cursor: pointer;
    height: 50px;
    color: var(--text-light);
}

.user-profile img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    width: 220px;
    z-index: 1100;
    overflow: hidden;
    display: none;
    margin-top: 5px;
}

.user-menu.show {
    display: block;
}

.user-menu a {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #444;
    text-decoration: none;
    transition: all 0.2s;
    border-bottom: 1px solid #f1f1f1;
}

.user-menu a:last-child {
    border-bottom: none;
}

.user-menu a:hover {
    background: #f8f9fa;
    color: var(--accent-color);
}

/* کارت‌های آمار */
.stat-card {
    border-radius: 12px;
    border: none;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 100%);
    z-index: -1;
}

.stat-card .card-body {
    position: relative;
    z-index: 2;
}

.stat-card .icon-container {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
}

.stat-card .card-title {
    font-size: 14px;
    margin-bottom: 5px;
    opacity: 0.9;
}

.stat-card .card-value {
    font-weight: bold;
    font-size: 24px;
    margin-bottom: 15px;
}

.progress {
    height: 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.3);
}

/* سایه هنگام باز شدن منو در موبایل */
.overlay {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1040;
    display: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    display: block;
}

/* دکمه‌ها */
.btn-toggle {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* صفحه‌بندی */
.pagination {
    margin-top: 30px;
    justify-content: center;
}

/* موبایل */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(100%);
        width: 280px;
        top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
        width: 100%;
    }

    .main-content.collapsed {
        margin-right: 0;
        width: 100%;
    }

    .user-profile .user-name {
        display: none;
    }

    .user-menu {
        right: 10px;
        left: auto;
        width: calc(100vw - 20px);
        max-width: 250px;
    }
}

/* انیمیشن‌ها */
@keyframes fadeIn {
    from {
        opacity: 0.5;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.8s ease forwards;
}

.delay-1 {
    animation-delay: 0.1s;
}

.delay-2 {
    animation-delay: 0.2s;
}

.delay-3 {
    animation-delay: 0.3s;
}

.delay-4 {
    animation-delay: 0.4s;
}

/* حالت تاریک */
.dark-mode {
    --primary-color: #0f1128;
    --secondary-color: #141f3a;
    background-color: #0a0a0a;
    color: #e0e0e0;
}

.dark-mode .content {
    background-color: #0f1128;
}

.dark-mode .stat-card {
    background-color: #141f3a;
    color: #e0e0e0;
}

.dark-mode .user-menu {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

.dark-mode .user-menu a {
    color: #e0e0e0;
    border-bottom: 1px solid #333;
}

.dark-mode .user-menu a:hover {
    background: #333;
}

/* کلید حالت تاریک */
.dark-mode-toggle {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
}

/* بهبودهای درخواستی */
@media (min-width: 992px) {
    .sidebar.collapsed:hover {
        width: var(--sidebar-width);
    }

    .sidebar.collapsed:hover .menu-text,
    .sidebar.collapsed:hover .menu-icon {
        display: inline-block;
    }

    .sidebar.collapsed:hover a {
        justify-content: flex-start;
        padding: 14px 20px;
    }
}