/* ============ RESET & BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --text: #1a2236;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #e5e7eb;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.25s ease;
}

[data-theme="dark"] {
  --bg: #0f1420;
  --surface: #1a2030;
  --surface-2: #232a3d;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --border: #2d3548;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

html { direction: rtl; }
body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button { font-family: inherit; cursor: pointer; border: none; }

/* ============ HEADER ============ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.logo {
  font-size: 22px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  color: var(--primary);
}
.header-meta {
  display: flex; align-items: center; gap: 20px;
  font-size: 14px; color: var(--text-muted);
}
.clock { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.theme-toggle {
  background: var(--surface-2);
  border-radius: 50%; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: transform var(--transition);
}
.theme-toggle:hover { transform: rotate(20deg); }

.nav-menu {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.nav-menu a {
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px;
  transition: background var(--transition);
}
.nav-menu a:hover { background: var(--surface-2); }

/* ============ CONTAINER ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* ============ HERO ============ */
.hero {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  padding: 60px 32px;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 40px;
  box-shadow: var(--shadow);
}
.hero h1 { font-size: 36px; margin-bottom: 16px; }
.hero p { font-size: 18px; opacity: 0.95; margin-bottom: 28px; }
.hero-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  transition: all var(--transition);
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-outline { background: transparent; color: #fff; border: 2px solid #fff; }
.btn-outline:hover { background: #fff; color: var(--primary); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); }
.btn-success { background: var(--success); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition);
}
.card:hover { transform: translateY(-2px); }
.card-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }

/* ============ GRID ============ */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ============ TEACHER CARD ============ */
.teacher-card {
  text-align: center;
  padding: 32px 24px;
}
.teacher-avatar {
  width: 120px; height: 120px; border-radius: 50%;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 48px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(79,70,229,0.3);
}
.teacher-card h3 { font-size: 22px; margin-bottom: 4px; }
.teacher-role { color: var(--text-muted); margin-bottom: 16px; }
.teacher-quote {
  font-style: italic; color: var(--text-muted);
  padding: 16px; background: var(--surface-2);
  border-radius: var(--radius-sm); margin: 16px 0;
  border-right: 3px solid var(--primary);
}
.teacher-stats {
  display: flex; justify-content: center; gap: 24px;
  margin: 16px 0; flex-wrap: wrap;
}
.stat-item { text-align: center; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-weight: 600; font-size: 14px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 15px;
  transition: border var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.form-textarea { min-height: 100px; resize: vertical; }

/* ============ EXAM ============ */
.exam-header {
  background: var(--surface);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.timer {
  font-size: 22px; font-weight: 700;
  padding: 8px 18px; border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}
.timer.warning { background: var(--warning); color: #fff; animation: pulse 1s infinite; }
.timer.danger { background: var(--danger); color: #fff; animation: pulse 0.5s infinite; }
@keyframes pulse { 50% { opacity: 0.7; } }

.question-card {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.question-number {
  color: var(--primary); font-weight: 700;
  margin-bottom: 12px; font-size: 14px;
}
.question-text { font-size: 18px; margin-bottom: 24px; line-height: 1.8; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  padding: 14px 18px;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; gap: 12px;
}
.option:hover { background: var(--border); }
.option.selected {
  background: rgba(79,70,229,0.1);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.option-radio {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.option.selected .option-radio {
  border-color: var(--primary);
  background: var(--primary);
}
.option.selected .option-radio::after {
  content: ''; width: 8px; height: 8px;
  background: #fff; border-radius: 50%;
}

.question-nav {
  display: flex; justify-content: space-between;
  margin-top: 24px; gap: 12px;
}
.question-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px; margin-top: 16px;
}
.q-btn {
  aspect-ratio: 1;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.q-btn.current { background: var(--primary); color: #fff; }
.q-btn.answered { background: var(--success); color: #fff; }

/* ============ RESULT ============ */
.result-hero {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff; padding: 48px 32px;
  border-radius: var(--radius); text-align: center;
  margin-bottom: 24px;
}
.result-score {
  font-size: 64px; font-weight: 800;
  margin: 16px 0;
}
.result-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px; margin-top: 24px;
}
.result-stat {
  background: rgba(255,255,255,0.15);
  padding: 16px; border-radius: var(--radius-sm);
}
.result-stat-value { font-size: 28px; font-weight: 700; }
.result-stat-label { font-size: 13px; opacity: 0.9; }

/* ============ BADGE ============ */
.badge {
  display: inline-block; padding: 4px 10px;
  background: var(--surface-2);
  border-radius: 20px; font-size: 12px;
  color: var(--text-muted);
}
.badge-primary { background: rgba(79,70,229,0.15); color: var(--primary); }
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }

/* ============ SERVICES ============ */
.service-card {
  padding: 20px;
  border-right: 3px solid var(--primary);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.service-card h4 { margin-bottom: 8px; }

/* ============ SOCIAL ============ */
.social-links { display: flex; gap: 10px; flex-wrap: wrap; }
.social-link {
  width: 42px; height: 42px;
  background: var(--surface-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: all var(--transition);
}
.social-link:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }

/* ============ BANNER ============ */
.promo-banner {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff; padding: 24px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin: 24px 0;
}

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: right; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 700; font-size: 14px; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px; max-width: 500px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ============ ALERT ============ */
.alert {
  padding: 14px 18px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 14px;
  border-right: 4px solid;
}
.alert-info { background: rgba(79,70,229,0.1); border-color: var(--primary); color: var(--primary); }
.alert-success { background: rgba(16,185,129,0.1); border-color: var(--success); color: var(--success); }
.alert-warning { background: rgba(245,158,11,0.1); border-color: var(--warning); color: var(--warning); }
.alert-danger { background: rgba(239,68,68,0.1); border-color: var(--danger); color: var(--danger); }

/* ============ LOGIN ============ */
.login-wrap {
  min-height: calc(100vh - 80px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  max-width: 420px; width: 100%;
  background: var(--surface);
  padding: 40px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h2 { margin-bottom: 8px; }
.login-card p { color: var(--text-muted); margin-bottom: 24px; }

/* ============ FOOTER ============ */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px; text-align: center;
  color: var(--text-muted); font-size: 14px;
  margin-top: 40px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 15px; }
  .hero { padding: 40px 20px; }
  .question-card { padding: 20px; }
  .question-text { font-size: 16px; }
  .result-score { font-size: 48px; }
  .header-meta { font-size: 12px; gap: 12px; }
  .nav-menu { display: none; }
  .container { padding: 20px 16px; }
}

/* ============ PRINT ============ */
@media print {
  .site-header, .site-footer, .btn, .promo-banner, .nav-menu, .theme-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .result-hero { box-shadow: none; border: 1px solid #ccc; }
}

/* ============ UTILS ============ */
.text-center { text-align: center; }
.mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }