/* ===================================
   1. تنظیمات اولیه و متغیرها
   =================================== */
:root {
    --sidebar-width: 280px;
    --header-height: 70px;
    --primary-color: #1a2a6c;
    --secondary-color: #b21f1f;
    --accent-color: #fdbb2d;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --info-color: #3498db;
    --light-bg: #f8f9fc;
    --white: #ffffff;
    --text-dark: #2c3e50;
    --text-muted: #95a5a6;
    --border-color: #ecf0f1;
    --font-family: 'Vazirmatn', sans-serif;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}

html {
    scroll-behavior: smooth;
    box-sizing: border-box;
}
*, *:before, *:after { box-sizing: inherit; }

body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--light-bg);
    direction: rtl;
    color: var(--text-dark);
    font-size: 16px;
    line-height: 1.7;
    /* فاصله از بالا برای هدر ثابت */
    padding-top: var(--header-height);
}

/* ===================================
   2. ساختار اصلی و مدیریت لایه‌ها (Layout)
   =================================== */
/* سایدبار - بالاترین لایه */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: var(--sidebar-width);
    z-index: 1055;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    padding-bottom: 60px; /* فضا برای فوتر سایدبار */
}

/* محتوای اصلی */
.content-wrapper {
    margin-right: var(--sidebar-width);
    min-height: calc(100vh - var(--header-height));
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 2rem;
}

/* هدر */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 1050;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: var(--shadow-sm);
}

/* لایه تاریک (Overlay) */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1045;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===================================
   3. استایل‌های هدر
   =================================== */
.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 2rem;
}
.header-left, .header-right { display: flex; align-items: center; }

.header-logo {
    height: 40px;
    margin-left: 1.5rem;
    transition: transform 0.3s ease;
}
.header-logo:hover { transform: scale(1.05); }

.page-title {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
}
.menu-toggle:hover { color: var(--accent-color); }

.user-profile {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 8px 18px;
    border-radius: 50px;
    transition: background-color 0.3s;
}
.user-profile:hover { background-color: rgba(255, 255, 255, 0.25); }
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--white);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-left: 12px;
    font-size: 1.2rem;
}
.user-details { color: var(--white); text-align: right; }
.user-name { font-weight: 600; font-size: 0.95rem; margin: 0; }
.user-role { font-size: 0.8rem; opacity: 0.9; margin: 0; }

/* ===================================
   4. استایل‌های سایدبار
   =================================== */
.sidebar-header {
    padding: 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-header h4 { font-weight: 700; margin-bottom: 0.5rem; font-size: 1.3rem; }
.sidebar-header p { opacity: 0.8; font-size: 0.9rem; margin: 0; }

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.85);
    padding: 14px 25px;
    transition: all 0.2s;
    border-radius: 0;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    position: relative;
}
.sidebar .nav-link:hover, .sidebar .nav-link:focus {
    color: var(--white);
    background-color: rgba(255, 255, 255, 0.1);
    padding-right: 35px;
}
.sidebar .nav-link.active {
    color: var(--white);
    background-color: rgba(255, 255, 255, 0.15);
    font-weight: 600;
}
.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background-color: var(--accent-color);
}
.sidebar .nav-link i { margin-left: 15px; font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 1.2rem;
    font-size: 0.8rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-close-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--white);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1060;
    font-size: 1.3rem;
    transition: background-color 0.3s;
}
.sidebar-close-btn:hover { background-color: rgba(255, 255, 255, 0.3); }

/* ===================================
   5. کامپوننت‌های داشبورد (کارت‌ها و آمار)
   =================================== */
.stats-card {
    border: none;
    border-radius: 15px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: var(--shadow-sm);
}
.stats-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}
.stats-card .card-body {
    padding: 1.5rem 2rem;
    color: var(--white);
}
.stats-card .stats-icon {
    font-size: 2.5rem;
    opacity: 0.6;
}
.stats-card .stats-number {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    margin-top: 0.5rem;
}
.stats-card .stats-title {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* کارت‌های اصلی */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    transition: box-shadow 0.3s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    color: var(--text-dark);
    border-radius: 15px 15px 0 0 !important;
    padding: 1.25rem 2rem;
}
.card-body { padding: 2rem; }

/* تایم‌لاین فعالیت‌ها */
.timeline-item {
    position: relative;
    padding-right: 45px;
    margin-bottom: 1.5rem;
}
.timeline-item::before {
    content: '';
    position: absolute;
    right: 17px;
    top: 35px;
    height: calc(100% + 10px);
    width: 2px;
    background: var(--border-color);
}
.timeline-item:last-child::before { display: none; }
.timeline-item .timeline-icon {
    position: absolute;
    right: 0;
    top: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--white);
    background: var(--info-color);
}
.timeline-item .timeline-content {
    background: var(--light-bg);
    padding: 1rem 1.5rem;
    border-radius: 10px;
    border-right: 3px solid var(--info-color);
}

/* ===================================
   6. ریسپانسیو (Responsive)
   =================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .sidebar-close-btn {
        display: flex;
    }
    .sidebar-header { padding-top: 4rem; }
    .content-wrapper {
        margin-right: 0;
        padding: 1rem;
    }
    .page-title, .user-details { display: none; }
    .card-header { padding: 1rem 1.5rem; }
    .card-body { padding: 1.5rem; }
    .stats-card .card-body { padding: 1.5rem; }
}
@media (min-width: 769px) {
    .menu-toggle, .sidebar-close-btn { display: none !important; }
}

/* استایل‌های عمومی */
.btn { border-radius: 8px; font-weight: 500; transition: all 0.2s; }
.btn-danger { background-color: var(--danger-color); border-color: var(--danger-color); }
.btn-danger:hover { background-color: #c0392b; border-color: #c0392b; }
.alert { border-radius: 10px; border: none; padding: 1rem 1.5rem; }


/* ===================================
   استایل‌های صفحات عمومی (Public Pages)
   =================================== */

/* هدر عمومی */
.public-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 4rem 0 3rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}
.public-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHBhdHRlcm4gaWQ9ImdyaWQiIHdpZHRoPSI2MCIgaGVpZ2h0PSI2MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGggZD0iTSAwIDYwIEwgNjAgMCBNIC0xNSAxNSBMIDE1IC0xNSBNIDQ1IDc1IEwgNzUgNDUiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmZiIgb3BhY2l0eT0iMC4wNSIgLz48L3BhdHRlcm4+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JpZCkiIC8+PC9zdmc+');
    opacity: 0.1;
}

/* استایل فرم عمومی */
.card {
    border-radius: 15px;
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}
.card-title {
    color: var(--text-dark);
}
fieldset {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    background-color: #fdfdfd;
}
legend {
    background-color: var(--light-bg);
    padding: 0 1rem;
    border-radius: 5px;
    font-size: 1rem;
}
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #ced4da;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(26, 42, 108, 0.25);
}
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
}
.btn-primary:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-2px);
}
.btn-primary:disabled {
    background-color: #6c757d;
    border-color: #6c757d;
    transform: none;
}

/* فوتر */
footer {
    color: var(--text-muted);
}
footer a {
    color: var(--primary-color);
    transition: color 0.3s;
}
footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* ===================================
   استایل‌های صفحات عمومی (Public Pages)
   =================================== */

/* هدر عمومی */
.public-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 4rem 0 3rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}
.public-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHBhdHRlcm4gaWQ9ImdyaWQiIHdpZHRoPSI2MCIgaGVpZ2h0PSI2MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGggZD0iTSAwIDYwIEwgNjAgMCBNIC0xNSAxNSBMIDE1IC0xNSBNIDQ1IDc1IEwgNzUgNDUiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmZiIgb3BhY2l0eT0iMC4wNSIgLz48L3BhdHRlcm4+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JpZCkiIC8+PC9zdmc+');
    opacity: 0.1;
}

/* استایل کارت‌های چند مرحله‌ای */
.card {
    border-radius: 15px;
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden; /* برای اینکه گوشه‌های هدر هم گرد باشند */
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.5rem;
    border-radius: 15px 15px 0 0 !important;
}
.card-header h5 {
    color: var(--text-dark);
    font-size: 1.1rem;
}

/* استایل فرم‌ها و دکمه‌ها */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #ced4da;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.15rem rgba(26, 42, 108, 0.25);
}

/* دکمه اصلی با گرادینت خلاقانه */
.btn-primary-gradient {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(26, 42, 108, 0.3);
}
.btn-primary-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(26, 42, 108, 0.4);
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color)); /* معکوس شدن گرادینت در هاور */
    color: #fff;
}
.btn-primary-gradient:disabled {
    background: #6c757d;
    border-color: #6c757d;
    transform: none;
    box-shadow: none;
}

/* فوتر */
footer {
    color: var(--text-muted);
}
footer a {
    color: var(--primary-color);
    transition: color 0.3s;
}
footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}


/* ===================================
   پالت رنگی و تم جدید برای صفحات عمومی
   =================================== */
:root {
    /* ... متغیرهای قبلی شما ... */
    --primary-color: #1a2a6c;
    --secondary-color: #b21f1f;
    --accent-color: #fdbb2d;

    /* --- متغیرهای جدید برای تم عمومی --- */
    --public-bg-color: #eef2f7; /* پس‌زمینه اصلی صفحه (آبی-خاکستری بسیار روشن) */
    --card-bg-color: #ffffff;      /* پس‌زمینه کارت‌ها (سفید براق) */
    --header-text-color: #f8f9fa;  /* رنگ متن هدر (سفید کمی مات برای خوانایی بهتر) */
    --footer-bg-color: #d9e2ec;    /* پس‌زمینه فوتر (خاکستری روشن برای ایجاد کنتراست) */
}

/* ===================================
   استایل‌های صفحات عمومی (Public Pages)
   =================================== */

/* پس‌زمینه اصلی صفحه */
body.bg-light {
    background-color: var(--public-bg-color) !important;
}

/* هدر عمومی با لوگو و نام شرکت */
.public-header {
    background: linear-gradient(135deg, #2c3e50, #34495e); /* گرادینت تیره‌تر و شیک‌تر */
    color: var(--header-text-color);
    padding: 3rem 0;
    margin-bottom: 3rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
}
.public-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHBhdHRlcm4gaWQ9ImdyaWQiIHdpZHRoPSI2MCIgaGVpZ2h0PSI2MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGggZD0iTSAwIDYwIEwgNjAgMCBNIC0xNSAxNSBMIDE1IC0xNSBNIDQ1IDc1IEwgNzUgNDUiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmZiIgb3BhY2l0eT0iMC4wMyIgLz48L3BhdHRlcm4+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWighth0PSIxMDAlIiBmaWxsPSJ1cmwoI2dyaWQpIiAvPjwvc3ZnPg==');
    opacity: 0.05;
}
.public-header .header-branding {
    display: flex;
    align-items: center;
    justify-content: center;
}
.public-header .brand-logo {
    height: 50px;
    margin-left: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.public-header .brand-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.5px;
}

/* کارت‌های برجسته و خلاقانه */
.card {
    background-color: var(--card-bg-color);
    border-radius: 15px;
    border: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.06); /* سایه نرم‌تر برای حس برجستگی */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); /* سایه قوی‌تر در هاور */
}
.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 1.25rem 1.5rem;
    border-radius: 15px 15px 0 0 !important;
}
.card-header h5 {
    color: var(--text-dark);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

/* دکمه اصلی با گرادینت جذاب */
.btn-primary-gradient {
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); /* گرادینت بنفش-آبی مدرن */
    border: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}
.btn-primary-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: #fff;
}
.btn-primary-gradient:disabled {
    background: #6c757d;
    transform: none;
    box-shadow: none;
}

/* فوتر با کنتراست مناسب */
footer {
    background-color: var(--footer-bg-color) !important;
    color: var(--text-muted);
    border-top: 1px solid #d0d7de;
}
footer a {
    color: var(--primary-color);
    font-weight: 600;
    transition: color 0.3s;
}
footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* ===================================
   استایل‌های صفحه لاگین (بازنویسی شده)
   =================================== */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--public-bg-color) 0%, #d9e2ec 100%); /* پس‌زمینه گرادینتی ملایم */
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    background: white;
    animation: fadeIn 0.8s ease-out;
}
.login-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); /* همان گرادینت دکمه اصلی */
    color: white;
    padding: 40px 20px;
    text-align: center;
    position: relative;
}
.login-header .login-logo {
    height: 60px;
    margin-bottom: 1rem;
    border-radius: 10px;
    background: white;
    padding: 5px;
}
.login-header h3 { margin-bottom: 0; font-weight: 800; font-size: 1.5rem; }
.login-body { padding: 40px 30px; }
.form-control-lg {
    padding: 12px 15px;
    border-radius: 10px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    transition: all 0.3s;
}
.form-control-lg:focus {
    background-color: white;
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}
.btn-login {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: 0.3s;
}
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    color: white;
}
.back-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: #6c757d;
    text-decoration: none;
    transition: color 0.3s;
}
.back-link:hover { color: var(--primary-color); }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}