/* ==========================================================================
   JavanehSchool - Main Application Styles
   نکته مهم: کلاس‌های MudBlazor (mud-*) اینجا override نمی‌شوند.
   رنگ، فونت و border-radius از طریق MudTheme در MainLayout کنترل می‌شود.
   ========================================================================== */

/* ==========================================================================
   1. CSS Variables — Light Mode
   ========================================================================== */

:root {
    --primary-color: #2563EB;
    --primary-light: #EBF3FF;
    --primary-dark: #1D4ED8;
    --secondary-color: #36B9CC;
    --success-color: #17A673;
    --warning-color: #F6C23E;
    --danger-color: #E11D48;

    --bg-page: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --text-primary: #1F2937;
    --text-muted: #9CA3AF;
    --text-secondary: #6B7280;
    --border-color: #F3F4F6;
    --border-subtle: #E5E7EB;

    --shadow-soft: 0 1px 4px rgba(0,0,0,0.05);
    --shadow-card: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 10px 25px -5px rgba(0,0,0,0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --nav-link-hover-bg: #F3F4F6;
    --nav-link-active-bg: #EBF3FF;
    --nav-link-active-color: #2563EB;
    --nav-link-color: #4B5563;

    --transition-base: all 0.2s ease;
}

/* ==========================================================================
   2. CSS Variables — Dark Mode (html.dark-mode)
   ========================================================================== */

html.dark-mode {
    --bg-page: #0F172A;
    --bg-card: #1E293B;
    --bg-sidebar: #1E293B;
    --text-primary: #F1F5F9;
    --text-muted: #64748B;
    --text-secondary: #94A3B8;
    --border-color: #1E293B;
    --border-subtle: #334155;

    --shadow-soft: 0 1px 4px rgba(0,0,0,0.3);
    --shadow-card: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-hover: 0 10px 25px -5px rgba(0,0,0,0.5);

    --nav-link-hover-bg: #334155;
    --nav-link-active-bg: rgba(37, 99, 235, 0.15);
    --nav-link-active-color: #60A5FA;
    --nav-link-color: #CBD5E1;
}

/* ==========================================================================
   3. Base & Reset
   ========================================================================== */

*, *::before, *::after {
    font-family: 'Kalameh', sans-serif !important;
    box-sizing: border-box;
}

html, body {
    direction: rtl !important;
    height: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    background: var(--bg-page) !important;
    color: var(--text-primary);
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

/* ==========================================================================
   4. Layout (صفحه‌بندی اصلی)
   ========================================================================== */

.mud-layout {
    background: var(--bg-page) !important;
    transition: background-color 0.3s ease;
}

.mud-main-content {
    background: var(--bg-page) !important;
    padding-left: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    height: 100vh;
    transition: background-color 0.3s ease, padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrollbar main content */
.mud-main-content::-webkit-scrollbar { width: 6px; }
.mud-main-content::-webkit-scrollbar-track { background: transparent; }
.mud-main-content::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }
.mud-main-content::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

html.dark-mode .mud-main-content::-webkit-scrollbar-thumb { background: #334155; }

/* ==========================================================================
   5. AppBar (نوار بالایی)
   ========================================================================== */

.school-appbar {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06) !important;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.appbar-school-name {
    font-weight: 800;
    font-size: 16px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

/* دکمه dark mode — شکیل و واکنش‌دار */
.theme-toggle-btn {
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
    position: relative;
}

.theme-toggle-btn:hover {
    transform: rotate(15deg) scale(1.1) !important;
}

html.dark-mode .theme-toggle-btn .mud-icon-root {
    color: #FBBF24 !important; /* زرد آفتاب */
}

html:not(.dark-mode) .theme-toggle-btn .mud-icon-root {
    color: #1D4ED8 !important; /* آبی ماه */
}

/* ==========================================================================
   6. Sidebar & Drawer
   ========================================================================== */

.modern-drawer .mud-drawer-content,
.mud-drawer-paper {
    background: var(--bg-sidebar) !important;
    border-left: 1px solid var(--border-subtle) !important;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.mud-drawer-paper::-webkit-scrollbar { width: 3px; }
.mud-drawer-paper::-webkit-scrollbar-thumb { background-color: var(--border-subtle); border-radius: 20px; }

/* لوگو در sidebar */
.sidebar-logo-text {
    font-weight: 800;
    font-size: 16px;
    color: var(--text-primary) !important;
    transition: color 0.3s ease;
}

/* بخش پروفایل کاربر در پایین sidebar */
.sidebar-user-name {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary) !important;
    transition: color 0.3s ease;
}

.sidebar-user-role {
    font-size: 10px;
    color: var(--text-muted) !important;
    transition: color 0.3s ease;
}

/* دکمه تغییر تم در sidebar */
.sidebar-theme-toggle {
    border-radius: var(--radius-md) !important;
    margin: 4px 12px !important;
    transition: var(--transition-base) !important;
}

.sidebar-theme-toggle:hover {
    background: var(--nav-link-hover-bg) !important;
}

/* ==========================================================================
   7. Common Page Components
   ========================================================================== */

/* کارت هدر صفحه */
.page-header-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.page-title {
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0;
    transition: color 0.3s ease;
}

.page-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
    flex-shrink: 0;
}

.page-header-icon .mud-icon-root { color: white !important; font-size: 1.75rem !important; }

/* دکمه اضافه کردن */
.btn-add {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    color: white !important;
    border-radius: var(--radius-md) !important;
    padding: 10px 20px !important;
    font-weight: 700 !important;
    text-transform: none !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25) !important;
    transition: all 0.2s ease !important;
}

.btn-add:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35) !important;
}

/* ==========================================================================
   8. Table & Data Grid
   ========================================================================== */

.modern-table .mud-table-head .mud-table-cell {
    font-weight: 700 !important;
    font-size: 12px !important;
    color: var(--text-secondary) !important;
    background: var(--bg-page) !important;
    padding: 14px 12px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.modern-table .mud-table-row {
    transition: background-color 0.15s ease !important;
}

.modern-table .mud-table-row:hover {
    background: var(--nav-link-hover-bg) !important;
}

.modern-table .mud-table-cell {
    border-bottom: 1px solid var(--border-color) !important;
    padding: 12px !important;
    color: var(--text-primary) !important;
    transition: border-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   9. Status Badges & Chips (سفارشی، نه override مودبلازر)
   ========================================================================== */

.badge-success {
    background: rgba(5, 150, 105, 0.12);
    color: #059669;
    font-weight: 700;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    line-height: 1.4;
}

.badge-error {
    background: rgba(225, 29, 72, 0.12);
    color: #E11D48;
    font-weight: 700;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    line-height: 1.4;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #D97706;
    font-weight: 700;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    line-height: 1.4;
}

.badge-info {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary-color);
    font-weight: 700;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    line-height: 1.4;
}

/* ==========================================================================
   10. Loading & Empty States
   ========================================================================== */

.state-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    color: var(--text-muted);
    gap: 1rem;
}

.state-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    text-align: center;
    color: var(--text-muted);
    gap: 0.75rem;
}

.state-empty-icon { font-size: 4rem !important; opacity: 0.3; }
.state-empty-text { font-size: 14px; max-width: 300px; }

/* حفظ کلاس‌های قدیمی برای سازگاری */
.loading-container { @extend .state-loading; }
.empty-state-container { @extend .state-empty; }
.empty-state-icon { font-size: 4rem !important; color: rgba(0,0,0,0.2); }
.empty-state-text { color: var(--text-secondary); }
.loading-text { color: var(--primary-color); }

/* ==========================================================================
   11. Mobile Card Components
   ========================================================================== */

.mobile-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
}

.mobile-card:hover {
    box-shadow: var(--shadow-card);
    transform: translateY(-2px);
}

/* ==========================================================================
   12. Stat Cards (در صفحه داشبورد)
   ========================================================================== */

.stat-card-custom {
    background: var(--bg-card);
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border-color);
    transition: all 0.25s ease;
    overflow: hidden;
}

.stat-card-custom:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card) !important;
}

.stat-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.stat-icon-blue    { background: rgba(37,99,235,0.1); }
.stat-icon-green   { background: rgba(5,150,105,0.1); }
.stat-icon-orange  { background: rgba(249,115,22,0.1); }
.stat-icon-purple  { background: rgba(124,58,237,0.1); }
.stat-icon-teal    { background: rgba(20,184,166,0.1); }
.stat-icon-red     { background: rgba(220,38,38,0.1); }

/* ==========================================================================
   13. Quick Access & Shortcut Buttons
   ========================================================================== */

.quick-btn {
    justify-content: flex-start !important;
    background: var(--nav-link-hover-bg) !important;
    border-radius: var(--radius-sm) !important;
    text-transform: none !important;
    padding: 10px 14px !important;
    color: var(--text-primary) !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    transition: var(--transition-base) !important;
    text-align: right !important;
    width: 100% !important;
}

.quick-btn:hover {
    background: var(--nav-link-active-bg) !important;
    color: var(--primary-color) !important;
}

/* ==========================================================================
   14. Dialog Customization
   ========================================================================== */

.dialog-gradient-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    color: white !important;
}

.dialog-gradient-header * { color: white !important; }

/* ==========================================================================
   15. Dark Mode — صفحه‌آرایی کلی
   ========================================================================== */

html.dark-mode body {
    background: var(--bg-page) !important;
    color: var(--text-primary);
}

/* کارت‌های MudBlazor در دارک مود — MudTheme این را هندل می‌کند
   اما برای اطمینان از transition نرم: */
html.dark-mode .mud-paper {
    transition: background-color 0.3s ease, border-color 0.3s ease !important;
}

html.dark-mode .page-header-card,
html.dark-mode .mobile-card,
html.dark-mode .stat-card-custom {
    border-color: var(--border-subtle);
}

/* ==========================================================================
   16. Responsive
   ========================================================================== */

@media (max-width: 960px) {
    .page-header-card { padding: 16px; }
    .page-header-icon { width: 44px; height: 44px; }
}

@media (max-width: 600px) {
    .page-header-card {
        padding: 14px;
        border-radius: var(--radius-md);
        margin-bottom: 16px;
    }
    .page-header-icon { width: 38px; height: 38px; }
    .btn-add { width: 100%; margin-top: 10px; }
}
.dynamic-spacer {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    height: 85% !important;
}
/* ایجاد افکت نرم برای باز و بسته شدن */
.modern-sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow-x: hidden !important;
    border-left: 1px solid var(--mud-palette-divider);
}

/* وقتی منو در حالت Mini (بسته) است */
.mud-drawer--closed.mud-drawer-mini-right .sidebar-greeting-text,
.mud-drawer--closed.mud-drawer-mini-right .sidebar-profile-text,
.mud-drawer--closed.mud-drawer-mini-right .sidebar-profile-chevron,
.mud-drawer--closed.mud-drawer-mini-right .mud-nav-link-text {
    display: none;
}

/* استایل آیکون‌ها در حالت بسته برای تمرکز بیشتر کاربر */
.mud-drawer--closed.mud-drawer-mini-right .mud-nav-link .mud-nav-link-icon {
    margin-inline: 0 !important;
    transition: transform 0.2s;
}

/* بزرگنمایی ملایم آیکون هنگام هاور در حالت بسته */
.mud-drawer--closed.mud-drawer-mini-right .mud-nav-link:hover .mud-nav-link-icon {
    transform: scale(1.1);
}

/* رفع مشکل فضای خالی در موبایل */
@media (max-width: 959px) {
    .mud-main-content {
        padding-right: 0 !important;
    }
}