/* NOTE(docs): با هر تغییر — حتی کوچک — docs/ را با جزئی‌ترین حالت ممکن به‌روز کنید | Keep docs/ updated with every change. */
/* ══════════════════════════════════════════════════════════════════
   کاکپیت فرماندهی ادمین کل کلاسیا (Superadmin Cockpit Enterprise)
   طراحی مدرن Glassmorphism، تم دارک/لایت، پایش زنده و رصد بی‌درنگ
   ══════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f5fa;
  --surface-3: #e8eef6;
  --border: #e2e8f0;
  --border-subtle: #edf2f7;
  --border-focus: #4f46e5;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-2: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.2);
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.07), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 30px -10px rgba(15, 23, 42, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --tap: 42px;
  --nav-h: 64px;
}

[data-theme="dark"] {
  --bg: #090d16;
  --surface: #111827;
  --surface-2: #162032;
  --surface-3: #1e293b;
  --border: #1f293d;
  --border-subtle: #172235;
  --border-focus: #6366f1;
  --text: #f8fafc;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-2: #1e1b4b;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --success: #10b981;
  --success-bg: #064e3b;
  --success-border: #047857;
  --warning: #f59e0b;
  --warning-bg: #451a03;
  --warning-border: #b45309;
  --danger: #f43f5e;
  --danger-bg: #4c0519;
  --danger-border: #9f1239;
  --info: #38bdf8;
  --info-bg: #0c4a6e;
  --info-border: #0284c7;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 45px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, sans-serif;
  font-size: 13.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; min-height: var(--tap); transition: all .15s ease; }
input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
label { font-size: 12px; font-weight: 600; color: var(--text-soft); display: block; margin: 10px 0 4px; }
[hidden] { display: none !important; }

/* ── ورود و احراز هویت ادمین کل (Auth Wrap) ── */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(circle at 50% 20%, rgba(99, 102, 241, 0.12), transparent 70%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0; right: 0; left: 0; height: 4px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #38bdf8);
}
.auth-logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.auth-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}
.auth-header-text h2 { margin: 0 0 2px; font-size: 20px; font-weight: 800; color: var(--text); }
.auth-header-text p { margin: 0; font-size: 12px; color: var(--muted); }
.otp-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 16px 0;
  direction: ltr;
}
.otp-row input {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  padding: 6px 0;
  height: 50px;
  border-radius: 12px;
  background: var(--surface-2);
}
.test-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--warning-bg);
  border: 1px dashed var(--warning-border);
  color: var(--warning);
  font-size: 11.5px;
  margin-top: 6px;
}

/* ── پوسته اصلی (App Shell) ── */
.app { min-height: 100vh; display: flex; }
.sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  position: fixed;
  right: 0; top: 0; bottom: 0;
  z-index: 65;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  position: relative;
}
.brand .logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  flex-shrink: 0;
}
.brand-info { flex: 1; min-width: 0; }
.brand-info strong { font-size: 14.5px; display: block; line-height: 1.3; }
.badge-adm {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: var(--primary-2);
  color: var(--primary);
  border: 1px solid var(--primary-glow);
  border-radius: 20px;
  padding: 2px 8px;
  display: inline-block;
  margin-top: 3px;
}

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-section-title {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 10px 4px;
}
.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: right;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 500;
  position: relative;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.on {
  background: var(--primary-2);
  color: var(--primary);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav button .nav-icon { font-size: 15px; width: 22px; text-align: center; }
.nav-badge {
  margin-right: auto;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
}
.nav-badge.orange { background: var(--warning); }
.nav-badge.green { background: var(--success); }

.main {
  width: calc(100% - 260px);
  margin-right: 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + 20px);
  transition: width .2s ease, margin-right .2s ease;
}

/* ── نوار بالا (Topbar) ── */
.topbar {
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px);
}
.menu-btn { display: none; }
.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
}
.server-pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
  font-size: 11px;
  font-weight: 600;
}
.pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}
.icon-btn {
  min-width: var(--tap);
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--muted); }
.live-clock-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  direction: ltr;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

/* ── محتوا (Content Area) ── */
.content {
  padding: 24px 28px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; color: var(--text); }
.page-head p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ── دکمه‌ها ── */
.btn {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}
.btn.danger:hover { filter: brightness(1.1); }
.btn.block { width: 100%; }

/* ── کارت‌ها و پانل‌ها ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.panel { padding: 20px; margin-bottom: 16px; }
.panel h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; color: var(--text); }

/* ── کارت‌های آمار (Stats Grid) ── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--primary), transparent);
}
.stat small { color: var(--muted); font-size: 12px; font-weight: 600; display: block; margin-bottom: 6px; }
.stat strong { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }

/* ── درخواست‌های مدیریت (Manager Requests) ── */
.req {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  transition: border-color .15s ease;
}
.req:hover { border-color: var(--border-focus); }
.req-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.spec-table {
  display: grid;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.spec-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px;
  align-items: baseline;
}
.spec-row:last-child { border-bottom: 0; }
.spec-row:nth-child(even) { background: var(--surface-2); }
.spec-k { color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.spec-v { font-weight: 600; color: var(--text); min-width: 0; overflow-wrap: anywhere; line-height: 1.8; }
@media (max-width: 540px) {
  .spec-row { grid-template-columns: 110px 1fr; padding: 8px 10px; }
}

/* ── جدول‌ها (Tables) ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 600px; background: var(--surface); }
th, td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--border); font-size: 12.5px; white-space: nowrap; }
thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 700; color: var(--text-soft); z-index: 2; font-size: 11.5px; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--primary); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }

/* ── وضعیت‌ها و بج‌ها (Badges & Status) ── */
.status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.status.green { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.status.orange { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.status.blue { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }
.status.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 12px;
  font-size: 11px;
  min-height: unset;
  line-height: 1.4;
  margin: 2px 3px 2px 0;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.status-badge:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.status-badge b { font-weight: 700; }
.status-badge .sep { opacity: .4; font-size: 10px; }
.status-badge .school-tag { opacity: .9; }
.status-badge .state-tag { font-size: 10px; opacity: .85; }

/* ── مودال‌ها و اورلی ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
}
.modal .box {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-height: 88vh;
  overflow-y: auto;
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.open { pointer-events: auto; }
.modal.open .box { opacity: 1; transform: scale(1); pointer-events: auto; }

/* ── توست‌ها ── */
#toasts {
  position: fixed;
  bottom: 24px;
  right: 16px; left: 16px;
  z-index: 80;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── اسکلت بارگذاری (Skeleton Loading) ── */
.skel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}
.skel {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 8px;
  min-height: 14px;
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(140, 160, 200, 0.2), transparent);
  animation: skelSh 1.3s infinite;
}
@keyframes skelSh { from { transform: translateX(100%); } to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* ── کارت خطا و مرز محافظتی (Error Boundary Card) ── */
.error-card {
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── کدهای میانبر و دسترسی‌پذیری ── */
kbd {
  font-family: inherit;
  font-size: 11px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--surface-2);
  color: var(--muted);
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── کنترل نوار کناری (Sidebar collapse & mobile) ── */
.side-close { display: none; position: absolute; top: 12px; left: 12px; }
body.sb-collapsed .sidebar { transform: translateX(100%); }
body.sb-collapsed .main { width: 100%; margin-right: 0; }
body.sb-collapsed .menu-btn { display: grid; }
body.nav-open .menu-btn { visibility: hidden; }

.bottomnav { display: none; }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 18px 16px; }
}

@media (max-width: 780px) {
  .sidebar { transform: translateX(100%); width: min(300px, 86vw); }
  .sidebar.open { transform: translateX(0); }
  .side-close { display: grid; }
  .main { width: 100%; margin-right: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 8px 14px; }
  .content { padding: 14px 12px 20px; }
  .page-head h1 { font-size: 19px; }
  .bottomnav {
    display: flex;
    position: fixed;
    bottom: 0; right: 0; left: 0;
    z-index: 50;
    height: var(--nav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    color: var(--muted);
    min-height: var(--nav-h);
  }
  .bottomnav button.on { color: var(--primary); font-weight: 700; }
  .bottomnav b { font-size: 16px; }
}

@media print {
  .sidebar, .topbar, .bottomnav, #toasts, .modal { display: none !important; }
  .main { width: 100%; margin: 0; padding: 0; }
  .card { break-inside: avoid; box-shadow: none; border-color: #ccc; }
}
