/* ============================================================
   سامانه‌ی مدرسه — سیستم طراحی مشترک
   ایده: روز = دفتر و کاغذ کلاس (paper/ledger)
        شب = تخته‌سیاه کلاس (chalkboard)
   ============================================================ */

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

:root {
  /* ---- روز: کاغذ دفتر مدرسه ---- */
  --bg: #f4efe2;
  --surface: #fffdf8;
  --surface-2: #ece5d3;
  --ink: #26241d;
  --ink-soft: #6b6555;
  --line: #ddd3ba;
  --accent: #b8842e;       /* طلایی/زعفرانی - مثل مهر روی کارنامه */
  --accent-ink: #fffdf8;
  --accent-2: #2f6f63;     /* سبز تخته - برای وضعیت‌های مثبت */
  --danger: #a33d3d;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(38, 36, 29, 0.06);
  --font: 'Vazirmatn', Tahoma, sans-serif;
}

html[data-theme="night"] {
  /* ---- شب: تخته‌سیاه کلاس ---- */
  --bg: #16221e;
  --surface: #1e2f29;
  --surface-2: #253a33;
  --ink: #eae3cf;
  --ink-soft: #a9b3ab;
  --line: #35493f;
  --accent: #e0b158;
  --accent-ink: #16221e;
  --accent-2: #7fbfae;
  --danger: #e08585;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  direction: rtl;
}

body {
  min-height: 100vh;
  transition: background .25s ease, color .25s ease;
}

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }
p { line-height: 1.9; color: var(--ink-soft); margin: 0 0 1em; }
a { color: inherit; }

/* ---------------- دکمه‌ی روز/شب ---------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: background .2s;
}
.theme-toggle:hover { background: var(--line); }

/* ---------------- ساختار کلی صفحه ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}

.app-shell { display: flex; min-height: calc(100vh - 62px); }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  padding: 18px 12px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14.5px;
  margin-bottom: 2px;
  border-inline-end: 3px solid transparent;
  cursor: pointer;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--ink); }
.sidebar nav a.active {
  background: var(--surface-2);
  color: var(--ink);
  border-inline-end-color: var(--accent);
  font-weight: 600;
}

.content { flex: 1; padding: 26px 30px; max-width: 1180px; }

/* ---------------- کارت‌ها و جدول ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card > h3 { font-size: 15px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .num { font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1.3; }
.stat .lbl { font-size: 13px; color: var(--ink-soft); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; font-size: 12.5px; }
tbody tr:hover { background: var(--surface-2); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
}
.badge.ok { color: var(--accent-2); border-color: var(--accent-2); }
.badge.warn { color: var(--accent); border-color: var(--accent); }
.badge.danger { color: var(--danger); border-color: var(--danger); }
.badge.info { color: #6d5bd0; border-color: #6d5bd0; }

/* ---------------- فرم‌ها ---------------- */
label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  margin-bottom: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  transition: opacity .15s, transform .05s;
}
button:hover, .btn:hover { opacity: .9; }
button:active, .btn:active { transform: translateY(1px); }
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }

.hint { font-size: 12.5px; color: var(--ink-soft); margin-top: -8px; margin-bottom: 14px; }
.error-box {
  background: rgba(163, 61, 61, .08);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}
.success-box {
  background: rgba(47, 111, 99, .08);
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

/* ---------------- صفحه‌ی ورود ---------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}
.auth-page .theme-toggle { position: absolute; top: 20px; left: 20px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.auth-card .brand-mark { margin: 0 auto 16px; }
.auth-card h1 { text-align: center; font-size: 20px; }
.auth-card .subtitle { text-align: center; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 26px; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.35} 50%{opacity:1} }

.muted { color: var(--ink-soft); font-size: 13px; }

@media (max-width: 760px) {
  .field-row { grid-template-columns: 1fr; }
  .content { padding: 18px; }
}

/* ============================================================
   لانچر گوشی — منوی همه‌ی نقش‌ها مثل صفحه‌ی اصلی گوشی
   (مدیر، معاون، معلم، دانش‌آموز، ولی، مشاور)
   • صفحه‌ی اصلی: شبکه‌ی آیکون‌های رنگی با نام زیرشان
   • لمس هر آیکون: فقط همان بخش باز می‌شود
   • نوار بالا: دکمه‌ی «برگشت» به صفحه‌ی آیکون‌ها
   منطق: assets/js/appLauncher.js
   ============================================================ */

/* پالت رنگ آیکون‌ها */
.lx-c-blue   { --lx-a: #6aa8ff; --lx-b: #3467dc; }
.lx-c-indigo { --lx-a: #8b8fff; --lx-b: #4d51d6; }
.lx-c-violet { --lx-a: #b08aff; --lx-b: #7146d8; }
.lx-c-pink   { --lx-a: #ff86b5; --lx-b: #d54473; }
.lx-c-red    { --lx-a: #ff8272; --lx-b: #d5443b; }
.lx-c-orange { --lx-a: #ffab55; --lx-b: #dd6b18; }
.lx-c-amber  { --lx-a: #ffd25a; --lx-b: #d69a0a; }
.lx-c-green  { --lx-a: #66d692; --lx-b: #25955a; }
.lx-c-teal   { --lx-a: #45d0c4; --lx-b: #14908b; }
.lx-c-cyan   { --lx-a: #58c8fa; --lx-b: #1f8bd0; }
.lx-c-brown  { --lx-a: #d0a575; --lx-b: #8d6236; }
.lx-c-slate  { --lx-a: #93a4b8; --lx-b: #56667d; }

/* دسکتاپ: همان منوی قبلی؛ فقط ایموجی مرتبط‌تر. برچسب کوتاهِ آیکون و نوار برگشت دیده نمی‌شوند */
.lx-ico { flex-shrink: 0; line-height: 1; }
.lx-short { display: none; }
.lx-appbar { display: none; }
.sidebar nav a > span:empty,
.tabs .tab-btn > span:empty:not(.tab-badge) { display: none; }
.nav-sep { border-top: 1px solid var(--line); margin: 12px 6px; }
.nav-sep.nav-sep-first { display: none; }

/* نوار «برگشت» (فقط در گوشی و داخل یک بخش دیده می‌شود) */
.lx-appbar {
  align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 40;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.lx-back {
  gap: 4px; padding: 7px 10px 7px 14px;
  border-radius: 999px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.lx-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.lx-app-ico {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
  background: linear-gradient(155deg, var(--lx-a, #93a4b8), var(--lx-b, #56667d));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.lx-app-title { font-size: 15px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes lx-fade { from { opacity: 0; } to { opacity: 1; } }

/* گوشی: عرض کم، یا هر دستگاه لمسی (حتی وقتی مرورگر روی «نسخه‌ی دسکتاپ» است و عرض ۹۸۰px نشان می‌دهد) */
@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  /* نوار بالا فشرده؛ داخل بخش، برای جا باز کردن، پنهان می‌شود (خروج/تم از صفحه‌ی آیکون‌ها) */
  .topbar { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  body.lx-app .topbar { display: none; }
  body.lx-app .lx-appbar { display: flex; }

  /* --- مدیر و معاون: منوی کناری = صفحه‌ی آیکون‌ها؛ محتوا فقط داخل بخش --- */
  .app-shell { display: block; min-height: 0; }
  .app-shell > .content { display: none; }
  /* اگر بخشی عریض‌تر از صفحه بود، فقط خودِ محتوا افقی اسکرول شود، نه کل صفحه و نوار برگشت */
  body.lx-app .app-shell > .content { display: block; overflow-x: auto; animation: lx-fade .16s ease; }
  body.lx-app .app-shell > .sidebar { display: none; }
  .sidebar { width: 100%; border: 0; background: transparent; padding: 18px 14px 32px; }

  /* --- معلم، دانش‌آموز، ولی، مشاور: دکمه‌های تب = صفحه‌ی آیکون‌ها؛ فقط تب باز داخل بخش --- */
  body:not(.lx-app) > .content > [id^="tab"] { display: none !important; }
  body.lx-app > .content > :not([id^="tab"]) { display: none !important; }
  body.lx-app > .content { overflow-x: auto; animation: lx-fade .16s ease; }
  body > .content > .tabs { margin: 6px 0 28px; }

  /* شبکه‌ی آیکون‌ها */
  .sidebar nav,
  body > .content > .tabs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 20px 4px;
    align-items: start;
  }

  /* عنوان گروه‌ها (مثل پوشه‌ها) — فقط پنل مدیر */
  .sidebar nav .nav-sep,
  .sidebar nav .nav-sep.nav-sep-first {
    grid-column: 1 / -1;
    display: flex; align-items: center; gap: 10px;
    border: 0; margin: 4px 2px -6px;
    font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  }
  .sidebar nav .nav-sep.nav-sep-first { margin-top: 0; }
  .sidebar nav .nav-sep::before { content: attr(data-group); }
  .sidebar nav .nav-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

  /* خودِ آیکون (ظاهر اپ گوشی) */
  .sidebar nav a.lx-tile,
  body > .content > .tabs .tab-btn.lx-tile {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 6px; width: 100%; min-height: 0; margin: 0; padding: 0;
    background: none; border: 0; border-radius: 0; box-shadow: none; opacity: 1;
    color: var(--ink); font-family: var(--font);
    font-size: 11px; font-weight: 500; line-height: 1.45; text-align: center;
    white-space: normal; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .sidebar nav a.lx-tile:hover,
  .sidebar nav a.lx-tile.active,
  body > .content > .tabs .tab-btn.lx-tile:hover,
  body > .content > .tabs .tab-btn.lx-tile.active {
    background: none; color: var(--ink); font-weight: 500; border: 0;
  }
  .lx-tile .lx-ico {
    width: clamp(48px, 14vw, 60px); height: clamp(48px, 14vw, 60px);
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: clamp(24px, 7vw, 30px);
    background: linear-gradient(155deg, var(--lx-a, #93a4b8), var(--lx-b, #56667d));
    box-shadow: 0 4px 9px -4px rgba(20, 20, 20, .45), inset 0 0 0 2px rgba(255,255,255,.28);
    transition: transform .12s ease;
  }
  .lx-tile:active .lx-ico { transform: scale(.9); }
  .lx-tile .lx-lbl { max-width: 100%; }
  .lx-tile .lx-full { display: none; }
  .lx-tile .lx-short {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; word-break: normal;
  }

  /* نوار دکمه‌های بالای بخش‌ها (مثل «+ دانش‌آموز جدید») در گوشی شکسته شود، نه اینکه از صفحه بیرون بزند */
  .toolbar > div { flex-wrap: wrap; }
  .toolbar button { white-space: nowrap; }

  /* نشانه‌ی خبر جدید / شمارنده‌ی روی گوشه‌ی آیکون */
  .lx-tile > span:not(.lx-ico):not(.lx-lbl):not(:empty) {
    position: absolute; top: -5px; left: calc(50% + 7px); z-index: 1;
  }
  .lx-tile .badge { background: var(--surface); font-size: 11px; padding: 1px 7px; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
  .lx-tile .tab-badge { top: -1px; left: calc(50% + 15px); width: 12px; height: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  body.lx-app .app-shell > .content, body.lx-app > .content { animation: none; }
  .lx-tile .lx-ico { transition: none; }
}

/* جدول هفتگیِ برنامه‌ی کلاسی (روز × زنگ) — قابل استفاده در پنل مدیر/دانش‌آموز/ولی و در پنجره‌ی چاپ */
.schedule-grid { width: 100%; border-collapse: collapse; }
.schedule-grid th, .schedule-grid td { border: 1px solid var(--line); padding: 8px 6px; text-align: center; font-size: 13.5px; }
.schedule-grid thead th { background: var(--bg-soft, #f3f1ea); font-weight: 700; }
.schedule-grid td.sg-day { background: var(--bg-soft, #f8f7f2); font-weight: 700; white-space: nowrap; }
.schedule-grid td.sg-holiday { color: #a33333; font-weight: 700; background: #fbeeee; }
.schedule-grid td.sg-empty { color: #bbb; }
.schedule-grid td.sg-extra { background: #f4faf2; }
.schedule-grid th.sg-extra-head { background: #eef5ec; }
.schedule-grid .sg-subject { font-weight: 600; }
.schedule-grid .sg-teacher { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }

/* ============================================================
   تقویم و یادآوری — بنر مناسبت امروز + پنل تقویم کامل
   (مشترک بین همه‌ی نقش‌ها: admin/vp/teacher/student/parent/counselor)
   ============================================================ */
.occ-banner {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  padding: 10px 16px; font-size: 14px; line-height: 1.8;
  border-radius: var(--radius); margin: 10px 16px 0;
}
.occ-banner .occ-date { font-weight: 700; white-space: nowrap; opacity: .9; font-size: 12.5px; }
.occ-banner .occ-text { font-weight: 700; font-size: 15.5px; }
.occ-banner.occ-plain { background: var(--surface-2); color: var(--ink, inherit); font-weight: 500; }
.occ-banner.occ-plain .occ-text { font-weight: 500; font-size: 13px; opacity: .8; }

.calw-wrap { max-width: 720px; }
.calw-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.calw-head button { padding: 6px 12px; }
.calw-title { font-weight: 700; font-size: 17px; }
.calw-weekdays, .calw-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calw-weekday { text-align: center; font-size: 12.5px; color: var(--ink-soft); font-weight: 700; padding: 4px 0; }
.calw-cell {
  position: relative; min-height: 58px; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px; cursor: pointer; background: var(--surface); transition: background .15s;
}
.calw-cell:hover { background: var(--surface-2); }
.calw-cell.calw-empty { visibility: hidden; cursor: default; }
.calw-cell.calw-today { border: 2px solid var(--accent); }
.calw-cell.calw-holiday .calw-daynum { color: #c23b3b; }
.calw-daynum { font-weight: 700; font-size: 14px; }
.calw-marks { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.calw-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); }
.calw-dot.calw-dot-remind { background: var(--accent); }
.calw-detail { margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius); }
.calw-detail h4 { margin: 0 0 8px; }
.calw-occ-item { font-size: 13.5px; margin-bottom: 4px; }
.calw-reminder-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.calw-reminder-row .rr-actions button { padding: 3px 8px; font-size: 12px; }
.calw-push-box { margin-top: 14px; padding: 10px 14px; border: 1px dashed var(--accent); border-radius: var(--radius); font-size: 13px; }
