/**
 * Eduplayify Engine: results-modal.css
 * أنماط نافذة مراجعة الإجابات والنتيجة التفصيلية بعد انتهاء اللعبة.
 * تدعم المتصفحات القديمة والأجهزة الضعيفة (انظر .ai/rules/project-memory.md §10 و§12).
 * استثناء موثّق من بوابة الباقات: متاح للجميع بقرار المالك الصريح (2026-11-07).
 */

/* الغلاف المعتم الخلفي */
.erm-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

/* النافذة المنبثقة الكبيرة */
.erm-modal {
    background: #ffffff;
    width: 100%;
    max-width: 960px;
    max-height: 92vh;
    border-radius: 16px;
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    font-family: inherit;
    animation: ermFadeIn 0.2s ease-out;
}

@keyframes ermFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

/* الشريط العلوي */
.erm-header {
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.erm-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.erm-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.erm-header-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.erm-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}

.erm-stat-chip.is-score {
    background: #ede9fe;
    color: #6d28d9;
}

.erm-stat-chip.is-correct {
    background: #dcfce7;
    color: #15803d;
}

.erm-stat-chip.is-incorrect {
    background: #fee2e2;
    color: #b91c1c;
}

.erm-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #e2e8f0;
    color: #475569;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
    padding: 0;
}

.erm-close-btn:hover {
    background: #cbd5e1;
    color: #0f172a;
}

/* شريط التنقل بالأسئلة */
.erm-stepper-wrap {
    padding: 10px 16px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    overflow-x: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
}

.erm-pill {
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
    box-sizing: border-box;
}

.erm-pill:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.erm-pill.is-correct {
    background: #dcfce7;
    color: #15803d;
    border-color: #86efac;
}

.erm-pill.is-incorrect {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

.erm-pill.is-partial {
    background: #fef3c7;
    color: #b45309;
    border-color: #fcd34d;
}

.erm-pill.is-active {
    outline: 3px solid #3b82f6;
    outline-offset: 1px;
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.35);
}

/* جسم النافذة */
.erm-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
}

/* ترويسة السؤال المعروض */
.erm-q-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.erm-q-label-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.erm-q-num {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
}

.erm-q-template-badge {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
}

.erm-q-points-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: 800;
}

.erm-q-points-badge.is-correct {
    background: #dcfce7;
    color: #15803d;
}

.erm-q-points-badge.is-incorrect {
    background: #fee2e2;
    color: #b91c1c;
}

.erm-q-points-badge.is-partial {
    background: #fef3c7;
    color: #b45309;
}

/* مربع نص السؤال وصورته */
.erm-prompt-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 20px;
    box-sizing: border-box;
}

.erm-q-img-wrap {
    text-align: center;
    margin-bottom: 14px;
}

.erm-q-img {
    max-height: 220px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    cursor: zoom-in;
    background: #ffffff;
}

.erm-q-prompt-text {
    margin: 0;
    font-size: 1.18rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.6;
    word-break: break-word;
}

/* أنماط مراجعة القوالب */
.erm-review-stage {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* اختيار من متعدد وصح وخطأ */
.erm-choices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.erm-choice-card {
    padding: 14px 16px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-sizing: border-box;
    transition: transform 0.15s;
}

.erm-choice-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.erm-choice-letter {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 800;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.erm-choice-text {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    word-break: break-word;
}

.erm-choice-card.is-correct {
    border-color: #22c55e;
    background: #f0fdf4;
}

.erm-choice-card.is-correct .erm-choice-letter {
    background: #22c55e;
    color: #ffffff;
}

.erm-choice-card.is-wrong-pick {
    border-color: #ef4444;
    background: #fef2f2;
}

.erm-choice-card.is-wrong-pick .erm-choice-letter {
    background: #ef4444;
    color: #ffffff;
}

.erm-choice-card.is-neutral {
    opacity: 0.65;
}

.erm-choice-tag {
    font-size: 0.75rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 8px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.erm-choice-tag.is-correct-tag {
    background: #dcfce7;
    color: #15803d;
}

.erm-choice-tag.is-wrong-tag {
    background: #fee2e2;
    color: #b91c1c;
}

/* قالب التوصيل */
.erm-match-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.erm-match-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

.erm-match-side {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #1e293b;
    flex: 1;
    min-width: 140px;
}

.erm-match-arrow {
    font-size: 1.2rem;
    color: #64748b;
    flex-shrink: 0;
}

.erm-match-side.is-target {
    color: #15803d;
}

/* قالب إكمال الفراغ والكلمات والحروف */
.erm-text-compare-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.erm-compare-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 8px;
    gap: 10px;
    flex-wrap: wrap;
}

.erm-compare-row.is-student {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
}

.erm-compare-row.is-student.is-correct {
    background: #f0fdf4;
    border-color: #86efac;
    color: #15803d;
}

.erm-compare-row.is-student.is-wrong {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.erm-compare-row.is-correct-target {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #15803d;
}

.erm-compare-label {
    font-weight: 800;
    font-size: 0.85rem;
    color: #475569;
}

.erm-compare-val {
    font-weight: 800;
    font-size: 1.05rem;
}

/* قالب الترتيب */
.erm-order-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.erm-order-row {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.erm-order-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.erm-order-chip {
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.erm-order-chip.is-target {
    background: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}

.erm-order-arrow {
    color: #94a3b8;
    font-weight: 800;
}

/* قالب التصنيف */
.erm-cls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.erm-cls-bucket {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.erm-cls-bucket-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
    padding-bottom: 6px;
    border-bottom: 2px solid #e2e8f0;
}

.erm-cls-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.erm-cls-item {
    padding: 6px 10px;
    border-radius: 8px;
    background: #f1f5f9;
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* الشريط السفلي */
.erm-footer {
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.erm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1.4;
}

.erm-btn-outline {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #334155;
}

.erm-btn-outline:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.erm-btn-primary {
    background: #2563eb;
    color: #ffffff;
}

.erm-btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.erm-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* زر مراجعة الإجابات في شاشة النهاية الأصلية */
.gp-btn-review {
    font-size: 1rem;
    font-weight: 800;
    padding: 10px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
}

.gp-btn-review:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

/* مراجعة قالب التوصيل على صورة (image_labeling) — نموذج الإجابة الصحيحة */
.erm-il-container {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-x: auto;
}

.erm-il-banner {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 9px 14px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.erm-il-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    min-width: 520px;
    min-height: 340px;
    direction: ltr !important;
    box-sizing: border-box;
    padding: 10px 0;
}

.erm-il-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: visible;
}

.erm-il-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 175px;
    flex-shrink: 0;
    z-index: 15;
}

.erm-il-card {
    padding: 9px 14px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.92rem;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
    position: relative;
    word-break: break-word;
    line-height: 1.35;
}

.erm-il-card-text {
    flex: 1;
    min-width: 0;
}

.erm-il-card-peg {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transform: translateY(-50%);
    box-sizing: border-box;
}

.erm-il-card-peg.is-right {
    right: -6px;
}

.erm-il-card-peg.is-left {
    left: -6px;
}

.erm-il-frame {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
    text-align: center;
}

.erm-il-img-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    margin: 0 auto;
}

.erm-il-img {
    display: block;
    max-width: 100%;
    max-height: 420px;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.erm-il-point {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2.5px solid #ffffff;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, -50%);
    z-index: 25;
    pointer-events: none;
    box-sizing: border-box;
}

/* تفاصيل نقاط التوصيل على صورة تحت الصورة */
.erm-il-results-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.erm-il-res-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.erm-il-res-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.erm-il-res-card {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.erm-il-res-card.is-correct {
    border-color: #86efac;
    background: #f0fdf4;
}

.erm-il-res-card.is-wrong {
    border-color: #fca5a5;
    background: #fef2f2;
}

.erm-il-res-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.erm-il-res-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.erm-il-res-name {
    font-weight: 800;
    font-size: 0.92rem;
    color: #1e293b;
    word-break: break-word;
}

.erm-il-res-badge {
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 800;
    white-space: nowrap;
}

.erm-il-res-badge.is-correct {
    background: #dcfce7;
    color: #15803d;
}

.erm-il-res-badge.is-wrong {
    background: #fee2e2;
    color: #b91c1c;
}

.erm-il-res-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 4px;
    border-top: 1px dashed #cbd5e1;
}

.erm-il-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 12px;
}

.erm-il-stat-pill.is-correct {
    background: #dcfce7;
    color: #15803d;
}

.erm-il-stat-pill.is-wrong {
    background: #fee2e2;
    color: #b91c1c;
}

/* التجاوب مع الشاشات الصغيرة */
@media (max-width: 640px) {
    .erm-backdrop {
        padding: 8px;
    }
    .erm-modal {
        max-height: 96vh;
        border-radius: 12px;
    }
    .erm-header, .erm-footer {
        padding: 10px 14px;
    }
    .erm-body {
        padding: 14px 12px;
    }
    .erm-title {
        font-size: 1rem;
    }
    .erm-pill {
        min-width: 34px;
        height: 34px;
        font-size: 0.85rem;
    }
    .erm-choices-grid {
        grid-template-columns: 1fr;
    }
    .erm-btn {
        padding: 7px 14px;
        font-size: 0.85rem;
    }
}

