/**
 * Eduplayify Template: multi_select (الاختيار المتعدد)
 * تنسيقات قالب الاختيار المتعدد: خيارات ملوّنة قابلة للتحديد مع صور، ومربّح
 * تحديد واضح، وحالات (صحيح / خاطئ / مُهمَل / باهت) بعد التحقّق.
 */

.ms-wrap {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: clamp(6px, 1.5vh, 16px) 0;
}

/* ===== صورة السؤال ===== */
.ms-image-box {
    text-align: center;
}

.ms-wrap .ws-image {
    max-width: 96%;
    max-height: clamp(220px, 46vh, 500px);
    /* pointer بديل قديم للمتصفحات التي لا تعرف zoom-in */
    cursor: pointer;
    cursor: zoom-in;
    display: block;
    margin: 0 auto clamp(14px, 2.5vh, 22px);
    border-radius: clamp(12px, 2vw, 18px);
    object-fit: contain;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    padding: 6px;
}

/* ===== نص السؤال ===== */
.ms-prompt {
    font-size: clamp(1.2rem, 2.5vw + 0.2rem, 1.8rem);
    font-weight: 800;
    color: #0f172a;
    text-align: center;
    margin: 0 auto clamp(10px, 1.6vh, 16px);
    line-height: 1.55;
    max-width: 800px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #e2e8f0;
    border-radius: clamp(14px, 2vw, 20px);
    padding: clamp(14px, 2.2vw, 22px) clamp(18px, 3vw, 32px);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* ===== تلميح الاختيار ===== */
.ms-hint {
    text-align: center;
    font-size: clamp(0.92rem, 1.4vw, 1.05rem);
    font-weight: 700;
    color: #475569;
    margin: 0 0 clamp(12px, 2vh, 18px);
    padding: 8px 14px;
    border-radius: 20px;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
}

/* ===== شبكة الخيارات ===== */
.ms-options,
.ms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(240px, 45%, 400px), 1fr));
    gap: clamp(12px, 2vw, 20px);
    width: 100%;
    margin-bottom: clamp(14px, 2.5vh, 22px);
}

.ms-opt {
    position: relative;
    display: flex;
    align-items: center;
    gap: clamp(12px, 2vw, 18px);
    text-align: start;
    min-height: clamp(70px, 10vh, 92px);
    padding: clamp(12px, 2vw, 18px) clamp(16px, 2.2vw, 24px);
    font-family: inherit;
    border-radius: clamp(14px, 1.8vw, 20px);
    border: 2.5px solid transparent;
    cursor: pointer;
    overflow: hidden;
    outline: none;
    user-select: none;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.ms-opt:disabled {
    cursor: default;
}

/* مربّع التحديد (يعلو حرف الخيار) */
.ms-opt::after {
    content: '';
    position: absolute;
    inset-inline-end: 10px;
    inset-block-start: 10px;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2.5px solid rgba(15, 23, 42, 0.28);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.ms-opt.is-picked::after {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%);
    border-color: #1e3a8a;
    box-shadow: inset 0 0 0 3px #ffffff;
}

.ms-opt.is-picked {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
}

/* شارة حرف الخيار */
.ms-opt-letter {
    width: clamp(38px, 4.5vw, 48px);
    height: clamp(38px, 4.5vw, 48px);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: clamp(10px, 1.2vw, 14px);
    font-weight: 900;
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
}

.ms-opt-body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ms-opt-image {
    flex-shrink: 0;
    max-width: clamp(64px, 12vw, 110px);
    max-height: clamp(64px, 12vh, 110px);
    object-fit: contain;
    border-radius: 10px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    padding: 3px;
}

.ms-opt-text {
    font-weight: 700;
    font-size: clamp(1.05rem, 1.8vw, 1.3rem);
    line-height: 1.45;
    word-break: break-word;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #0f172a;
}

/* ===== الثيمات اللونية ===== */
.ms-opt.ms-theme-blue { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); border-color: #60a5fa; }
.ms-opt.ms-theme-blue .ms-opt-letter { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); color: #ffffff; }
.ms-opt.ms-theme-blue:hover:not(:disabled) { border-color: #2563eb; background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); }

.ms-opt.ms-theme-emerald { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); border-color: #4ade80; }
.ms-opt.ms-theme-emerald .ms-opt-letter { background: linear-gradient(135deg, #16a34a 0%, #15803d 100%); color: #ffffff; }
.ms-opt.ms-theme-emerald:hover:not(:disabled) { border-color: #16a34a; background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%); }

.ms-opt.ms-theme-amber { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); border-color: #fbbf24; }
.ms-opt.ms-theme-amber .ms-opt-letter { background: linear-gradient(135deg, #d97706 0%, #b45309 100%); color: #ffffff; }
.ms-opt.ms-theme-amber:hover:not(:disabled) { border-color: #d97706; background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); }

.ms-opt.ms-theme-purple { background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%); border-color: #c084fc; }
.ms-opt.ms-theme-purple .ms-opt-letter { background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%); color: #ffffff; }
.ms-opt.ms-theme-purple:hover:not(:disabled) { border-color: #7c3aed; background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%); }

.ms-opt.ms-theme-rose { background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%); border-color: #fb7185; }
.ms-opt.ms-theme-rose .ms-opt-letter { background: linear-gradient(135deg, #e11d48 0%, #be123c 100%); color: #ffffff; }
.ms-opt.ms-theme-rose:hover:not(:disabled) { border-color: #e11d48; background: linear-gradient(135deg, #ffe4e6 0%, #fecdd3 100%); }

.ms-opt.ms-theme-coral { background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%); border-color: #fb923c; }
.ms-opt.ms-theme-coral .ms-opt-letter { background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%); color: #ffffff; }
.ms-opt.ms-theme-coral:hover:not(:disabled) { border-color: #ea580c; background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%); }

.ms-opt.ms-theme-indigo { background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%); border-color: #818cf8; }
.ms-opt.ms-theme-indigo .ms-opt-letter { background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%); color: #ffffff; }
.ms-opt.ms-theme-indigo:hover:not(:disabled) { border-color: #4f46e5; background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%); }

.ms-opt.ms-theme-teal { background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%); border-color: #2dd4bf; }
.ms-opt.ms-theme-teal .ms-opt-letter { background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%); color: #ffffff; }
.ms-opt.ms-theme-teal:hover:not(:disabled) { border-color: #0d9488; background: linear-gradient(135deg, #ccfbf1 0%, #99f6e4 100%); }

/* ===== أزرار التحكم ===== */
.ms-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.ms-check {
    font-size: clamp(1.05rem, 1.8vw, 1.3rem);
    font-weight: 800;
    padding: 12px 34px;
    border-radius: 24px;
    min-width: 170px;
}

.ms-check:disabled {
    opacity: 0.5;
    cursor: default;
}

.ms-score-line {
    text-align: center;
    font-weight: 800;
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    color: #334155;
    margin-top: 6px;
}

/* ===== حالات ما بعد التحقّق ===== */
.ms-opt.correct,
.ms-opt.is-correct {
    border-color: #16a34a !important;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%) !important;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.3), 0 10px 26px rgba(34, 197, 94, 0.3) !important;
    transform: none;
}
.ms-opt.correct .ms-opt-letter,
.ms-opt.is-correct .ms-opt-letter { background: #ffffff !important; color: #15803d !important; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important; }
.ms-opt.correct .ms-opt-text,
.ms-opt.is-correct .ms-opt-text { color: #ffffff !important; }
.ms-opt.correct::after,
.ms-opt.is-correct::after { background: #ffffff; border-color: #16a34a; box-shadow: inset 0 0 0 3px #16a34a; }

.ms-opt.incorrect,
.ms-opt.is-incorrect {
    border-color: #dc2626 !important;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.3), 0 10px 26px rgba(239, 68, 68, 0.3) !important;
    opacity: 0.9;
    transform: none;
}
.ms-opt.incorrect .ms-opt-letter,
.ms-opt.is-incorrect .ms-opt-letter { background: #ffffff !important; color: #b91c1c !important; }
.ms-opt.incorrect .ms-opt-text,
.ms-opt.is-incorrect .ms-opt-text { color: #ffffff !important; }

.ms-opt.is-dimmed {
    opacity: 0.5;
    filter: grayscale(0.5);
    transform: none;
}

/* رسالة درجة جزئية */
.ms-wrap .ws-feedback.partial {
    background: #fffbeb;
    color: #92400e;
    border: 2px solid #f59e0b;
}

/* ===== ملء الشاشة والشاشات الكبيرة ===== */
.gpa-fullscreen .ms-wrap {
    max-width: 1040px;
    margin-top: auto;
    margin-bottom: auto;
}
.gpa-fullscreen .ms-options,
.gpa-fullscreen .ms-grid { grid-template-columns: repeat(2, 1fr); }
.gpa-fullscreen .ms-prompt { font-size: clamp(1.5rem, 3.2vw, 2.2rem); padding: 24px 36px; }
.gpa-fullscreen .ms-opt { min-height: 98px; }
.gpa-fullscreen .ms-opt-letter { width: 52px; height: 52px; font-size: 1.4rem; }

/* ===== الجوال ===== */
@media (max-width: 560px) {
    .ms-options,
    .ms-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .ms-opt {
        min-height: 64px;
        padding: 12px 14px;
        gap: 12px;
    }

    .ms-prompt {
        font-size: 1.2rem;
        padding: 13px 15px;
        margin-bottom: 14px;
    }

    .ms-check {
        width: 100%;
    }
}

/* مصيدة غير بديهية: grid/flex-gap غائبان في IE11/Safari<14.1 —
   الكتل أدناه بديل فقط عند الغياب، والحديث يتجاهلها */
@supports not (display: grid) {
    .ms-options, .ms-grid { display: block; }
    .ms-opt { display: flex; width: 100%; margin: 6px 0; }
}
@supports not (gap: 12px) {
    .ms-opt > * { margin: 0 6px; }
    .ms-opt-body > * { margin: 0 4px; }
    .ms-prompt > * { margin: 0 5px; }
}