/* ═══════════════════════════════════════════════
   ISLAMIC EXAM — GRADE 7 — FULL STYLESHEET
   ═══════════════════════════════════════════════ */

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

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #1e2530;
  --border:    rgba(255,255,255,.08);
  --gold:      #c9a227;
  --gold-light:#e8c45a;
  --teal:      #2cb67d;
  --blue:      #3d8ef0;
  --green:     #38a169;
  --purple:    #7c5cbf;
  --red:       #e05252;
  --text:      #e8eaf0;
  --text2:     #9ba3b0;
  --text3:     #6b7280;
  --correct:   #22c55e;
  --wrong:     #ef4444;
  --radius:    14px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --font-ar:   'Cairo', 'Amiri', sans-serif;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-ar);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  overflow-x: hidden;
}

/* ─── SCREENS ─────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ─── HOME ─────────────────────────────────────── */
.home-bg-pattern {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(201,162,39,.07) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(44,182,125,.06) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(201,162,39,0.05)' stroke-width='1'%3E%3Cpolygon points='30,2 56,16 56,44 30,58 4,44 4,16'/%3E%3Cpolygon points='30,10 48,20 48,40 30,50 12,40 12,20'/%3E%3C/g%3E%3C/svg%3E");
}

.home-header {
  position: relative; z-index: 1;
  text-align: center;
  padding: 3rem 2rem 2rem;
  max-width: 900px; margin: 0 auto;
}

.school-badge {
  display: inline-flex; align-items: center; gap: .75rem;
  background: rgba(201,162,39,.1);
  border: 1px solid rgba(201,162,39,.25);
  border-radius: 50px;
  padding: .5rem 1.25rem;
  margin-bottom: 1.75rem;
}
.badge-icon { font-size: 1.5rem; }
.badge-title { font-size: .85rem; font-weight: 700; color: var(--gold-light); }
.badge-sub   { font-size: .75rem; color: var(--text2); }

.home-title {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-light), var(--teal));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: .6rem;
  line-height: 1.3;
}
.home-subtitle {
  color: var(--text2); font-size: .95rem; margin-bottom: 1.5rem;
}
.topics-bar {
  display: flex; flex-wrap: wrap; gap: .5rem;
  justify-content: center; margin-bottom: 1rem;
}
.topic-pill {
  padding: .35rem .9rem; border-radius: 50px;
  font-size: .8rem; font-weight: 600;
  border: 1px solid currentColor;
}
.topic-pill.teal   { color: var(--teal);   background: rgba(44,182,125,.1); }
.topic-pill.blue   { color: var(--blue);   background: rgba(61,142,240,.1); }
.topic-pill.green  { color: var(--green);  background: rgba(56,161,105,.1); }
.topic-pill.gold   { color: var(--gold);   background: rgba(201,162,39,.1); }

/* ─── SETS GRID ────────────────────────────────── */
.sets-grid {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  max-width: 1100px; margin: 0 auto 3rem;
  padding: 0 1.5rem;
}

.set-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative;
  overflow: hidden;
}
.set-card::before {
  content: '';
  position: absolute; top: 0; right: 0; left: 0; height: 3px;
  background: var(--card-accent, var(--gold));
  border-radius: var(--radius) var(--radius) 0 0;
}
.set-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
  border-color: rgba(255,255,255,.15);
}
.set-icon  { font-size: 2rem; margin-bottom: .75rem; display: block; }
.set-num   { font-size: .7rem; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: .25rem; }
.set-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .25rem; }
.set-sub   { font-size: .8rem; color: var(--text2); margin-bottom: 1rem; }

.set-stats {
  display: flex; gap: .5rem; flex-wrap: wrap;
}
.stat-badge {
  font-size: .72rem; padding: .2rem .6rem;
  border-radius: 50px; background: rgba(255,255,255,.06);
  color: var(--text2);
}
.set-start-btn {
  margin-top: 1rem; width: 100%;
  background: rgba(201,162,39,.15);
  border: 1px solid rgba(201,162,39,.3);
  color: var(--gold-light);
  padding: .6rem; border-radius: 8px;
  font-family: var(--font-ar); font-size: .9rem; font-weight: 700;
  cursor: pointer; transition: background .2s;
}
.set-start-btn:hover { background: rgba(201,162,39,.3); }

/* ─── EXAM HEADER ─────────────────────────────── */
.exam-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.btn-back {
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  color: var(--text2); padding: .45rem .9rem; border-radius: 8px;
  font-family: var(--font-ar); font-size: .85rem; cursor: pointer;
  transition: background .2s;
  white-space: nowrap;
}
.btn-back:hover { background: rgba(255,255,255,.12); color: var(--text); }

.exam-title-group { display: flex; align-items: center; gap: .75rem; flex: 1; min-width: 0; }
.exam-icon-large  { font-size: 1.8rem; }
.exam-title-text  { font-size: 1.05rem; font-weight: 700; }
.exam-sub-text    { font-size: .8rem; color: var(--text2); }

.progress-wrap    { display: flex; align-items: center; gap: .75rem; min-width: 200px; }
.progress-bar     { flex: 1; height: 6px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; }
.progress-fill    { height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: 99px; transition: width .4s ease; width: 0%; }
.progress-label   { font-size: .8rem; color: var(--text2); white-space: nowrap; }

/* ─── EXAM BODY ───────────────────────────────── */
.exam-body {
  max-width: 820px; margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ─── QUESTION CARD ───────────────────────────── */
.q-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: border-color .3s;
}
.q-card.answered { border-color: rgba(44,182,125,.25); }
.q-card.unanswered-warn { border-color: rgba(240,96,58,.6) !important; animation: shake .3s; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

.q-header {
  display: flex; align-items: flex-start; gap: .75rem;
  margin-bottom: 1rem;
}
.q-num {
  min-width: 2rem; height: 2rem;
  background: rgba(201,162,39,.15); border: 1px solid rgba(201,162,39,.3);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; color: var(--gold-light);
  flex-shrink: 0;
}
.q-topic-tag {
  font-size: .68rem; padding: .15rem .5rem; border-radius: 50px;
  background: rgba(255,255,255,.06); color: var(--text3);
  align-self: flex-start; flex-shrink: 0;
}
.q-text {
  font-size: 1rem; line-height: 1.7;
  font-family: 'Amiri', serif; font-weight: 700;
  flex: 1;
}
.q-type-badge {
  font-size: .65rem; padding: .15rem .5rem; border-radius: 50px;
  font-weight: 600; align-self: flex-start; flex-shrink: 0;
}
.q-type-badge.mcq  { background: rgba(61,142,240,.15);  color: var(--blue); }
.q-type-badge.tf   { background: rgba(124,92,191,.15);  color: var(--purple); }
.q-type-badge.fill { background: rgba(44,182,125,.15);  color: var(--teal); }
.q-type-badge.short{ background: rgba(201,162,39,.15);  color: var(--gold); }

/* MCQ Options */
.options-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }
.option-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer; transition: background .15s, border-color .15s;
  user-select: none;
}
.option-item:hover { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.15); }
.option-item input[type="radio"] { display: none; }
.option-item.selected {
  background: rgba(61,142,240,.12);
  border-color: rgba(61,142,240,.5);
}
.option-dot {
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: 2px solid var(--text3); flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.option-item.selected .option-dot {
  background: var(--blue); border-color: var(--blue);
}
.option-letter {
  font-size: .75rem; color: var(--text3); font-weight: 700;
  min-width: 1.1rem;
}
.option-text { font-size: .95rem; line-height: 1.5; }

/* T/F Buttons */
.tf-buttons { display: flex; gap: .75rem; }
.tf-btn {
  flex: 1; padding: .75rem; border-radius: 10px;
  border: 1px solid var(--border);
  background: none; color: var(--text2);
  font-family: var(--font-ar); font-size: .95rem; font-weight: 700;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.tf-btn:hover { background: rgba(255,255,255,.04); }
.tf-btn.selected-true  { background: rgba(34,197,94,.15);  border-color: rgba(34,197,94,.5);  color: var(--correct); }
.tf-btn.selected-false { background: rgba(239,68,68,.15);  border-color: rgba(239,68,68,.5);  color: var(--wrong); }

/* Fill & Short Answer */
.q-input, .q-textarea {
  width: 100%; padding: .75rem 1rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: var(--font-ar); font-size: .95rem;
  resize: vertical; direction: rtl;
  transition: border-color .2s;
}
.q-input:focus, .q-textarea:focus {
  outline: none; border-color: rgba(44,182,125,.5);
}
.q-hint {
  margin-top: .4rem; font-size: .75rem; color: var(--text3);
}

/* ─── SUBMIT ──────────────────────────────────── */
.submit-zone { text-align: center; margin-top: 2rem; }
.btn-submit {
  background: linear-gradient(135deg, var(--gold), #a07c18);
  border: none; color: #0d1117;
  padding: 1rem 3rem; border-radius: 50px;
  font-family: var(--font-ar); font-size: 1.05rem; font-weight: 900;
  cursor: pointer; transition: transform .2s, box-shadow .2s;
  box-shadow: 0 4px 20px rgba(201,162,39,.4);
}
.btn-submit:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(201,162,39,.5); }
.btn-submit:active { transform: translateY(0); }

/* ─── RESULTS ─────────────────────────────────── */
.results-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
}
.score-card {
  max-width: 420px; margin: 1rem auto;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
}
.score-emoji  { font-size: 3.5rem; margin-bottom: .5rem; }
.score-number {
  font-size: 3.5rem; font-weight: 900;
  background: linear-gradient(135deg, var(--gold-light), var(--teal));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.score-label  { font-size: 1.1rem; font-weight: 700; margin: .25rem 0; }
.score-detail { font-size: .85rem; color: var(--text2); }

.grading-status {
  display: flex; align-items: center; gap: .75rem;
  justify-content: center; margin-top: 1rem;
  color: var(--text2); font-size: .9rem;
}
.grading-status.hidden { display: none; }
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.1);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RESULT CARDS ────────────────────────────── */
.results-body {
  max-width: 820px; margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
  display: flex; flex-direction: column; gap: 1rem;
}

.r-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  border-right: 4px solid transparent;
}
.r-card.r-correct { border-right-color: var(--correct); }
.r-card.r-wrong   { border-right-color: var(--wrong);   }
.r-card.r-partial { border-right-color: var(--gold);    }
.r-card.r-pending { border-right-color: var(--blue);    }

.r-header {
  display: flex; align-items: flex-start; gap: .75rem;
  margin-bottom: .75rem;
}
.r-status-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: .1rem; }
.r-question    { font-size: .95rem; line-height: 1.6; font-family: 'Amiri', serif; flex: 1; }
.r-score-badge {
  padding: .2rem .6rem; border-radius: 50px; font-size: .75rem; font-weight: 700;
  flex-shrink: 0; white-space: nowrap;
}
.r-score-badge.correct { background: rgba(34,197,94,.15); color: var(--correct); }
.r-score-badge.wrong   { background: rgba(239,68,68,.15); color: var(--wrong); }
.r-score-badge.partial { background: rgba(201,162,39,.15); color: var(--gold); }
.r-score-badge.pending { background: rgba(61,142,240,.15); color: var(--blue); }

.r-answer-row { font-size: .85rem; margin-bottom: .4rem; }
.r-answer-row .lbl { color: var(--text3); margin-left: .4rem; }
.r-answer-row .val-correct { color: var(--correct); }
.r-answer-row .val-wrong   { color: var(--wrong); text-decoration: line-through; }
.r-answer-row .val-student { color: var(--text2); }

.r-explanation {
  margin-top: .6rem; font-size: .8rem; color: var(--text3);
  background: rgba(255,255,255,.03);
  padding: .5rem .75rem; border-radius: 8px;
  border-right: 2px solid rgba(255,255,255,.08);
}
.r-ai-feedback {
  margin-top: .6rem; font-size: .82rem; color: var(--text2);
  background: rgba(44,182,125,.05);
  border: 1px solid rgba(44,182,125,.15);
  padding: .6rem .75rem; border-radius: 8px;
}
.r-ai-feedback .feedback-label { color: var(--teal); font-weight: 700; display: block; margin-bottom: .25rem; font-size: .75rem; }

.r-ai-pending {
  display: flex; align-items: center; gap: .5rem;
  font-size: .82rem; color: var(--blue);
  margin-top: .5rem;
}

/* ─── RESULTS FOOTER ──────────────────────────── */
.results-footer {
  position: sticky; bottom: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex; gap: 1rem; justify-content: center;
}
.btn-retry, .btn-home-2 {
  padding: .7rem 2rem; border-radius: 50px;
  font-family: var(--font-ar); font-size: .95rem; font-weight: 700;
  cursor: pointer; transition: transform .2s;
  border: none;
}
.btn-retry  { background: linear-gradient(135deg, var(--teal), #1a8a56); color: #fff; }
.btn-home-2 { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--border); }
.btn-retry:hover, .btn-home-2:hover { transform: translateY(-2px); }

/* ─── HOME FOOTER ─────────────────────────────── */
.home-footer {
  text-align: center; padding: 1.5rem;
  color: var(--text3); font-size: .8rem;
  position: relative; z-index: 1;
}

/* ─── RESPONSIVE ──────────────────────────────── */
@media (max-width: 600px) {
  .exam-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .progress-wrap { width: 100%; min-width: unset; }
  .tf-buttons { gap: .5rem; }
  .sets-grid { grid-template-columns: 1fr; padding: 0 1rem; }
  .results-footer { flex-direction: column; }
}
