/* =========================================
   سامانه هوشمند آموزشی انصارالرضا (ع) | TopIdeas P2
   معماری ماژولار - فایل استایل‌های اصلی (پشتیبانی از Theme Engine)
   ========================================= */

@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

/* 🎨 متغیرهای رنگی پیش‌فرض (Fallback) */
:root {
    --bg-gradient: linear-gradient(135deg, #1e293b, #0f172a);
    --primary: #3b82f6;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    --transition-speed: 0.3s;
}

/* 🧹 ریست استایل‌ها */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    user-select: none; /* جلوگیری از انتخاب متون در موبایل */
    -webkit-tap-highlight-color: transparent;
}

/* ⚡️ یکپارچگی با موتور تنظیمات سامانه (Theme Engine) */
body {
    background: var(--bg-gradient);
    color: var(--text-main);
    overflow-x: hidden;
    transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* 🔄 کلاس‌های کاربردی و پایه */
.hidden {
    display: none !important;
}

.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    animation: fadeIn var(--transition-speed) ease;
}

.screen-active {
    display: block;
}

.full-width {
    width: 100%;
}

/* =========================================
   🔒 ۱. صفحه ورود امن (Login Screen)
   ========================================= */
#screen-login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-card-glass {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 30px 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.login-header-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    background: #fff;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

#login-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-card-glass h2 {
    color: #1e293b;
    font-weight: 800;
    margin-bottom: 5px;
}

.app-subtitle {
    color: #64748b;
    font-size: 0.9em;
    margin-bottom: 20px;
}

.login-input-field {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font-size: 1em;
    outline: none;
    transition: all var(--transition-speed);
    user-select: text; /* بازگردانی انتخاب برای فرم‌ها */
    -webkit-user-select: text;
}

.login-input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.error-msg {
    color: var(--danger);
    font-size: 0.9em;
    font-weight: bold;
    min-height: 20px;
    margin-bottom: 10px;
}

.brand-badge {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    background: #0f172a;
    padding: 10px;
    border-radius: 12px;
    color: white;
}

.brand-title {
    font-size: 0.7em;
    color: #94a3b8;
}

.brand-name {
    font-weight: bold;
    color: #fcd34d;
}

/* =========================================
   🎛️ دکمه‌ها
   ========================================= */
.btn {
    border: none;
    cursor: pointer;
    border-radius: 12px;
    font-weight: bold;
    transition: all var(--transition-speed);
    font-family: inherit;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 14px;
    font-size: 1.1em;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.primary-btn:active {
    transform: translateY(2px);
}

/* دکمه بازگشت سراسری */
#universal-back-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 9999;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: 2px solid rgba(255,255,255,0.4);
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

/* =========================================
   📱 ۲. داشبورد و شبکه‌های کارت
   ========================================= */
.modern-dashboard {
    padding: 20px 15px 80px; /* فضای خالی پایین برای منوی ناوبری */
    max-width: 600px;
    margin: 0 auto;
}

.md-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.md-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.md-avatar {
    font-size: 2.5em;
    background: rgba(255, 255, 255, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}

.md-greeting h3 {
    font-size: 1.2em;
    color: var(--text-main);
    margin: 0;
}

.md-greeting p {
    font-size: 0.8em;
    color: var(--text-muted);
    margin: 0;
}

.md-coins {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.neo-scroll-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* شبکه‌بندی (Grids) */
.neo-grid-1 { display: grid; grid-template-columns: 1fr; gap: 15px; }
.neo-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

/* کارت‌های داشبورد */
.neo-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition-speed);
}

.neo-card:active {
    transform: scale(0.96);
}

.neo-card h4 { margin: 0 0 5px; font-size: 1.1em; }
.neo-card p { margin: 0; font-size: 0.8em; opacity: 0.9; }
.neo-card .icon { font-size: 2.5em; }

.neo-card-small {
    flex-direction: column;
    text-align: center;
    padding: 15px;
}
.neo-card-small .icon { font-size: 2em; margin-bottom: 10px; }

/* تم‌های رنگی کارت‌ها */
.nc-blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.nc-orange { background: linear-gradient(135deg, #f97316, #c2410c); }
.nc-purple { background: linear-gradient(135deg, #a855f7, #7e22ce); }
.nc-pink { background: linear-gradient(135deg, #ec4899, #be185d); }
.nc-green { background: linear-gradient(135deg, #10b981, #047857); }
.nc-dark { background: linear-gradient(135deg, #334155, #0f172a); }

/* عناوین بخش‌ها */
.section-title {
    color: var(--primary);
    font-size: 0.95em;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 5px;
    margin: 15px 0 10px;
}

/* =========================================
   📝 فرم‌ها و تکالیف (معلم و دانش‌آموز)
   ========================================= */
.neo-form-card {
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    margin-bottom: 20px;
}

.form-title {
    color: var(--primary);
    margin-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.form-label {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: bold;
    display: block;
}

.highlight-label { color: #fcd34d; }

.form-input {
    width: 100%;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 15px;
    font-family: inherit;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.select-black-text option { color: #000; }

.form-row {
    display: flex;
    gap: 10px;
}
.form-col { flex: 1; }
.flex-1-2 { flex: 1.2; }
.flex-0-8 { flex: 0.8; }

.date-input, .time-input { 
    text-align: center; 
    border-color: rgba(252, 211, 77, 0.4); 
}
.date-input { cursor: pointer; font-weight: bold; }

.form-submit-btn {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    box-shadow: 0 5px 0 #075985;
    padding: 14px;
    color: white;
    margin-top: 10px;
}

/* =========================================
   🧭 نوار ناوبری پایین (Bottom Nav)
   ========================================= */
.md-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    padding: 10px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    border-top: 1px solid var(--border-color);
}

.md-nav-item {
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8em;
    transition: color var(--transition-speed);
}

.md-nav-item.active { color: var(--primary); font-weight: bold; }
.md-nav-icon { font-size: 1.5em; margin-bottom: 3px; }

.md-nav-fab {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    transform: translateY(-20px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.5);
    cursor: pointer;
    transition: transform var(--transition-speed);
}
.md-nav-fab:active { transform: translateY(-15px) scale(0.95); }

/* =========================================
   🔔 توست نوتیفیکیشن
   ========================================= */
#neo-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(5px);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    z-index: 10000;
    transition: opacity var(--transition-speed) ease;
}

/* =========================================
   ✨ انیمیشن‌ها
   ========================================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   Phase 5 Pilot — Mobile / weak-network UX
   ========================================= */
html {
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}
body {
    min-height: 100dvh;
    overscroll-behavior-y: none;
}
button, input, select, textarea {
    font: inherit;
}
input, textarea, [contenteditable="true"] {
    user-select: text;
    -webkit-user-select: text;
}
button, .btn, [role="button"] {
    touch-action: manipulation;
}
@media (max-width: 640px) {
    .screen { min-height: 100dvh; }
    #screen-login { min-height: 100dvh; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
    .login-card-glass { width: 100%; max-width: 420px; padding: 22px 16px; border-radius: 20px; }
    .modern-dashboard {
        width: 100%;
        max-width: none;
        padding:
            max(14px, env(safe-area-inset-top))
            12px
            calc(88px + env(safe-area-inset-bottom));
    }
    .md-header { gap: 10px; flex-wrap: wrap; }
    #universal-nav-actions {
        top: max(8px, env(safe-area-inset-top)) !important;
        left: max(8px, env(safe-area-inset-left)) !important;
        max-width: calc(100vw - 16px);
        flex-wrap: wrap;
    }
    #universal-back-btn {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        min-height: 40px;
    }
    .btn, button, input, select, textarea { min-height: 44px; }
}
@media (max-width: 380px) {
    .login-card-glass { padding-inline: 12px; }
    .md-header { align-items: flex-start; }
    #universal-nav-actions button { padding: 7px 9px !important; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

#network-status-banner {
    position: fixed;
    left: 50%;
    bottom: calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 999999;
    width: min(92vw, 520px);
    padding: 9px 14px;
    border-radius: 12px;
    background: rgba(127,29,29,.96);
    color: #fff;
    text-align: center;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
