/* =========================================================
   سیستم آزمون - استایل‌ها
   ========================================================= */

/* ─── Wrapper ─── */
.pwa-exam-wrap {
    font-family: inherit;
    direction: rtl;
}

/* ─── Topbar (Runner) ─── */
.pwa-exam-topbar {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 10px 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* ─── Timer ─── */
.pwa-timer {
    background: var(--bs-primary);
    color: #fff;
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
    transition: background .3s;
}
.pwa-timer.warning  { background: #ffc107; color: #000; }
.pwa-timer.danger   { background: #dc3545; animation: timerPulse .8s infinite; }

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .6; }
}

/* ─── Question Navigation Grid ─── */
.pwa-q-nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 4px;
}
.pwa-q-nav-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: .75rem;
    font-weight: 600;
    transition: all .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pwa-q-nav-btn:hover       { border-color: var(--bs-primary); color: var(--bs-primary); }
.pwa-q-nav-btn.current     { border-color: var(--bs-primary); background: var(--bs-primary); color: #fff; }
.pwa-q-nav-btn.answered    { border-color: #198754; background: #d1e7dd; color: #198754; }
.pwa-q-nav-btn.flagged     { border-color: #ffc107; background: #fff3cd; color: #856404; }
.pwa-q-nav-btn.unanswered  { border-color: #dee2e6; }

/* Legend badges */
.pwa-q-badge {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 2px solid;
    vertical-align: middle;
}
.pwa-q-badge.answered   { border-color: #198754; background: #d1e7dd; }
.pwa-q-badge.flagged    { border-color: #ffc107; background: #fff3cd; }
.pwa-q-badge.unanswered { border-color: #dee2e6; background: #fff; }

/* ─── Question Body ─── */
.pwa-question-stem {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 1rem;
    white-space: pre-wrap; /* حفظ line-breakهای واردشده در متن سؤال */
}

.pwa-question-stem p {
    margin-bottom: 0;
}

.pwa-question-passage {
    background: #f8f9fa;
    border-right: 4px solid var(--bs-primary);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 1rem;
    font-size: .95rem;
    line-height: 1.8;
    max-height: 240px;
    overflow-y: auto;
}
#reading-question,
#reading-passage {
    text-align: left;
    direction: ltr;
}
#pwa-qb-form textarea {
    text-align: left;
    direction: ltr;
}
/* MCQ Options */
.pwa-mcq-options { list-style: none; padding: 0; margin: 0; }
.pwa-mcq-option  {
    border: 2px solid #dee2e6;
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: 10px;
}
.pwa-mcq-option:hover          { border-color: var(--bs-primary); background: #f0f7ff; }
.pwa-mcq-option.selected       { border-color: var(--bs-primary); background: #e7f0ff; }
.pwa-mcq-option .option-circle {
    width: 22px; height: 22px;
    border: 2px solid #adb5bd;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem; transition: all .15s;
}
.pwa-mcq-option.selected .option-circle {
    border-color: var(--bs-primary);
    background: var(--bs-primary);
    color: #fff;
}

/* Gap Fill */
.pwa-gap-input {
    border: none;
    border-bottom: 2px solid var(--bs-primary);
    border-radius: 0;
    background: transparent;
    padding: 2px 6px;
    min-width: 80px;
    text-align: center;
    font-size: inherit;
    display: inline-block;
    vertical-align: middle;
    color: var(--bs-primary);
    font-weight: bold;
}
.pwa-gap-input:focus {
    outline: none;
    border-bottom-width: 3px;
    background: #e7f0ff;
}

/* Matching */
.pwa-matching-wrap { display: flex; gap: 1rem; }
.pwa-matching-col  { flex: 1; }
.pwa-matching-item {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all .15s;
    background: #fff;
    font-size: .9rem;
}
.pwa-matching-item.selected {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.35);
    background: #fff;
}
/* جفت‌های تطبیق با رنگ یکسان (کلاس‌های pwa-match-pair-0 …) */
.pwa-matching-item.pwa-match-pair-0 { border-color: #1565c0; background: #e3f2fd; }
.pwa-matching-item.pwa-match-pair-1 { border-color: #c62828; background: #ffebee; }
.pwa-matching-item.pwa-match-pair-2 { border-color: #2e7d32; background: #e8f5e9; }
.pwa-matching-item.pwa-match-pair-3 { border-color: #6a1b9a; background: #f3e5f5; }
.pwa-matching-item.pwa-match-pair-4 { border-color: #ef6c00; background: #fff3e0; }
.pwa-matching-item.pwa-match-pair-5 { border-color: #00838f; background: #e0f7fa; }
.pwa-matching-item.pwa-match-pair-6 { border-color: #5d4037; background: #efebe9; }
.pwa-matching-item.pwa-match-pair-7 { border-color: #ad1457; background: #fce4ec; }
.pwa-match-line-svg { flex-shrink: 0; }

/* Ordering (drag-sort) */
.pwa-ordering-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.pwa-ordering-item {
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 6px;
    background: #fff;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all .15s;
    user-select: none;
}
.pwa-ordering-item:active { cursor: grabbing; }
.pwa-ordering-item.dragging { opacity: .5; border-style: dashed; }
.pwa-ordering-item .drag-handle { color: #adb5bd; font-size: 1.2rem; }

/* Audio Player */
.pwa-audio-wrap {
    background: #f0f7ff;
    border: 2px solid var(--bs-primary);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
}
.pwa-audio-wrap audio { flex: 1; }
.pwa-play-count {
    font-size: .8rem;
    color: #6c757d;
    white-space: nowrap;
}
.pwa-play-count.maxed { color: #dc3545; font-weight: bold; }

/* Essay Textarea */
.pwa-essay-textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
    font-size: .95rem;
    line-height: 1.7;
    transition: border .15s;
}
.pwa-essay-textarea:focus { border-color: var(--bs-primary); outline: none; }
.pwa-word-count {
    text-align: left;
    font-size: .8rem;
    color: #6c757d;
    margin-top: 4px;
}
.pwa-word-count.below-min { color: #dc3545; }
.pwa-word-count.above-max { color: #dc3545; font-weight: bold; }
.pwa-word-count.ok        { color: #198754; }

/* ─── Autosave Status ─── */
#pwa-autosave-status {
    font-size: .78rem;
    height: 18px;
}

/* ─── Score Circle (Results) ─── */
.pwa-score-circle {
    width: 160px;
    height: 160px;
}

/* چرخش فقط روی <g> داخل SVG است؛ کل svg را نچرخانید تا درصد افقی بماند */
.pwa-score-circle svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.qb-q-table .qb-q-user-txt,
.qb-q-table .qb-q-key-txt,
.qb-q-table .qb-q-title {
    text-align: left;
    direction: ltr;
}

.qb-q-table .qb-q-user-txt {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}
/* ─── Mini Gauge (Student History) ─── */
.pwa-mini-gauge-val {
    font-size: 2rem;
    font-weight: bold;
}

/* ─── Grading Card ─── */
.pwa-grading-card { border-right: 4px solid #ffc107; }
.pwa-grading-card.graded { border-right-color: #198754; }

/* ─── Question Bank Table ─── */
#pwa-qb-list-wrap .table th,
#pwa-qb-list-wrap .table td { vertical-align: middle; font-size: .9rem; }
#pwa-qb-list-wrap .qb-q-title { direction: ltr; text-align: left; }

/* ─── Section Builder ─── */
.pwa-section-card {
    border: 2px solid #dee2e6;
    border-radius: 10px;
    margin-bottom: 1rem;
}
.pwa-section-card .section-header {
    background: #f8f9fa;
    padding: 10px 14px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}
.pwa-section-card .section-body { padding: 12px 14px; }
.pwa-section-q-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #f0f0f0;
    padding: 6px 0;
    font-size: .85rem;
}
.pwa-section-q-row .qb-q-title {
    text-align: left;
    direction: ltr;
}
.pwa-section-q-row:last-child { border-bottom: none; }
.pwa-section-card .min-w-0 { min-width: 0; }


#pwa-exam-intro {
    max-width: 600px;
    margin: 0 auto;
}

#pwa-question-body {
    text-align: left;
    direction: ltr;
}

.mcq-option-row {
    flex-direction: row-reverse;
}

#mcq-options-wrap .input-group .input-group-text{
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
    border-right: none;
}
#mcq-options-wrap .input-group .btn:not(.mcq-correct-label) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

#mcq-options-wrap input[type="text"] {
    margin-left: 0;
    margin-right: 0;
    text-align: left;
    direction: ltr;
}

#pwa-section-desc {
    white-space: pre-wrap;
    text-align: left;
    direction: ltr;
    font-size: 1.3rem;
    font-family: monospace;
    font-weight: 700;
}

#pwa-question-body {
    font-family: monospace;
    font-weight: 700;
}

.pwa-exam-q-modal-block-content {
    white-space: pre-wrap;
    text-align: left;
    direction: ltr;
    font-family: monospace;
    font-weight: 700;
}

.pwa-exam-q-modal-block-ol {
    list-style-type: none;
    padding-left: 0;
    margin-left: 0;
    font-family: monospace;
    font-weight: 700;
    text-align: left;
    direction: ltr;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .pwa-exam-topbar { flex-direction: column; gap: 8px; align-items: flex-start; }
    .pwa-q-nav-grid  { grid-template-columns: repeat(6, 1fr); }
    .pwa-matching-wrap { flex-direction: column; }
    .pwa-score-circle { width: 120px; height: 120px; }
}

@media (max-width: 576px) {
    .pwa-q-nav-grid { grid-template-columns: repeat(5, 1fr); }
    .pwa-question-stem { font-size: .95rem; }
}
