/* Global vars */
:root {
  --primary: #0073EA;
  --primary-hover: #0060c0;
  --primary-light: #e6f2ff;
  --success: #00C875;
  --warning: #FDAB3D;
  --danger: #E2445C;
  --bg: #F6F7FB;
  --card: #ffffff;
  --border: #e6e9ef;
  --text: #323338;
  --text-muted: #676879;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; }

html { font-family: 'Rubik', 'Segoe UI', sans-serif; direction: rtl; }

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #00a862; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c43050; }

.btn-outline {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

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

.btn-lg { height: 48px; padding: 0 28px; font-size: 16px; border-radius: 12px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* Form elements */
.input, input[type="text"], input[type="password"], input[type="email"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
  outline: none;
}
.input:focus, input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,115,234,.12);
}

label { font-size: 13px; font-weight: 500; color: var(--text-muted); display: block; margin-bottom: 5px; }

.form-group { margin-bottom: 16px; }

/* Topbar */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}
.topbar-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-left: auto;
}
.topbar-spacer { flex: 1; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  background: var(--bg);
  text-align: right;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--primary-light); }
tr:last-child td { border-bottom: none; }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-pending { background: #fff3e0; color: #e65100; }
.badge-in_progress { background: #e3f2fd; color: #1565c0; }
.badge-completed { background: #e8f5e9; color: #2e7d32; }
.badge-expired { background: #fce4ec; color: #c62828; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: fadeIn .15s;
}
.modal {
  background: var(--card);
  border-radius: 14px;
  padding: 28px;
  width: 440px;
  max-width: 95vw;
  box-shadow: var(--shadow-md);
  animation: slideUp .2s;
}
.modal-title { font-size: 18px; font-weight: 700; margin: 0 0 16px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp .2s;
  max-width: 320px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* Animations */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: translateY(0) } }
@keyframes fadeOut { from { opacity: 1 } to { opacity: 0 } }

/* Exam timer bar */
.exam-header {
  position: fixed; top: 0; right: 0; left: 0;
  height: 62px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

.timer-global {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.timer-global .time-val {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.timer-global.danger .time-val { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

.section-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.progress-step {
  width: 28px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: background .3s;
}
.progress-step.done { background: var(--success); }
.progress-step.active { background: var(--primary); }

.section-timer {
  font-size: 13px;
  white-space: nowrap;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-timer .time-val {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.section-timer.warning .time-val { color: var(--warning); }
.section-timer.danger .time-val { color: var(--danger); animation: pulse 1s infinite; }

/* Exam content area */
.exam-content {
  padding-top: 80px;
  min-height: 100vh;
  max-width: 780px;
  margin: 0 auto;
  padding-right: 20px;
  padding-left: 20px;
  padding-bottom: 40px;
}

/* Question card */
.question-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px;
  animation: fadeIn .2s;
}
.question-number {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 10px;
}
.question-prompt {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 28px;
  line-height: 1.6;
}

/* Option buttons */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  text-align: right;
  transition: border-color .15s, background .15s;
  width: 100%;
}
.option-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.option-btn.selected { border-color: var(--primary); background: var(--primary-light); }
.option-btn.demo-correct { border-color: var(--success) !important; background: #e8f5e9 !important; box-shadow: 0 0 0 2px rgba(0,200,117,.3); }
.option-letter {
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: border-color .15s, color .15s, background .15s;
}
.option-btn:hover .option-letter,
.option-btn.selected .option-letter {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff;
}

/* String match specific */
.string-match-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 24px 0;
  flex-wrap: wrap;
}
.string-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px 28px;
  font-family: 'Courier New', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  border: 1.5px solid var(--border);
  direction: ltr;
  min-width: 180px;
  text-align: center;
}
.string-actions { display: flex; gap: 14px; justify-content: center; }
.btn-same { background: var(--success); color: #fff; height: 48px; padding: 0 32px; font-size: 16px; }
.btn-diff { background: var(--warning); color: #fff; height: 48px; padding: 0 32px; font-size: 16px; }
.btn-same:hover { background: #00a862; }
.btn-diff:hover { background: #e09700; }
.btn-same.demo-correct, .btn-diff.demo-correct { outline: 3px solid #fff; box-shadow: 0 0 0 5px rgba(0,200,117,.5); }

/* Memory presentation */
.memory-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.memory-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
}
.memory-item-num {
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Pattern SVG grid */
.pattern-sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.pattern-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pattern-item.question-mark {
  border: 2px dashed var(--primary);
  background: var(--primary-light);
}
.pattern-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 20px;
}
.pattern-opt-btn {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color .15s, background .15s;
}
.pattern-opt-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.pattern-opt-btn.selected { border-color: var(--primary); background: var(--primary-light); }
.pattern-opt-btn.demo-correct { border-color: var(--success) !important; background: #e8f5e9 !important; box-shadow: 0 0 0 2px rgba(0,200,117,.3); }
.opt-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* Chart container */
.chart-container {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  overflow: hidden;
}

/* English reading passage */
.reading-passage {
  background: var(--bg);
  border-right: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 15px;
  line-height: 1.7;
  direction: ltr;
  text-align: left;
  color: var(--text);
}

/* Score / radar in admin */
.domain-bar-list { display: flex; flex-direction: column; gap: 10px; }
.domain-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.domain-bar-label {
  width: 130px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  text-align: right;
}
.domain-bar-track {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.domain-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--primary);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.domain-bar-pct {
  width: 36px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  color: var(--text-muted);
}

/* Intro screen */
.intro-wrap {
  max-width: 600px;
  margin: 60px auto;
  padding: 0 20px;
}

/* Loader */
.loader {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Score circle */
.score-circle {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}
.score-high { background: var(--success); }
.score-mid { background: var(--warning); color: var(--text); }
.score-low { background: var(--danger); }

/* Responsive */
@media (max-width: 600px) {
  .pattern-options { grid-template-columns: repeat(2, 1fr); }
  .string-match-pair { flex-direction: column; gap: 12px; }
  .modal { padding: 20px; }
  .exam-content { padding-top: 76px; }
}
