/* =========================================================
   STYLE.CSS - نسخه کامل (برندینگ مهگل + حفظ ساختار)
   ========================================================= */

/* 1. تنظیمات فونت و متغیرهای اصلی */
/* NOTE: Previously imported from Google Fonts (requires internet).
   Font-face is already loaded via `cdn.jsdelivr.net/gh/rastikerdar/vazirmatn...` in templates. */

:root {
    /* --- پالت رنگی اختصاصی مهگل --- */
    --mahgol-blue: #003366;       /* آبی سرمه‌ای (رنگ اصلی سازمانی) */
    --mahgol-blue-hover: #002244; /* حالت هاور آبی */
    --mahgol-red: #da291c;        /* قرمز لوگو (برای اکشن‌ها و هشدارها) */
    --mahgol-red-hover: #b91c1c;
    --mahgol-green: #4caf50;      /* سبز (برای موفقیت) */
    --mahgol-yellow: #ffc107;     /* زرد (برای هشدار) */
    
    /* --- نگاشت متغیرها به سیستم --- */
    --primary-color: var(--mahgol-blue);
    --primary-hover: var(--mahgol-blue-hover);
    --accent-color: var(--mahgol-red);
    
    /* --- رنگ‌های زمینه و متن --- */
    --bg-color: #f8fafc;          /* پس‌زمینه کلی روشن */
    --card-bg: #ffffff;           /* پس‌زمینه کارت‌ها */
    --text-main: #1e293b;         /* متن اصلی (تیره) */
    --text-muted: #64748b;        /* متن کمرنگ */
    --border-color: #e2e8f0;      /* رنگ خطوط مرزی */

    /* --- اندازه‌ها --- */
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 0.75rem;     /* گردی گوشه‌ها */
}

/* 2. تنظیمات پایه (Reset & Base) */
* {
    box-sizing: border-box;
    outline: none; /* حذف خط دور پیش‌فرض مرورگر */
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    direction: rtl;
    text-align: right;
    height: 100vh;
    overflow: hidden; /* جلوگیری از اسکرول صفحه اصلی */
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

/* 3. کلاس‌های کمکی — فقط لایوت قدیمی؛ روی structure-dashboard-shell تیلویند حاکم است */
.hidden { display: none !important; }
.d-none { display: none !important; } /* برای اطمینان */
body:not(.structure-dashboard-shell) .flex { display: flex; }
body:not(.structure-dashboard-shell):not(.happy-shell) .flex-col { flex-direction: column; }
body:not(.structure-dashboard-shell) .items-center { align-items: center; }
body:not(.structure-dashboard-shell) .justify-center { justify-content: center; }
body:not(.structure-dashboard-shell) .justify-between { justify-content: space-between; }
body:not(.structure-dashboard-shell) .w-full { width: 100%; }
body:not(.structure-dashboard-shell) .h-screen { height: 100vh; }
body:not(.structure-dashboard-shell) .mt-4 { margin-top: 1rem; }
body:not(.structure-dashboard-shell) .mb-4 { margin-bottom: 1rem; }
body:not(.structure-dashboard-shell) .p-4 { padding: 1rem; }
body:not(.structure-dashboard-shell) .text-center { text-align: center; }
.text-red { color: var(--mahgol-red); }
.text-blue { color: var(--mahgol-blue); }
body:not(.structure-dashboard-shell) .font-bold { font-weight: 700; }

/* ---------------------------------------------------------
   4. صفحه ورود (LOGIN PAGE) - ساختار حفظ شده، رنگ‌ها تغییر کرده
   --------------------------------------------------------- */
#view-login {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    /* گرادینت بسیار ملایم آبی به سفید */
    background: linear-gradient(135deg, #f0f4f8 0%, #dbeafe 100%);
    position: relative;
    z-index: 100;
}

/* Tailwind .hidden را ID بالا override می‌کرد؛ بدون این، فرم لاگین روی داشبورد می‌ماند */
#view-login.hidden,
#view-login[hidden] {
    display: none !important;
}

#view-dashboard.hidden,
#view-dashboard[hidden] {
    display: none !important;
}

/* خط رنگی بالای صفحه لاگین (برندینگ) */
#view-login::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(to right, var(--mahgol-red), var(--mahgol-yellow), var(--mahgol-green));
}

.login-container {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    border-top: 4px solid var(--mahgol-red); /* خط قرمز بالای فرم */
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header img {
    height: 80px;
    width: auto;
    margin-bottom: 1rem;
    object-fit: contain;
}

.login-header h2 {
    color: var(--mahgol-blue);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

/* ---------------------------------------------------------
   5. لایوت اصلی داشبورد (Dashboard Layout)
   --------------------------------------------------------- */
/* کانتینر اصلی که سایدبار و محتوا را نگه می‌دارد */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* --- سایدبار (Sidebar) — فقط لایوت قدیمی app-container --- */
body:not(.structure-dashboard-shell) aside {
    width: var(--sidebar-width);
    background-color: #ffffff;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
    z-index: 50;
    box-shadow: -2px 0 10px rgba(0,0,0,0.02);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    background-color: white; /* پس زمینه سفید برای لوگو */
}

.sidebar-header img {
    max-height: 45px;
    width: auto;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.5rem;
}

/* لینک‌های سایدبار */
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    border-radius: var(--border-radius);
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    font-weight: 500;
}

.sidebar-link i {
    width: 1.5rem;
    text-align: center;
    margin-left: 0.75rem;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.sidebar-link:hover {
    background-color: #f1f5f9;
    color: var(--mahgol-blue);
    padding-right: 1.25rem; /* افکت حرکت جزئی */
}

/* حالت فعال منو (Active State) */
.sidebar-link.active {
    background-color: #eff6ff; /* آبی خیلی کمرنگ */
    color: var(--mahgol-blue);
    font-weight: 700;
    border-right: 4px solid var(--mahgol-red); /* خط قرمز شاخص */
}

.sidebar-link.active i {
    color: var(--mahgol-red);
}

.user-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
}

/* --- محتوای اصلی (Main Content) --- */
body:not(.structure-dashboard-shell) main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
}

/* هدر بالا (Top Header) — خارج از Happy / structure shell */
body:not(.structure-dashboard-shell) header {
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 40;
}

body:not(.structure-dashboard-shell) header h2 {
    color: var(--mahgol-blue);
    font-size: 1.1rem;
    margin: 0;
}

/* ناحیه اسکرول محتوا */
body:not(.structure-dashboard-shell) #main-content {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    /* اسکرول بار زیبا */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* ---------------------------------------------------------
   6. المان‌های فرم — فقط خارج از پوستهٔ داشبورد تیلویندی
   --------------------------------------------------------- */
body:not(.structure-dashboard-shell) input,
body:not(.structure-dashboard-shell) select,
body:not(.structure-dashboard-shell) textarea,
body:not(.structure-dashboard-shell) .form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #fff;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

body:not(.structure-dashboard-shell) input:focus,
body:not(.structure-dashboard-shell) select:focus,
body:not(.structure-dashboard-shell) textarea:focus,
body:not(.structure-dashboard-shell) .form-control:focus {
    outline: none;
    border-color: var(--mahgol-blue);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1); /* سایه آبی */
}

body:not(.structure-dashboard-shell) label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #475569;
    font-size: 0.9rem;
}

/* ---------------------------------------------------------
   7. دکمه‌ها (Buttons) — فقط لایوت قدیمی؛ جلوگیری از تداخل با دکمه‌های تیلویند
   --------------------------------------------------------- */
body:not(.structure-dashboard-shell):not(.happy-shell) button,
body:not(.structure-dashboard-shell):not(.happy-shell) .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: var(--border-radius);
    border: none;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

/* دکمه اصلی (آبی مهگل) */
body:not(.structure-dashboard-shell):not(.happy-shell) .btn-primary,
body:not(.structure-dashboard-shell):not(.happy-shell) button[type="submit"] {
    background-color: var(--mahgol-blue);
    color: white;
}

body:not(.structure-dashboard-shell):not(.happy-shell) .btn-primary:hover,
body:not(.structure-dashboard-shell):not(.happy-shell) button[type="submit"]:hover {
    background-color: var(--mahgol-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 51, 102, 0.2);
}

/* دکمه خطر/حذف (قرمز مهگل) */
.btn-danger {
    background-color: var(--mahgol-red);
    color: white;
}

.btn-danger:hover {
    background-color: var(--mahgol-red-hover);
}

/* دکمه ثانویه/انصراف */
.btn-secondary {
    background-color: #e2e8f0;
    color: #475569;
}

.btn-secondary:hover {
    background-color: #cbd5e1;
    color: #1e293b;
}

/* ---------------------------------------------------------
   8. کارت‌ها و گریدها (Cards & Grids) — نام کلاس‌ها با تیلویند یکی است؛ محدود به لایوت قدیمی
   --------------------------------------------------------- */
body:not(.structure-dashboard-shell):not(.happy-shell) .grid {
    display: grid;
    gap: 1.5rem;
}

body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-2,
    body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-3,
    body:not(.structure-dashboard-shell):not(.happy-shell) .grid-cols-4 { grid-template-columns: 1fr; }
}

.card {
    background-color: white;
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e1;
}

/* نوار رنگی بالای ماژول‌ها */
.card-border-top {
    position: relative;
    overflow: hidden;
}
.card-border-top::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
    background: var(--mahgol-blue);
}
.card-border-top.accent::before {
    background: var(--mahgol-red);
}

/* ---------------------------------------------------------
   9. جداول (Tables)
   --------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
}

thead th {
    background-color: #f1f5f9;
    color: var(--mahgol-blue); /* هدر جدول آبی */
    font-weight: 700;
    padding: 1rem;
    text-align: right;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

tbody tr {
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: #f8fafc;
}

tbody td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

/* ---------------------------------------------------------
   10. مودال‌ها (Modals) - بخش حیاتی و بدون تغییر ساختار
   --------------------------------------------------------- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* بک‌گراند تیره */
    z-index: 1000;
    display: flex; /* برای وسط‌چین کردن */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px); /* تار کردن پس‌زمینه */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* کلاس کمکی برای نمایش مودال توسط JS */
.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
    display: flex; /* اطمینان از اینکه flex می‌ماند */
}

.modal-content {
    background-color: white;
    border-radius: 1rem;
    width: 90%;
    max-width: 600px; /* عرض پیش‌فرض */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    border-top: 5px solid var(--mahgol-blue); /* نوار آبی بالای مودال */
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

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

.modal-header h3 {
    margin: 0;
    color: var(--mahgol-blue);
    font-size: 1.25rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
}
.close-modal:hover { color: var(--mahgol-red); }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background-color: #f8fafc;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
}

/* سایزهای مختلف مودال */
.modal-lg { max-width: 900px; }
.modal-sm { max-width: 400px; }

/* ---------------------------------------------------------
   11. تب‌ها (Tabs) - برای فرم پرسنلی
   --------------------------------------------------------- */
.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--mahgol-blue);
}

.tab-btn.active {
    color: var(--mahgol-blue);
    border-bottom-color: var(--mahgol-blue);
    font-weight: 700;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------
   12. اسکرول بار اختصاصی (Custom Scrollbar)
   --------------------------------------------------------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
