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

:root {
  direction: rtl;
  color-scheme: light; /* جلوگیری از تیره‌شدنِ خودکار کنترل‌های فرم (select، تاریخ و ...)
                           توسط حالت تاریک گوشی — یکی از دلایل رایج «رنگش با لپ‌تاپ فرق داره» */
  --primary-50:  #faf5ff;
  --primary-100: #f3e8ff;
  --primary-200: #e9d5ff;
  --primary-300: #d8b4fe;
  --primary-400: #c084fc;
  --primary-500: #a855f7;
  --primary-600: #9333ea;
  --primary-700: #7e22ce;
  --primary-800: #6b21a8;
  --primary-900: #581c87;
}

* {
  font-family: 'Vazirmatn', sans-serif;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* حذف فلاش خاکستری/آبی زشت روی دکمه‌ها هنگام لمس در گوشی */
}

html, body {
  overflow-x: hidden; /* از اسکرول افقی ناخواسته‌ی گوشی (که ظاهر صفحه را به‌هم می‌ریزد) جلوگیری می‌کند */
}

body {
  background-color: #f8f5ff;
  color: #1e1b2e;
  direction: rtl;
  margin: 0;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--primary-500); border-radius: 3px; }

/* ===== فرم‌ها ===== */
.input-base {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  outline: none;
  transition: all .15s;
  background: #fff;
}
.input-base:focus {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px var(--primary-100);
}

/* ===== دکمه‌ها ===== */
.btn-primary {
  background: var(--primary-600);
  color: #fff;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  transition: all .2s;
}
.btn-primary:hover { background: var(--primary-700); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: #fff;
  border: 1px solid var(--primary-200);
  color: var(--primary-700);
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-secondary:hover { background: var(--primary-50); }

.btn-danger {
  background: #ef4444;
  color: #fff;
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  transition: all .2s;
}
.btn-danger:hover { background: #dc2626; }

/* ===== کارت ===== */
.card {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  border: 1px solid #f3f4f6;
  padding: 1.5rem;
}

.page-title { font-size: 1.5rem; font-weight: 700; color: #1f2937; margin-bottom: 1.5rem; }

/* زیرتب‌های صفحه‌ی «ارزشیابی‌ها»ی دانش‌آموز (جاری / نتایج) */
.student-exams-subtabs { display: flex; gap: .5rem; margin-bottom: 1.5rem; background: #f3f4f6; padding: .3rem; border-radius: .9rem; width: fit-content; max-width: 100%; overflow-x: auto; }
.student-exams-subtab-btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1rem; border-radius: .7rem; border: none;
  background: transparent; color: #6b7280; font-size: .85rem; font-weight: 600; cursor: pointer;
  font-family: inherit; white-space: nowrap; transition: background .15s, color .15s;
}
.student-exams-subtab-btn.active { background: #fff; color: var(--primary-700); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.student-exams-subtab-btn:hover:not(.active) { color: #1f2937; }

/* ===== سایدبار ===== */
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-radius: .75rem;
  font-size: .875rem; font-weight: 500; color: #4b5563;
  transition: all .2s; cursor: pointer; text-decoration: none;
}
.nav-link:hover { background: var(--primary-50); color: var(--primary-700); }
.nav-link.active { background: var(--primary-100); color: var(--primary-800); font-weight: 600; }

/* ===== جدول ===== */
.table-base { width: 100%; font-size: .875rem; border-collapse: collapse; }
.table-base th { text-align: right; background: #f9fafb; padding: .75rem 1rem; font-weight: 600; color: #4b5563; border-bottom: 1px solid #f3f4f6; }
.table-base td { padding: .75rem 1rem; border-bottom: 1px solid #f9fafb; color: #374151; }
.table-base tr:last-child td { border-bottom: none; }
.table-base tr:hover td { background: rgba(250,245,255,.6); }

/* ===== نشان (Badge) ===== */
.badge { display: inline-flex; align-items: center; padding: .125rem .625rem; border-radius: 9999px; font-size: .75rem; font-weight: 500; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-purple { background: var(--primary-100); color: var(--primary-700); }
.badge-yellow { background: #fef9c3; color: #a16207; }

/* ===== ابزارهای عمومی جایگزین کلاس‌های یوتیلیتی Tailwind که مستقیماً در HTML لازم بود ===== */
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none !important; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.rounded-xl { border-radius: .75rem; }
.rounded-2xl { border-radius: 1rem; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== لودینگ ===== */
.loader {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 3px solid var(--primary-100); border-top-color: var(--primary-600);
  animation: spin .8s linear infinite; margin: 3rem auto;
}

/* ===== چیدمان اصلی پنل‌ها (سایدبار + محتوا) ===== */
.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; background: #f8f5ff; }

.app-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem .75rem;
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-topbar-title { font-size: 1rem; font-weight: 700; color: #1f2937; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-toggle-btn {
  background: none; border: none; cursor: pointer; color: #4b5563;
  display: flex; align-items: center; justify-content: center;
  padding: .375rem; border-radius: .5rem; flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--primary-50); }

/* دکمه‌ی خروج از حساب که همیشه (در همه‌ی تب‌ها، بدون نیاز به باز کردن
   منوی کشویی) بالای صفحه‌ی موبایل، داخل یک کادر مشخص، در دسترس است. */
.topbar-logout-btn {
  background: #fef2f2; border: 1px solid #fee2e2; color: #dc2626;
  display: flex; align-items: center; justify-content: center;
  padding: .4rem .55rem; border-radius: .6rem; flex-shrink: 0; cursor: pointer;
}
.topbar-logout-btn:hover { background: #fee2e2; }

.app-sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(17, 12, 34, .45); z-index: 30;
}
.app-sidebar-overlay.open { display: block; }

.app-sidebar {
  width: 260px; background: #fff; border-left: 1px solid #f3f4f6;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.app-sidebar-header { padding: 1.5rem; border-bottom: 1px solid #f3f4f6; }
.app-sidebar-header h2 { font-size: 1.1rem; font-weight: 700; color: #1f2937; margin: 0; }
.app-sidebar-header p { font-size: .8rem; color: #6b7280; margin: .25rem 0 0; }
.app-sidebar-nav { flex: 1; padding: 1rem; display: flex; flex-direction: column; gap: .25rem; overflow-y: auto; }
.app-sidebar-footer { padding: 1rem; border-top: 1px solid #f3f4f6; display: flex; flex-direction: column; gap: .5rem; }

.app-main { flex: 1; padding: 2rem; overflow-y: auto; max-height: 100vh; min-width: 0; }

/* نوار اطلاعاتی بالای صفحه (اسم مدرسه + تاریخ/ساعت دقیق) — در پنل‌های
   معلم/مدیر/دانش‌آموز، همیشه بالای محتوا و مستقل از باز/بسته بودن
   سایدبار (روی موبایل) دیده می‌شود. */
.app-info-bar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: .5rem 1rem; background: #fff; border: 1px solid #f3f4f6; border-radius: .85rem;
  padding: .9rem 1.25rem; margin-bottom: 1.25rem; position: sticky; top: 0; z-index: 15;
  box-shadow: 0 1px 3px rgba(0,0,0,.03);
}
.app-info-bar-school {
  display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; color: var(--primary-700);
}
.app-info-bar-clock {
  font-size: .875rem; color: #6b7280; font-variant-numeric: tabular-nums;
}

/* ===== صفحه‌ی آزمون ===== */
.exam-answer-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .5rem; }

/* ===== دکمه‌های عملیات روی کارت ارزشیابی (لیست ارزشیابی‌های توسعه‌دهنده) ===== */
.exam-action-btn {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .5rem .75rem; border-radius: .6rem; border: none;
  font-size: .8rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: filter .15s;
}
.exam-action-btn:hover { filter: brightness(.95); }

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .app-topbar { display: flex; }
  .app-sidebar {
    position: fixed; top: 0; right: 0; width: 80vw; max-width: 300px;
    /* «100vh» روی گوشی، ارتفاع واقعی صفحه (بدون نوار آدرس) را حساب
       نمی‌کند و باعث می‌شد دکمه‌ی «خروج از حساب» پایین منو، پایین‌تر از
       صفحه‌ی واقعی و نیازمند اسکرول باشد. «100dvh» ارتفاع واقعیِ دیدِ
       فعلی مرورگر را در نظر می‌گیرد. */
    height: 100vh;
    height: 100dvh;
    z-index: 40;
    transform: translateX(100%);
    transition: transform .25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,.15);
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { padding: 1rem; max-height: none; }
  .card { padding: 1rem; }
  .page-title { font-size: 1.25rem; margin-bottom: 1rem; }
  .table-base { display: block; overflow-x: auto; white-space: nowrap; }

  /* ===== صفحه‌ی آزمون در گوشی ===== */
  .exam-header-row1 { padding: .625rem .75rem !important; }
  .exam-header-row2 { padding: 0 .75rem .5rem !important; }
  .exam-timer { font-size: .95rem !important; padding: .4rem .75rem !important; }
  .exam-subject-name { font-size: .8rem !important; }
  .exam-answer-grid { grid-template-columns: repeat(4, 1fr) !important; }
  .exam-footer-inner { padding: .75rem !important; gap: .5rem !important; }
  .exam-footer-inner .btn-primary,
  .exam-footer-inner .btn-secondary { padding: .625rem .9rem !important; font-size: .8rem !important; white-space: nowrap; }
  main#examQuestionsWrap { padding: 1rem .75rem !important; }

  /* روی گوشی، متن بزرگ‌تر نوار اسم مدرسه کمی کوچک‌تر می‌شود تا جا بیفتد */
  .app-info-bar-school { font-size: 1rem !important; }
}

@media (max-width: 380px) {
  .exam-answer-grid { grid-template-columns: repeat(3, 1fr) !important; }
  .exam-footer-step-label { display: none; } /* روی گوشی‌های خیلی باریک، متن «بخش X از Y» برای جادادن دکمه‌ها مخفی می‌شود */
}

/* ===================================================
   صفحه‌ی اصلی (Home) — مدیر / معلم / دانش‌آموز
   =================================================== */
@keyframes homeFadeUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* نوار بالای صفحه‌ی اصلی: اسم کاربر + زنگوله‌ی اعلان — به‌جای یک کادر
   بزرگ تزئینی، عمداً کم‌حجم است تا بیشترین جا برای چیزهایی که واقعاً
   کاربر لازم دارد (آمار و کارهای فوری) در همان نگاه اول باقی بماند. */
.home-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.home-topbar-sub { font-size: 1.05rem; font-weight: 700; color: #1f2937; margin: 0; }
.home-bell-btn {
  position: relative; width: 2.75rem; height: 2.75rem; border-radius: .9rem; flex-shrink: 0;
  background: #fff; border: 1px solid #f3f4f6; color: var(--primary-700);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .15s, transform .15s;
}
.home-bell-btn:hover { background: var(--primary-50); transform: translateY(-2px); }
.home-bell-badge {
  position: absolute; top: -5px; right: -5px; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem;
  background: #e11d48; color: #fff; font-size: .65rem; font-weight: 700; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; font-variant-numeric: tabular-nums;
}
.home-bell-badge-text {
  top: -.4rem; right: -1.6rem; min-width: auto; height: auto; padding: .15rem .5rem;
  border-radius: .6rem; white-space: nowrap; font-size: .62rem;
}

/* کارهایی که همین الان نیاز به توجه دارند — اول از همه دیده می‌شود */
.home-alerts { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.5rem; }
.home-alert {
  display: flex; align-items: center; gap: .8rem; padding: .85rem 1.1rem; border-radius: 1rem;
  border: 1px solid; cursor: pointer; transition: transform .15s, box-shadow .15s;
  animation: homeFadeUp .4s ease both;
}
.home-alert:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(17,12,34,.06); }
.home-alert-rose   { background: #fff1f2; border-color: #fecdd3; }
.home-alert-gold   { background: #fffbeb; border-color: #fde68a; }
.home-alert-violet { background: var(--primary-50); border-color: var(--primary-100); }
.home-alert-icon { width: 2.25rem; height: 2.25rem; border-radius: .7rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.home-alert-text { font-size: .85rem; font-weight: 600; color: #1f2937; flex: 1; }
.home-alert-text small { display: block; font-weight: 400; color: #6b7280; font-size: .75rem; margin-top: .15rem; }
.home-alert-chevron { color: #9ca3af; flex-shrink: 0; }

/* پنلِ جزئیاتِ اعلان‌ها (باز شده با کلیک روی زنگوله) */
.home-notif-item {
  display: flex; align-items: center; gap: .65rem; width: 100%; text-align: right;
  padding: .8rem .9rem; border-radius: .9rem; border: none; background: #f9fafb;
  cursor: pointer; font-family: inherit; font-size: .85rem; color: #1f2937; transition: background .15s;
}
.home-notif-item:hover { background: #f3f4f6; }
.home-notif-item-icon { width: 2.1rem; height: 2.1rem; border-radius: .65rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.home-notif-item-text { flex: 1; }

/* دکمه‌های «دسترسی سریع» به قابلیت‌های فعال — یک شبکه از دکمه‌های بزرگ */
.home-quick-access { display: grid; grid-template-columns: repeat(2, 1fr); gap: .85rem; margin-bottom: 1.5rem; }
.home-quick-btn {
  display: flex; align-items: center; gap: .75rem; padding: 1rem 1.1rem; border-radius: 1rem;
  background: #fff; border: 1px solid #f3f4f6; cursor: pointer; text-align: right;
  font-family: inherit; transition: transform .15s, box-shadow .15s; animation: homeFadeUp .45s ease both;
}
.home-quick-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(17,12,34,.07); }
.home-quick-btn-icon { width: 2.5rem; height: 2.5rem; border-radius: .8rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.home-quick-btn-label { font-size: .9rem; font-weight: 600; color: #1f2937; }

.home-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.home-stat-card {
  background: #fff; border-radius: 1rem; padding: 1.1rem 1.25rem; border: 1px solid #f3f4f6;
  display: flex; align-items: center; gap: .9rem; transition: transform .2s, box-shadow .2s;
  animation: homeFadeUp .5s ease both;
}
.home-stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(88,28,135,.09); }
.home-stat-card:nth-child(1) { animation-delay: .05s; }
.home-stat-card:nth-child(2) { animation-delay: .1s; }
.home-stat-card:nth-child(3) { animation-delay: .15s; }
.home-stat-card:nth-child(4) { animation-delay: .2s; }
.home-stat-icon { width: 2.75rem; height: 2.75rem; border-radius: .85rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.home-stat-icon-violet { background: var(--primary-100); color: var(--primary-700); }
.home-stat-icon-gold   { background: #fef3c7; color: #b45309; }
.home-stat-icon-teal   { background: #ccfbf1; color: #0f766e; }
.home-stat-icon-rose   { background: #ffe4e6; color: #be123c; }
.home-stat-value { font-size: 1.5rem; font-weight: 800; color: #1f2937; font-variant-numeric: tabular-nums; line-height: 1.15; }
.home-stat-label { font-size: .78rem; color: #6b7280; margin-top: .1rem; }

.home-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; align-items: start; }
.home-card { animation: homeFadeUp .55s ease both; animation-delay: .1s; }
.home-card-title { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: #1f2937; font-size: 1rem; margin-bottom: 1.1rem; }
.home-card-title-icon { width: 2rem; height: 2rem; border-radius: .6rem; background: var(--primary-50); color: var(--primary-700); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.home-ring-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.home-ring { position: relative; width: 128px; height: 128px; flex-shrink: 0; }
.home-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.home-ring circle { fill: none; stroke-width: 11; }
.home-ring circle.home-ring-bg { stroke: var(--primary-50); }
.home-ring circle.home-ring-fg { stroke-linecap: round; transition: stroke-dashoffset 1.1s cubic-bezier(.22,.9,.3,1); }
.home-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.home-ring-center b { font-size: 1.4rem; font-weight: 800; color: #1f2937; font-variant-numeric: tabular-nums; }
.home-ring-center span { font-size: .68rem; color: #9ca3af; margin-top: .1rem; }
.home-ring-info { flex: 1; min-width: 160px; }
.home-ring-info h4 { margin: 0 0 .35rem; font-size: .95rem; font-weight: 700; color: #1f2937; }
.home-ring-info p { margin: 0; font-size: .8rem; color: #6b7280; line-height: 1.7; }

.home-empty { text-align: center; color: #9ca3af; padding: 2.25rem 0; font-size: .875rem; }
.home-empty svg { opacity: .5; margin-bottom: .5rem; }

.home-mini-row { display: flex; align-items: center; justify-content: space-between; padding: .7rem 0; border-bottom: 1px dashed #f3f4f6; font-size: .85rem; }
.home-mini-row:last-child { border-bottom: none; }
.home-mini-row-label { color: #6b7280; }
.home-mini-row-value { font-weight: 700; color: #1f2937; font-variant-numeric: tabular-nums; }

.home-motivation {
  display: flex; align-items: center; gap: .75rem; padding: 1rem 1.1rem; border-radius: 1rem;
  background: linear-gradient(90deg, #fef3c7, #fff7ed); border: 1px solid #fde68a; margin-bottom: 1.25rem;
  animation: homeFadeUp .5s ease both;
}
.home-motivation-icon { width: 2.5rem; height: 2.5rem; border-radius: .75rem; background: #fef3c7; color: #b45309; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.home-motivation p { margin: 0; font-size: .875rem; color: #78350f; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .home-stat-card, .home-card, .home-motivation, .home-alert { animation: none; }
  .home-ring circle.home-ring-fg { transition: none; }
}

@media (max-width: 768px) {
  .home-topbar-sub { font-size: .95rem; }
  .home-stats-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .home-stat-card { padding: .9rem 1rem; }
  .home-stat-value { font-size: 1.25rem; }
  .home-grid { grid-template-columns: 1fr; }
  .home-ring-wrap { justify-content: center; text-align: center; }
  .home-ring-info { text-align: center; min-width: 0; }
}

/* ===== ارتباط با دانش‌آموزان/معلم (پیام‌رسانی) ===== */
#msgListWrap { scroll-behavior: smooth; }
#msgListWrap img { transition: opacity .15s; }
#msgListWrap img:hover { opacity: .9; }
#msgTextInput:focus { outline: none; }
@media (max-width: 768px) {
  .card[style*="height:60vh"] { height: 70vh !important; }
}
