/* ===================================
   نظام الاختبارات الموحد - QOU Exams
   CSS مشترك لجميع صفحات الاختبارات
   =================================== */

:root {
  --bg: #0f172a;
  --panel: #0b1c2c;
  --card: #11263b;
  --accent: #00c9a7;
  --accent-2: #4dd2ff;
  --primary: #4a9eff;
  --primary-dark: #2d7ae6;
  --muted: #9fb3c8;
  --text: #e8f0fb;
  --danger: #ff6b6b;
  --success: #4ade80;
  --warning: #ffb703;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

/* حماية النسخ */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  box-sizing: border-box;
}

input[type="text"],
input[type="email"],
textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

::selection {
  background: transparent;
}

body {
  margin: 0;
  font-family: 'Cairo', 'Noto Sans Arabic', 'Segoe UI', sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(0, 201, 167, 0.08), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(77, 210, 255, 0.12), transparent 32%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px;
  direction: rtl;
}

/* تخطيط الصفحة */
.exam-layout {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

/* الهيدر */
.exam-header {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(0, 201, 167, 0.18), rgba(77, 210, 255, 0.14));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.exam-header h1 {
  margin: 0;
  font-size: 1.8rem;
  color: var(--text);
}

.exam-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.badge {
  background: rgba(0, 201, 167, 0.15);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid rgba(0, 201, 167, 0.4);
}

/* البطاقات */
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.28);
}

/* شريط الحالة */
.status-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.status-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.status-pill strong {
  color: var(--text);
}

/* شريط التقدم */
.progress-bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 18px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 0.25s ease;
}

/* بطاقة السؤال */
.question-card {
  margin-bottom: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
}

.question-card h2 {
  margin: 0 0 16px;
  font-size: 1.35rem;
  line-height: 1.65;
  color: #f1f5f9;
  word-break: break-word;
}

/* الخيارات */
.options {
  display: grid;
  gap: 10px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0d2133;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, transform 0.1s ease;
  font-size: 1rem;
}

.option input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.option:hover {
  border-color: rgba(0, 201, 167, 0.6);
  transform: translateX(-2px);
}

.option.selected {
  border-color: var(--accent);
  background: rgba(0, 201, 167, 0.12);
}

.options.locked .option {
  pointer-events: none;
  opacity: 0.7;
}

/* الأزرار */
button {
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #052532;
  box-shadow: 0 12px 30px rgba(0, 201, 167, 0.32);
}

button.primary:hover {
  box-shadow: 0 14px 35px rgba(0, 201, 167, 0.4);
}

button.secondary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 8px 20px rgba(74, 158, 255, 0.3);
}

button.danger {
  background: rgba(255, 107, 107, 0.14);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.35);
}

button.danger:hover {
  background: rgba(255, 107, 107, 0.2);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* صف التنقل */
.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.nav-row > div {
  display: flex;
  gap: 8px;
}

/* شبكة الأسئلة */
.questions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
}

.pill {
  text-align: center;
  padding: 10px 0;
  background: #0c1f31;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  transition: all 0.2s ease;
}

.pill:hover {
  border-color: var(--accent-2);
}

.pill.answered {
  background: rgba(0, 201, 167, 0.14);
  color: var(--accent);
  border-color: rgba(0, 201, 167, 0.4);
}

.pill.current {
  border-color: var(--accent-2);
  color: var(--accent-2);
  box-shadow: 0 0 10px rgba(77, 210, 255, 0.3);
}

/* النتائج */
.results-section {
  display: none;
  gap: 12px;
  margin-top: 10px;
}

.results-section.visible {
  display: grid;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat-card {
  background: #0b1c2c;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.stat-card h4 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.stat-card strong {
  font-size: 1.6rem;
  color: var(--text);
}

/* حالة النجاح/الرسوب */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-tag.pass {
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
}

.status-tag.fail {
  background: rgba(255, 107, 107, 0.12);
  color: #ff7b7b;
  border-color: rgba(255, 107, 107, 0.35);
}

/* مراجعة الإجابات */
.review-list {
  background: #0b1c2c;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.review-item {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.review-item:last-child {
  margin-bottom: 0;
}

.review-item.correct {
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.08);
}

.review-item.wrong {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.08);
}

.review-item strong {
  display: block;
  margin-bottom: 8px;
  line-height: 1.5;
}

.review-item .muted {
  color: var(--muted);
  font-size: 0.9rem;
}

/* النافذة المنبثقة */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #0f2133;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.modal-card h3 {
  margin: 0 0 12px;
  font-size: 1.3rem;
}

.modal-card p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* الإعدادات */
.settings-section {
  margin-top: 16px;
}

.settings-section h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.settings-grid label {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.settings-grid select,
.settings-grid input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0a1a29;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

/* الروابط */
.links-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.links-section a {
  display: block;
  color: #9bd5ff;
  text-decoration: none;
  font-weight: 600;
  padding: 8px 0;
  transition: color 0.2s;
}

.links-section a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

/* الفوتر */
.exam-footer {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  margin-top: 20px;
  font-size: 0.95rem;
}

.sponsor-banner {
  background: rgba(255, 183, 3, 0.1);
  border: 1px solid rgba(255, 183, 3, 0.3);
  border-radius: 14px;
  padding: 14px 20px;
  text-align: center;
  color: var(--warning);
  font-weight: 700;
  margin-bottom: 16px;
}

/* استجابة للشاشات الصغيرة */
@media (max-width: 1024px) {
  .exam-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    padding: 14px;
  }

  .exam-header {
    flex-direction: column;
    align-items: flex-start;
    text-align: center;
  }

  .exam-header h1 {
    font-size: 1.4rem;
  }

  .status-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .question-card {
    padding: 14px;
  }

  .question-card h2 {
    font-size: 1.15rem;
  }

  .option {
    padding: 12px;
    font-size: 0.95rem;
  }

  .nav-row {
    flex-direction: column;
  }

  .nav-row > div {
    width: 100%;
    justify-content: space-between;
  }

  .nav-row button {
    flex: 1;
  }
}
