:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --radius: 14px;
  --shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.08);
}

@font-face {
  font-family: 'VazirmatnLocal';
  src: url('../vendor/vazirmatn/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'VazirmatnLocal';
  src: url('../vendor/vazirmatn/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }
html { direction: rtl; font-size: 16px; }
body {
  margin: 0;
  font-family: 'VazirmatnLocal', 'IRANSans', 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout Helpers */
.container { max-width: 1120px; margin: 0 auto; padding: 20px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { margin: 0; font-size: 1.15rem; font-weight: 700; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 820px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Forms */
label { display: block; font-size: 0.88rem; font-weight: 600; color: #334155; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], input[type="url"], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
textarea { min-height: 110px; resize: vertical; }
.form-group { margin-bottom: 15px; }
.help { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.check-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check-row input { width: auto; accent-color: var(--primary); transform: scale(1.15); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none !important;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.95); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Badges & Alerts */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--success-soft); color: #15803d; }
.badge-red { background: var(--danger-soft); color: #b91c1c; }
.badge-amber { background: var(--warning-soft); color: #b45309; }
.badge-gray { background: var(--surface-2); color: var(--muted); }

.alert {
  padding: 13px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); color: #166534; border-color: #bbf7d0; }
.alert-danger { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-soft); color: #92400e; border-color: #fde68a; }
.alert-info { background: var(--primary-soft); color: #1e40af; border-color: #bfdbfe; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); color: #334155; font-weight: 700; white-space: nowrap; }
tr:hover td { background: #fafcff; }

/* Admin Shell */
.admin-nav {
  background: #0f172a;
  color: #fff;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 4px 20px rgba(15,23,42,0.12);
}
.admin-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 60px;
}
.admin-brand { font-weight: 700; font-size: 1rem; color: #fff; display: flex; align-items: center; gap: 10px; }
.admin-brand img { height: 32px; border-radius: 6px; }
.admin-links { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-links a {
  color: #cbd5e1;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
}
.admin-links a:hover, .admin-links a.active { background: rgba(255,255,255,0.12); color: #fff; }

/* Stat Cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 0.82rem; color: var(--muted); }
.stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 4px; color: var(--text); }

/* Porsline-Style Exam UI */
.exam-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px 14px;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}
.exam-card {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 50px -15px rgba(15, 23, 42, 0.14);
  overflow: hidden;
}
.exam-topbar {
  padding: 14px 22px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.progress-track { height: 5px; background: #e2e8f0; width: 100%; }
.progress-fill { height: 100%; background: var(--primary); transition: width .3s ease; }
.exam-body { padding: 28px 26px; position: relative; }
@media (max-width: 600px) { .exam-body { padding: 20px 16px; } }
.q-text { font-size: 1.12rem; font-weight: 600; line-height: 1.9; margin-bottom: 20px; color: #0f172a; }
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  background: #fff;
  transition: all .15s;
}
.option-item:hover { border-color: #93c5fd; background: #f8fbff; }
.option-item.selected { border-color: var(--primary); background: var(--primary-soft); }
.option-item input { margin-top: 4px; width: auto; accent-color: var(--primary); transform: scale(1.2); }
.timer-pill {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  direction: ltr;
}
.timer-pill.urgent { background: var(--danger-soft); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }

.exam-footer {
  padding: 16px 26px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.media-box { margin: 14px 0 20px; text-align: center; }
.media-box img { max-width: 100%; max-height: 360px; border-radius: 12px; border: 1px solid var(--border); }
.media-box audio { width: 100%; max-width: 440px; }

.ltr { direction: ltr; text-align: left; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.text-muted { color: var(--muted); font-size: 0.88rem; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; padding: 24px; box-shadow: 0 25px 60px rgba(0,0,0,0.25);
}
