/* ═══════════════════════════════════════════════
   سامانه نظارت هوشمند v2.0 — استایل مشترک
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

/* ── متغیرها ─────────────────────────────────── */
:root {
  --bg-base:    #030712;
  --bg-surface: #0a0f1e;
  --bg-card:    #0f172a;
  --bg-hover:   #1e293b;
  --bg-input:   #080d1a;
  --border:     #1e293b;
  --border-2:   #334155;

  --text-1: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;
  --text-4: #64748b;
  --text-5: #475569;

  --blue:       #0ea5e9;
  --blue-dark:  #0369a1;
  --blue-bg:    #0c1a3a;
  --blue-light: #38bdf8;

  --green:      #22c55e;
  --green-dark: #166534;
  --green-bg:   #052e16;

  --red:        #ef4444;
  --red-dark:   #7f1d1d;
  --red-bg:     #2d0a0a;

  --yellow:     #f59e0b;
  --yellow-dark:#78350f;
  --yellow-bg:  #2d1a00;

  --purple:     #a78bfa;
  --purple-bg:  #1e1040;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl:24px;

  --shadow-sm: 0 1px 8px rgba(0,0,0,0.3);
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.7);
  --shadow-blue: 0 4px 24px rgba(14,165,233,0.2);

  --sidebar-width: 248px;
  --header-h: 64px;
  --transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
}

/* Light mode */
[data-theme="light"] {
  --bg-base:    #f0f4f8;
  --bg-surface: #ffffff;
  --bg-card:    #ffffff;
  --bg-hover:   #f1f5f9;
  --bg-input:   #f8fafc;
  --border:     #e2e8f0;
  --border-2:   #cbd5e1;
  --text-1: #0f172a;
  --text-2: #1e293b;
  --text-3: #475569;
  --text-4: #64748b;
  --text-5: #94a3b8;
  --blue-bg: #eff6ff;
  --green-bg: #f0fdf4;
  --red-bg:  #fef2f2;
  --yellow-bg:#fffbeb;
  --purple-bg:#faf5ff;
  --shadow:  0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg:0 12px 48px rgba(0,0,0,0.12);
}

/* ── ریست ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-1);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

/* ── اسکرول‌بار ──────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-5); }

/* ── لایه‌بندی ───────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── سایدبار ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  right: 0; top: 0; bottom: 0;
  z-index: 300;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-inner { padding: 16px 12px; display: flex; flex-direction: column; min-height: 100%; gap: 2px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow-blue);
}

.sidebar-logo-text { font-size: 14px; font-weight: 800; color: var(--text-1); line-height: 1.2; }
.sidebar-logo-sub  { font-size: 11px; color: var(--text-4); margin-top: 2px; }

.nav-section {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-5);
  letter-spacing: 0.08em;
  padding: 14px 12px 5px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  cursor: pointer;
  position: relative;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-2); }
.nav-item.active {
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--blue);
  border-radius: 99px 0 0 99px;
}

.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }

.nav-badge {
  margin-right: auto;
  background: var(--red-bg);
  color: var(--red);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid var(--red-dark);
}

/* ── محتوای اصلی ─────────────────────────────── */
.main {
  flex: 1;
  margin-right: var(--sidebar-width);
  padding: 32px 36px;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-width));
}

/* ── هدر صفحه ────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 5px;
}

/* ── کارت ────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-sm  { padding: 16px; border-radius: var(--radius); }
.card-xs  { padding: 12px; border-radius: var(--radius-sm); }

.card-hover {
  transition: var(--transition);
  cursor: pointer;
}
.card-hover:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* ── گرید ────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }

/* ── فرم ─────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="datetime-local"],
input[type="date"],
select,
textarea {
  background: var(--bg-input);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-1);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
  background: var(--bg-surface);
}

input::placeholder, textarea::placeholder { color: var(--text-5); }

textarea { resize: vertical; min-height: 88px; line-height: 1.6; }

.input-hint { font-size: 11.5px; color: var(--text-4); margin-top: 3px; }

/* ── دکمه‌ها ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.15s;
}
.btn:hover::after { background: rgba(255,255,255,0.06); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(14,165,233,0.3);
}
.btn-primary:hover { box-shadow: 0 4px 20px rgba(14,165,233,0.45); }

.btn-success {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  box-shadow: 0 2px 12px rgba(22,163,74,0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  box-shadow: 0 2px 12px rgba(220,38,38,0.25);
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--border-2); color: var(--text-1); }

.btn-ghost {
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-2); border-color: var(--border-2); }

.btn-sm  { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-md  { padding: 10px 20px; font-size: 14px; }
.btn-lg  { padding: 13px 28px; font-size: 15px; border-radius: var(--radius); }
.btn-xl  { padding: 16px 36px; font-size: 16px; border-radius: var(--radius-lg); }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: var(--radius-sm); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── بج ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-red    { background: var(--red-bg);    color: var(--red);    border: 1px solid rgba(239,68,68,0.2); }
.badge-green  { background: var(--green-bg);  color: var(--green);  border: 1px solid rgba(34,197,94,0.2); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);   border: 1px solid rgba(14,165,233,0.2); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(245,158,11,0.2); }
.badge-purple { background: var(--purple-bg); color: var(--purple); border: 1px solid rgba(167,139,250,0.2); }
.badge-gray   { background: var(--bg-hover);  color: var(--text-3); border: 1px solid var(--border-2); }

/* ── جدول ────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead tr { background: var(--bg-surface); }
thead th {
  padding: 11px 16px;
  text-align: right;
  color: var(--text-4);
  font-weight: 700;
  font-size: 11.5px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 13px 16px; color: var(--text-2); vertical-align: middle; }

/* ── آواتار ──────────────────────────────────── */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--border-2);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg { width: 72px; height: 72px; font-size: 28px; }
.avatar-xl { width: 96px; height: 96px; font-size: 40px; }

/* ── کد دانش‌آموز ─────────────────────────────── */
.student-code {
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 5px;
  color: var(--blue);
  background: var(--blue-bg);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(14,165,233,0.2);
  display: inline-block;
}

/* ── استت کارت ───────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--glow-color, rgba(14,165,233,0.06));
  transform: translate(20px, -20px);
}

.stat-card-icon {
  font-size: 28px;
  margin-bottom: 12px;
  display: block;
}

.stat-card-num {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
}

.stat-card-delta {
  font-size: 11px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── آلرت ────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  line-height: 1.5;
}

.alert-error   { background: var(--red-bg);    color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.alert-success { background: var(--green-bg);  color: #86efac; border: 1px solid rgba(34,197,94,0.25); }
.alert-info    { background: var(--blue-bg);   color: #93c5fd; border: 1px solid rgba(14,165,233,0.25); }
.alert-warn    { background: var(--yellow-bg); color: #fde68a; border: 1px solid rgba(245,158,11,0.25); }

/* ── چک‌باکس سفارشی ──────────────────────────── */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.checkbox-group:hover { border-color: var(--border-2); }
.checkbox-group input[type="checkbox"] { display: none; }
.checkbox-box {
  width: 20px; height: 20px;
  border: 2px solid var(--border-2);
  border-radius: 5px;
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.checkbox-group.checked .checkbox-box { background: var(--blue); border-color: var(--blue); }
.checkbox-group.checked .checkbox-box::after { content: '✓'; color: #fff; font-size: 12px; font-weight: 700; }

/* ── آپلود عکس ───────────────────────────────── */
.photo-upload-area {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.photo-upload-area:hover {
  border-color: var(--blue);
  background: rgba(14,165,233,0.03);
}
.photo-upload-area input {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}

/* ── ویدیو ───────────────────────────────────── */
.video-box {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── رویداد تقلب ─────────────────────────────── */
.cheat-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--red);
  animation: slideInRight 0.3s ease;
}
.cheat-event.medium { border-color: var(--yellow); }
.cheat-event.low    { border-color: var(--text-4); }

/* ── گزینه آزمون ─────────────────────────────── */
.option-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 16px;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  line-height: 1.5;
}
.option-item:hover { border-color: var(--blue); background: rgba(14,165,233,0.04); }
.option-item.selected { border-color: var(--blue); background: var(--blue-bg); }
.option-item.correct  { border-color: var(--green); background: var(--green-bg); }
.option-item.wrong    { border-color: var(--red);   background: var(--red-bg); }

.option-letter {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  transition: var(--transition);
}

/* ── لاگین ───────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(14,165,233,0.08) 0%, transparent 70%),
              var(--bg-base);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 44px 48px;
  width: 100%;
  max-width: 430px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.45s ease;
}

.login-logo-wrap { text-align: center; margin-bottom: 32px; }

.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 30px;
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(14,165,233,0.35);
}

.login-title { font-size: 22px; font-weight: 800; color: var(--text-1); letter-spacing: -0.02em; }
.login-sub   { font-size: 13.5px; color: var(--text-3); margin-top: 5px; }

/* ── توست ────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 360px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastIn 0.35s cubic-bezier(0.175,0.885,0.32,1.275);
  pointer-events: all;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-error  { border-color: var(--red);   color: #fca5a5; }
.toast-success{ border-color: var(--green); color: #86efac; }
.toast-warn   { border-color: var(--yellow);color: #fde68a; }
.toast-info   { border-color: var(--blue);  color: #93c5fd; }
.toast.hiding { animation: toastOut 0.25s ease forwards; }

/* ── مودال ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--text-1); }

/* ── پیشرفت ──────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #818cf8);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── دیوایدر ─────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.divider-text {
  display: flex; align-items: center; gap: 12px; color: var(--text-4);
  font-size: 12px; margin: 16px 0;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── خروج ────────────────────────────────────── */
.logout-btn {
  margin-top: auto;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  transition: var(--transition);
}
.logout-btn:hover { background: var(--red-bg); color: #fca5a5; border-color: rgba(239,68,68,0.3); }

/* دکمه‌ی تغییر تم (روشن/تاریک) — گرد و کوچک، هم توی سایدبار ادمین هم توی هدر دانش‌آموز استفاده می‌شه */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-1);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.theme-toggle-btn:hover { background: var(--bg-card); border-color: var(--border-2); transform: scale(1.05); }
.theme-toggle-btn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 4px;
  margin-bottom: 8px;
}
.theme-toggle-btn-row span { font-size: 12.5px; color: var(--text-4); }


/* ── Floating Action Button ───────────────────── */
.fab {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.fab-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.fab-btn:hover { transform: scale(1.1); }
.fab-btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  box-shadow: 0 4px 20px rgba(220,38,38,0.4);
}

/* ── Loading Spinner ──────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }

.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(3,7,18,0.7);
  z-index: 9000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  backdrop-filter: blur(4px);
}

/* ── Empty State ──────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.6; }
.empty-state-title { font-size: 17px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.empty-state-sub   { font-size: 13.5px; color: var(--text-4); line-height: 1.6; max-width: 340px; margin: 0 auto; }

/* ── Auto-save indicator ──────────────────────── */
.autosave {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-4);
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.autosave.saving { color: var(--yellow); border-color: rgba(245,158,11,0.3); }
.autosave.saved  { color: var(--green);  border-color: rgba(34,197,94,0.3); }
.autosave-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.autosave.saving .autosave-dot { animation: pulse 0.8s infinite; }

/* ── Hamburger (موبایل) ────────────────────────── */
.hamburger {
  display: none;
  width: 36px; height: 36px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-2);
  border-radius: 2px;
  transition: var(--transition);
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 299;
  backdrop-filter: blur(2px);
}

/* ── Theme Toggle ─────────────────────────────── */
.theme-toggle {
  position: fixed;
  bottom: 28px;
  right: calc(var(--sidebar-width) + 16px);
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow);
  z-index: 400;
  transition: var(--transition);
}
.theme-toggle:hover { transform: rotate(20deg); }

/* ── Warning Banner ───────────────────────────── */
.warning-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 13px 20px;
  background: var(--red-bg);
  border-bottom: 2px solid var(--red);
  color: #fca5a5;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  z-index: 9990;
  display: none;
}

/* ── انیمیشن‌ها ──────────────────────────────── */
@keyframes fadeUp   { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeIn   { from{opacity:0} to{opacity:1} }
@keyframes slideInRight { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:0.35} }
@keyframes spin     { to{transform:rotate(360deg)} }
@keyframes shake    { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)} }
@keyframes toastIn  { from{opacity:0;transform:translateY(-12px) scale(0.95)} to{opacity:1;transform:translateY(0) scale(1)} }
@keyframes toastOut { to{opacity:0;transform:translateY(-8px) scale(0.95)} }
@keyframes modalIn  { from{opacity:0;transform:scale(0.92) translateY(16px)} to{opacity:1;transform:scale(1) translateY(0)} }
@keyframes blink    { 0%,100%{opacity:1} 50%{opacity:0.3} }
@keyframes bounce   { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }

/* ── نوار موبایل (ادمین) ─────────────────────── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  z-index: 350;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 10px;
}
.mobile-topbar-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── ریسپانسیو ───────────────────────────────── */
@media (max-width: 1100px) {
  :root { --sidebar-width: 220px; }
  .main { padding: 24px 20px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .form-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .hamburger { display: flex; flex-shrink: 0; }

  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: all;
  }

  .sidebar {
    transform: translateX(100%);
    width: min(300px, 86vw) !important;
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }

  .main {
    margin-right: 0 !important;
    max-width: 100vw;
    padding: 68px 14px 24px; /* جا برای mobile-topbar */
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 16px;
  }
  .page-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header .btn { flex: 1 1 auto; justify-content: center; }

  .grid-2, .grid-3, .grid-4,
  .form-row { grid-template-columns: 1fr; gap: 12px; }

  .stat-card { padding: 14px; }
  .stat-card-num { font-size: 26px; }

  .login-card { padding: 28px 18px; width: 100%; max-width: 100%; }

  .theme-toggle {
    right: 12px;
    bottom: 16px;
  }

  /* جداول ادمین */
  .table-wrap {
    margin: 0 -4px;
    border-radius: var(--radius-sm);
  }
  table { font-size: 12.5px; }
  table th, table td {
    padding: 10px 8px;
    white-space: nowrap;
  }

  /* مودال‌ها */
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
  }

  /* دکمه‌ها و فرم */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  input, select, textarea { font-size: 16px !important; } /* جلوگیری از زوم iOS */

  /* کارت‌ها */
  .card { padding: 16px; }

  /* ── صفحه آزمون دانش‌آموز ── */
  body.exam-page .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    height: auto;
    max-height: 42vh;
    transform: none;
    border-left: none;
    border-top: 1px solid var(--border);
    z-index: 200;
    overflow-y: auto;
  }
  body.exam-page .sidebar-inner {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px 14px;
  }
  body.exam-page .sidebar-logo {
    flex: 1 1 100%;
    margin-bottom: 4px;
  }
  body.exam-page .main {
    margin-right: 0 !important;
    padding: 12px 12px 48vh 12px;
    max-width: 100vw;
  }
  /* وب‌کم جمع‌وجور در موبایل */
  body.exam-page .exam-cam-box {
    width: 110px !important;
    min-height: 80px !important;
    max-height: 110px !important;
    aspect-ratio: 4/3 !important;
    margin: 0 !important;
  }
  body.exam-page .exam-cam-box > div {
    min-height: 80px !important;
    max-height: 110px !important;
    aspect-ratio: 4/3 !important;
  }
  body.exam-page .exam-student-card {
    display: none !important; /* روی موبایل فضای کمتر */
  }
  body.exam-page .question-nav button {
    min-width: 36px;
    min-height: 36px;
  }
  body.exam-page .option-btn {
    padding: 12px 14px;
  }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .page-title { font-size: 18px; }
  .page-sub { font-size: 12px; }
  .stat-card-num { font-size: 24px; }
  .btn-lg { padding: 12px 16px; font-size: 14px; }
  .card { padding: 14px; }
  .main { padding: 64px 10px 20px; }
  .mobile-topbar-title { font-size: 13px; }

  body.exam-page .main { padding: 10px 10px 46vh 10px; }
  body.exam-page .sidebar { max-height: 40vh; }
}

/* تبلت افقی */
@media (min-width: 769px) and (max-width: 1024px) {
  .main { padding: 24px 20px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ── Fullscreen Exam Mode ─────────────────────── */
.exam-fullscreen-mode body { overflow: hidden; }
.fullscreen-prompt {
  position: fixed; inset: 0;
  background: var(--bg-base);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  animation: fadeIn 0.4s ease;
}

/* ── کد تایمر ────────────────────────────────── */
.timer-display {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  font-weight: 800;
}
.timer-warning { color: var(--yellow) !important; animation: pulse 1s infinite; }
.timer-danger  { color: var(--red)    !important; animation: blink 0.6s infinite; }

/* ── Question Nav ─────────────────────────────── */
.q-nav-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.q-nav-btn:hover    { border-color: var(--blue); color: var(--blue); }
.q-nav-btn.answered { background: var(--blue-bg); border-color: var(--blue); color: var(--blue); }
.q-nav-btn.current  { background: var(--blue); border-color: var(--blue); color: #fff; }
.q-nav-btn.flagged  { border-color: var(--yellow); color: var(--yellow); }

/* ═══════════════════════════════════════════════
   UX v3 — بهبود تجربه کاربری
   ═══════════════════════════════════════════════ */

.toast-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  flex-shrink: 0;
  background: var(--bg-hover);
}
.toast-success .toast-icon { background: var(--green-bg); color: var(--green); }
.toast-error .toast-icon   { background: var(--red-bg); color: var(--red); }
.toast-warn .toast-icon    { background: var(--yellow-bg); color: var(--yellow); }
.toast-info .toast-icon    { background: var(--blue-bg); color: var(--blue); }
.toast-msg { flex: 1; line-height: 1.5; }

/* تأیید داخل‌برنامه‌ای */
.ui-confirm-modal {
  max-width: 400px;
  width: 100%;
  text-align: center;
  padding: 28px 24px 20px;
}
.ui-confirm-icon { font-size: 40px; margin-bottom: 12px; }
.ui-confirm-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.7;
  margin-bottom: 22px;
  white-space: pre-line;
}
.ui-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.ui-confirm-actions .btn { min-width: 110px; }

/* کارت شروع سریع */
.onboarding {
  background: linear-gradient(135deg, rgba(14,165,233,0.08), rgba(167,139,250,0.06));
  border: 1px solid rgba(14,165,233,0.25);
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
  margin-bottom: 24px;
}
.onboarding-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.onboarding-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 16px;
  line-height: 1.7;
}
.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.onboarding-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 110px;
}
.onboarding-step:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-blue);
}
.onboarding-step.done {
  border-color: rgba(34,197,94,0.4);
  background: rgba(34,197,94,0.06);
}
.onboarding-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-3);
  font-size: 13px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.onboarding-step.done .onboarding-step-num {
  background: var(--green-bg);
  color: var(--green);
}
.onboarding-step-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.4;
}
.onboarding-step-hint {
  font-size: 11px;
  color: var(--text-4);
}

/* empty state با دکمه */
.empty-state .btn { margin-top: 16px; }
.empty-state-soft {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-4);
  font-size: 13.5px;
}

/* فوکوس دسترس‌پذیر */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* بهبود کارت آمار */
.stat-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* ناوبری سایدبار نرم‌تر */
.nav-item {
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.nav-item:hover {
  transform: translateX(-2px);
}

/* صفحه آزمون — دکمه جمع کردن وب‌کم */
.exam-cam-toggle {
  display: none;
  width: 100%;
  margin: 4px 0 0;
  font-size: 12px;
}
body.exam-page.cam-collapsed .exam-cam-box,
body.exam-page.cam-collapsed .exam-status-list {
  display: none !important;
}
body.exam-page.cam-collapsed .sidebar {
  max-height: auto;
}

/* هشدار داخل آزمون نرم‌تر */
.warning-banner {
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* اسکلتون لودینگ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* صفحه ورود دانش‌آموز */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(14,165,233,0.12), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(167,139,250,0.1), transparent 50%),
    var(--bg-base);
}
.login-card {
  width: 100%;
  max-width: 420px;
  animation: fadeIn 0.35s ease;
}
.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-4);
  margin-top: 16px;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .onboarding-steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .onboarding-steps { grid-template-columns: 1fr 1fr; }
  .exam-cam-toggle { display: flex; }
  body.exam-page .sidebar { max-height: 48vh; }
  body.exam-page.cam-collapsed .sidebar { max-height: 160px; }
  body.exam-page.cam-collapsed .main { padding-bottom: 180px; }
}
@media (max-width: 480px) {
  .onboarding-steps { grid-template-columns: 1fr; }
  .toast-container { width: calc(100vw - 24px); }
}


/* density-v2 — کمتر شلوغ، فشرده‌تر */
.main { padding: 28px 28px; }
.page-header { margin-bottom: 20px; padding-bottom: 16px; }
.page-title { font-size: 22px; }
.card { padding: 18px; }
.stat-card { padding: 14px 16px; }
.stat-card-num { font-size: 26px; }
.grid-4 { gap: 12px; }
.grid-3 { gap: 12px; }
.nav-section { margin-top: 10px; font-size: 10.5px; letter-spacing: 0.06em; }
.nav-item { padding: 9px 12px; font-size: 13px; }
.sidebar-inner { gap: 1px; }
table { font-size: 13px; }
table th { font-size: 11.5px; text-transform: none; letter-spacing: 0; }
.badge { font-size: 11px; padding: 3px 8px; }

/* محدود کردن ارتفاع لیست‌های بلند */
.scroll-panel {
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 4px;
}
.scroll-panel::-webkit-scrollbar { width: 4px; }

/* نوار ابزار چسبان فیلترها */
.sticky-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-base);
  padding: 8px 0 12px;
  margin-bottom: 4px;
}

/* کارت آزمون فشرده در گزارش */
.exam-report-card {
  padding: 16px !important;
}
.exam-report-card .badge { margin-bottom: 2px; }

@media (max-width: 768px) {
  .main { padding: 64px 12px 20px; }
  .stat-card-num { font-size: 22px; }
  .page-header .btn { font-size: 12.5px; padding: 8px 12px; }
}


/* ── دکمه شناور و پنل تنظیمات ── */
.settings-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 80;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.settings-fab:hover { transform: scale(1.06); }
.settings-overlay { z-index: 10050; }
.settings-panel { max-width: 420px; width: 92vw; padding: 22px; }
.settings-panel [data-theme-opt].active {
  background: var(--blue-bg);
  border-color: var(--blue);
  color: var(--blue);
}


/* ── Lucide icons ── */
.lucide-icon,
[data-lucide] {
  display: inline-block;
  vertical-align: -0.2em;
  width: 1.15em;
  height: 1.15em;
  stroke-width: 2;
  flex-shrink: 0;
}
.nav-icon .lucide-icon,
.nav-icon[data-lucide],
.nav-icon i {
  width: 20px;
  height: 20px;
  stroke-width: 1.85;
}
.sidebar-logo-icon .lucide-icon,
.sidebar-logo-icon i,
.login-logo .lucide-icon,
.login-logo i {
  width: 28px;
  height: 28px;
  stroke-width: 1.75;
}
.stat-card-label .lucide-icon,
.stat-card-label i {
  width: 16px;
  height: 16px;
  margin-left: 4px;
}
.btn .lucide-icon,
.btn i[data-lucide] {
  width: 16px;
  height: 16px;
  margin-left: 6px;
  vertical-align: -0.25em;
}
.btn-sm .lucide-icon,
.btn-sm i[data-lucide] {
  width: 14px;
  height: 14px;
  margin-left: 4px;
}
.settings-fab .lucide-icon,
.settings-fab i {
  width: 22px;
  height: 22px;
}
.theme-toggle-btn .lucide-icon,
.theme-toggle-btn i {
  width: 18px;
  height: 18px;
}
.empty-state-icon .lucide-icon,
.empty-state-icon i {
  width: 40px;
  height: 40px;
  stroke-width: 1.5;
  color: var(--text-4);
}
.icon-inline { display: inline-flex; align-items: center; gap: 6px; }

.icon-sev-high { color: var(--red); fill: var(--red); }
.icon-sev-med  { color: var(--yellow); fill: var(--yellow); }
.icon-sev-ok   { color: var(--green); fill: var(--green); }
.lucide-icon.icon-sev-high, .lucide-icon.icon-sev-med, .lucide-icon.icon-sev-ok {
  stroke: currentColor;
}
