/* ===== Exam Generator: modal + runner + report ===== */
:root{
  --exam-primary:#4f46e5;
  --exam-primary-dark:#3730a3;
  --exam-success:#16a34a;
  --exam-danger:#dc2626;
  --exam-warn:#d97706;
  --exam-bg:#ffffff;
  --exam-bg-soft:#f4f5fb;
  --exam-border:#e4e4f0;
  --exam-text:#1f2333;
  --exam-text-soft:#6b7080;
  --exam-radius:16px;
}

.exam-overlay{
  position:fixed; inset:0; background:rgba(20,20,35,.55);
  display:flex; align-items:center; justify-content:center;
  z-index:9999; padding:16px; direction:rtl;
  font-family:inherit; backdrop-filter:blur(2px);
}
.exam-overlay[hidden]{ display:none; }

.exam-modal{
  background:var(--exam-bg); border-radius:var(--exam-radius);
  width:100%; max-width:640px; max-height:92vh; overflow:hidden;
  display:flex; flex-direction:column;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
  animation:examPopIn .18s ease-out;
}
@keyframes examPopIn{ from{ transform:translateY(12px); opacity:0 } to{ transform:none; opacity:1 } }

.exam-modal-header{
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 22px; border-bottom:1px solid var(--exam-border);
}
.exam-modal-header h3{ margin:0; font-size:18px; color:var(--exam-text); }
.exam-close-btn{
  background:none; border:none; font-size:22px; line-height:1; cursor:pointer;
  color:var(--exam-text-soft); padding:4px 8px; border-radius:8px;
}
.exam-close-btn:hover{ background:var(--exam-bg-soft); color:var(--exam-text); }

.exam-steps{ display:flex; gap:6px; padding:14px 22px 0; }
.exam-step-dot{ flex:1; height:4px; border-radius:4px; background:var(--exam-border); }
.exam-step-dot.active{ background:var(--exam-primary); }
.exam-step-dot.done{ background:var(--exam-primary); opacity:.5; }

.exam-modal-body{ padding:20px 22px; overflow-y:auto; flex:1; }
.exam-step-title{ font-size:15px; font-weight:700; color:var(--exam-text); margin:0 0 4px; }
.exam-step-sub{ font-size:13px; color:var(--exam-text-soft); margin:0 0 16px; }

.exam-choice-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:10px; }
.exam-choice-card{
  border:2px solid var(--exam-border); border-radius:12px; padding:12px 10px;
  text-align:center; cursor:pointer; user-select:none; font-size:14px; color:var(--exam-text);
  transition:.15s;
}
.exam-choice-card:hover{ border-color:#c7c9f5; }
.exam-choice-card.selected{ border-color:var(--exam-primary); background:#eef0ff; color:var(--exam-primary-dark); font-weight:700; }
.exam-choice-card small{ display:block; color:var(--exam-text-soft); font-size:11px; margin-top:2px; }

.exam-chapter{ border:1px solid var(--exam-border); border-radius:12px; margin-bottom:10px; overflow:hidden; }
.exam-chapter-head{ display:flex; align-items:center; gap:10px; padding:12px 14px; background:var(--exam-bg-soft); cursor:pointer; }
.exam-chapter-head input{ width:17px; height:17px; accent-color:var(--exam-primary); }
.exam-chapter-title{ flex:1; font-size:14px; font-weight:600; color:var(--exam-text); }
.exam-chapter-badge{ font-size:11px; color:var(--exam-text-soft); background:#fff; border:1px solid var(--exam-border); border-radius:999px; padding:2px 8px; }
.exam-chapter-toggle{ color:var(--exam-text-soft); font-size:12px; }
.exam-topics{ padding:6px 14px 12px 14px; display:none; }
.exam-chapter.open .exam-topics{ display:block; }
.exam-chapter.open .exam-chapter-toggle{ transform:rotate(180deg); }
.exam-topic-row{ display:flex; align-items:center; gap:10px; padding:6px 4px; font-size:13.5px; color:var(--exam-text); }
.exam-topic-row input{ width:16px; height:16px; accent-color:var(--exam-primary); }

.exam-count-input{
  width:100%; padding:12px 14px; border:2px solid var(--exam-border); border-radius:12px;
  font-size:15px; text-align:center; color:var(--exam-text); direction:ltr;
}
.exam-count-input:focus{ outline:none; border-color:var(--exam-primary); }

.exam-empty-note{ font-size:12px; color:var(--exam-text-soft); margin-top:10px; }
.exam-error-box{
  background:#fdeaea; color:var(--exam-danger); border:1px solid #f7c9c9; border-radius:10px;
  padding:10px 12px; font-size:13px; margin-top:12px;
}

.exam-modal-footer{ display:flex; justify-content:space-between; gap:10px; padding:16px 22px; border-top:1px solid var(--exam-border); }
.exam-btn{ border:none; border-radius:10px; padding:10px 20px; font-size:14px; cursor:pointer; font-weight:600; }
.exam-btn-primary{ background:var(--exam-primary); color:#fff; }
.exam-btn-primary:hover{ background:var(--exam-primary-dark); }
.exam-btn-primary:disabled{ background:#c7c9f5; cursor:not-allowed; }
.exam-btn-ghost{ background:var(--exam-bg-soft); color:var(--exam-text); }
.exam-btn-ghost:hover{ background:var(--exam-border); }
.exam-btn-sm{ padding:8px 14px; font-size:13px; }
.exam-btn:disabled{ opacity:.45; cursor:not-allowed; }

.exam-login-note{ text-align:center; padding:30px 10px; }
.exam-login-note p{ color:var(--exam-text-soft); margin-bottom:16px; }

/* ===== Exam runner ===== */
.exam-runner{
  position:fixed; inset:0; background:var(--exam-bg-soft); z-index:9998;
  display:flex; flex-direction:column; direction:rtl;
  transition:background .2s, color .2s;
}
.exam-runner[data-theme="dark"]{
  --exam-bg:#171923; --exam-bg-soft:#10121a; --exam-border:#2b2e3d;
  --exam-text:#eef0fa; --exam-text-soft:#9aa0bb;
}

.exam-runner-top{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:14px 20px; background:var(--exam-bg); border-bottom:1px solid var(--exam-border);
}
.exam-top-left, .exam-top-right{ display:flex; align-items:center; gap:10px; }
.exam-progress{ font-size:13px; color:var(--exam-text-soft); }
.exam-timer{
  font-weight:800; font-size:18px; color:var(--exam-primary); direction:ltr; min-width:76px; text-align:center;
  background:#eef0ff; border-radius:10px; padding:4px 12px;
}
.exam-runner[data-theme="dark"] .exam-timer{ background:#22243a; }
.exam-timer.warn{ color:var(--exam-danger); background:#fdeaea; }
.exam-runner[data-theme="dark"] .exam-timer.warn{ background:#3a1f22; }
.exam-exit-btn{ background:none; border:1px solid var(--exam-border); border-radius:8px; padding:6px 12px; font-size:13px; cursor:pointer; color:var(--exam-text-soft); }
.exam-theme-toggle{
  border:1px solid var(--exam-border); background:var(--exam-bg-soft); border-radius:50%;
  width:34px; height:34px; display:flex; align-items:center; justify-content:center;
  cursor:pointer; font-size:16px; color:var(--exam-text);
}

.exam-runner-body{ flex:1; overflow-y:auto; display:flex; justify-content:center; padding:24px 16px; }
.exam-question-wrap{ width:100%; max-width:680px; }
.exam-question-img{ width:100%; border-radius:14px; border:1px solid var(--exam-border); background:#fff; }
.exam-options{ display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-top:18px; }
.exam-option-btn{
  padding:14px 6px; border:2px solid var(--exam-border); background:var(--exam-bg); border-radius:12px;
  font-size:15px; font-weight:700; cursor:pointer; color:var(--exam-text);
}
.exam-option-btn.selected{ border-color:var(--exam-primary); background:#eef0ff; color:var(--exam-primary-dark); }
.exam-runner[data-theme="dark"] .exam-option-btn.selected{ background:#242a52; color:#c7cdff; }

.exam-essay-actions{ margin-top:18px; text-align:center; }
.exam-essay-actions .exam-answer-img{ max-width:100%; border-radius:12px; border:1px solid var(--exam-border); margin-top:14px; display:none; }
.exam-self-check{ display:none; gap:10px; justify-content:center; margin-top:14px; }
.exam-self-check .exam-btn{ min-width:110px; }

.exam-action-row{
  display:flex; align-items:center; justify-content:center; gap:10px;
  margin-top:18px; flex-wrap:wrap;
}
.exam-action-row .exam-btn{ min-width:110px; }

/* ===== Report ===== */
.exam-report{ max-width:760px; margin:0 auto; padding:24px 16px 60px; direction:rtl; }

.exam-report-hero{
  background:linear-gradient(135deg, var(--exam-primary), #7c3aed);
  border-radius:20px; padding:26px 22px; color:#fff; margin-bottom:18px;
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:16px;
}
.exam-report-hero-meta{ font-size:12px; opacity:.85; line-height:2; }
.exam-report-hero-score{ text-align:center; }
.exam-report-hero-score .num{ font-size:44px; font-weight:800; line-height:1; }
.exam-report-hero-score .lbl{ font-size:12px; opacity:.85; margin-top:4px; }

.exam-report-summary{
  background:var(--exam-bg); border:1px solid var(--exam-border); border-radius:16px; padding:18px;
  display:grid; grid-template-columns:repeat(3,1fr); gap:12px; text-align:center; margin-bottom:14px;
}
.exam-report-stat{ font-size:13px; color:var(--exam-text-soft); }
.exam-report-stat b{ display:block; font-size:20px; color:var(--exam-text); }
.exam-report-stat.correct b{ color:var(--exam-success); }
.exam-report-stat.wrong b{ color:var(--exam-danger); }
.exam-report-stat.unanswered b{ color:var(--exam-text-soft); }

.exam-difficulty-box{
  background:var(--exam-bg); border:1px solid var(--exam-border); border-radius:16px; padding:18px;
  margin-bottom:22px;
}
.exam-difficulty-box h4{ margin:0 0 12px; font-size:14px; color:var(--exam-text); }
.exam-difficulty-row{ display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.exam-difficulty-row:last-child{ margin-bottom:0; }
.exam-difficulty-label{ width:64px; font-size:13px; color:var(--exam-text-soft); flex-shrink:0; }
.exam-difficulty-bar-track{ flex:1; height:10px; border-radius:6px; background:var(--exam-bg-soft); overflow:hidden; }
.exam-difficulty-bar-fill{ height:100%; border-radius:6px; background:var(--exam-success); transition:width .4s; }
.exam-difficulty-count{ font-size:12px; color:var(--exam-text-soft); width:52px; text-align:left; direction:ltr; flex-shrink:0; }

.exam-report-item{
  background:var(--exam-bg); border:1px solid var(--exam-border); border-radius:14px; padding:14px; margin-bottom:14px;
}
.exam-report-item.correct{ border-color:#bfe6c8; }
.exam-report-item.wrong{ border-color:#f3bcbc; }
.exam-report-item-head{ display:flex; gap:12px; align-items:flex-start; }
.exam-report-badge{
  min-width:28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:800; color:#fff; flex-shrink:0;
}
.exam-report-item.correct .exam-report-badge{ background:var(--exam-success); }
.exam-report-item.wrong .exam-report-badge{ background:var(--exam-danger); }
.exam-report-item.unanswered .exam-report-badge{ background:#9ca3af; }

.exam-report-meta{ font-size:12px; color:var(--exam-text-soft); margin-bottom:4px; display:flex; flex-wrap:wrap; gap:6px; }
.exam-report-qnum{ font-size:13.5px; font-weight:700; color:var(--exam-text); margin-bottom:6px; }
.exam-report-meta span{ background:var(--exam-bg-soft); border-radius:999px; padding:2px 9px; }
.exam-report-answer-line{ font-size:13px; color:var(--exam-text); margin-top:4px; }
.exam-report-item img{ width:100%; border-radius:10px; margin-top:8px; }

.exam-show-answer-btn{
  margin-top:10px; background:var(--exam-bg-soft); border:1px solid var(--exam-border);
  color:var(--exam-text); border-radius:9px; padding:8px 14px; font-size:12.5px; cursor:pointer; font-weight:600;
}
.exam-report-answer-collapse{ display:none; margin-top:10px; }
.exam-report-answer-collapse.open{ display:block; }

/* ===== دکمه مارک/بوکمارک ===== */
.exam-mark-btn{
  background:var(--exam-bg-soft); border:1px solid var(--exam-border); color:var(--exam-text-soft);
  width:34px; height:34px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  cursor:pointer; font-size:15px; flex-shrink:0; transition:.15s;
}
.exam-mark-btn:hover{ border-color:var(--exam-primary); color:var(--exam-primary); }
.exam-mark-btn.marked{
  background:linear-gradient(135deg, var(--exam-primary), #7c3aed); color:#fff; border-color:transparent;
}
.exam-stage-top{ display:flex; align-items:center; justify-content:flex-end; margin-bottom:8px; }
.exam-report-item-head{ position:relative; }
.exam-report-mark-wrap{ margin-inline-start:auto; }

/* ===== تصاویر قابل زوم ===== */
.exam-zoomable{ position:relative; cursor:zoom-in; }
.exam-zoom-hint{
  position:absolute; bottom:8px; left:8px; background:rgba(0,0,0,.55); color:#fff;
  font-size:11px; padding:4px 10px; border-radius:20px;
}

.exam-lightbox{
  position:fixed; inset:0; z-index:100000; background:rgba(0,0,0,.92);
  display:none; align-items:center; justify-content:center; padding:20px;
}
.exam-lightbox.active{ display:flex; }
.exam-lightbox img{ max-width:92vw; max-height:88vh; border-radius:10px; background:#fff; object-fit:contain; }
.exam-lightbox-close{
  position:absolute; top:18px; left:18px; color:#fff; font-size:30px; cursor:pointer; opacity:.85;
}
.exam-lightbox-close:hover{ opacity:1; }

@media (max-width:520px){
  .exam-options{ grid-template-columns:repeat(2,1fr); }
  .exam-report-summary{ grid-template-columns:repeat(3,1fr); }
  .exam-action-row .exam-btn{ min-width:90px; }
}

/* ===== تصاویر سوال/پاسخ در حالت شب: دو رنگ معکوس ===== */
.exam-runner[data-theme="dark"] .exam-question-img,
.exam-runner[data-theme="dark"] .exam-answer-img,
.exam-runner[data-theme="dark"] .exam-report-item img {
  filter: invert(0.92) hue-rotate(180deg);
  transition: filter .2s ease;
}

/* لایت‌باکس زوم هم باید تبعیت کنه (چون بیرون از exam-runner است) */
.exam-lightbox.theme-dark img {
  filter: invert(0.92) hue-rotate(180deg);
}