/* ============================================================
   سامانه‌ی مدرسه — سیستم طراحی مشترک
   ایده: روز = دفتر و کاغذ کلاس (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); }

/* ---------------- فرم‌ها ---------------- */
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) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-inline-start: none; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; overflow-x: auto; gap: 4px; }
  .sidebar nav a { white-space: nowrap; border-inline-end: none; border-bottom: 3px solid transparent; }
  .sidebar nav a.active { border-bottom-color: var(--accent); }
  .field-row { grid-template-columns: 1fr; }
  .content { padding: 18px; }
}
