/* ==========================================================================
   Madrasatye Skills Arena - Master UI/UX (Compact & Responsive)
   ========================================================================== */

/* --- السحر هنا: إجبار جميع عناصر الإضافة على وراثة خط القالب الأساسي --- */
.msa-quiz-container,
.msa-quiz-container * {
    font-family: inherit !important;
}
/* ------------------------------------------------------------------------- */
/* الحاوية الرئيسية (Main Container) */
.msa-quiz-container {
    background: #ffffff; border: none; border-radius: 12px; /* تقليل الاستدارة قليلاً */
    padding: 20px 25px; /* تقليل الحشو الداخلي من 30px لتوفير مساحة */
    max-width: 700px; /* توسيع العرض قليلاً ليستوعب أسئلة أطول أفقياً */
    margin: 20px auto; /* تقليل الهامش الخارجي */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    position: relative; overflow: hidden;
    font-family: inherit; /* وراثة خط القالب */
}

/* شريط التقدم (Progress Bar) */
.msa-progress-container { 
    background: #e9ecef; border-radius: 8px; height: 6px; /* تقليل الارتفاع من 8 إلى 6 */
    width: 100%; margin-bottom: 15px; /* تقليل الهامش السفلي من 20 إلى 15 */
    overflow: hidden; 
}
.msa-progress-bar { 
    height: 100%; background: linear-gradient(90deg, #0073aa, #00d2ff); 
    width: 0%; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 8px; 
}

/* الترويسة واسم الطالب */
.msa-quiz-header { 
    display: flex; justify-content: space-between; align-items: center; 
    border-bottom: 2px solid #f1f3f5; padding-bottom: 10px; /* تقليل الحشو من 15 إلى 10 */
    margin-bottom: 15px; /* تقليل الهامش من 25 إلى 15 */
}
.msa-quiz-header h2 { margin: 0; font-size: 1.3em; color: #2c3e50; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.msa-student-display-name { background: #f8f9fa; padding: 4px 10px; border-radius: 15px; font-size: 0.75em; color: #0073aa; border: 1px solid #e2e8f0; }
.msa-score-board { font-weight: 800; font-size: 1.1em; color: #0073aa; background: #e6f6ff; padding: 5px 12px; border-radius: 15px; }

/* صندوق القطعة النصية (Reading Passage) & الصوت */
.msa-passage-box {
    background: #f8fcff; padding: 12px 15px; /* تقليل الحشو من 20 إلى 12 */
    border-radius: 8px; margin-bottom: 15px; /* تقليل الهامش من 20 إلى 15 */
    font-size: 0.9em; line-height: 1.6; color: #34495e; box-shadow: inset 0 0 8px rgba(0,0,0,0.02);
}
/* مشغل الوسائط (Audio & Video Player) */
.msa-media-box {
    margin-bottom: 15px;
    padding: 15px;
    background: #fff3cd;
    border-radius: 12px;
    border: 1px solid #ffeeba;
    text-align: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
}
.msa-media-box audio {
    width: 100%;
    max-width: 400px;
    height: 40px;
    outline: none;
}
.msa-media-box video {
    width: 100%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    outline: none;
    background: #000;
}
.msa-media-label {
    display: block;
    margin-bottom: 10px;
    color: #856404;
    font-weight: bold;
    font-size: 0.9em;
}

/* المؤقت الزمني */
.msa-timer-display { font-weight: bold; font-size: 1.05em; color: #dc3545; background: #fff5f5; padding: 4px 10px; border-radius: 15px; border: 1px solid #ffc107; display: inline-flex; align-items: center; gap: 4px; margin: 0 8px; }
.msa-timer-warning { animation: pulseRed 1s infinite; background: #dc3545; color: white; }

/* دعم الاتجاهات (RTL / LTR) */
.msa-align-right { text-align: right; } .msa-align-left { text-align: left; }
.msa-align-right .msa-passage-box { border-right: 4px solid #0073aa; } .msa-align-left .msa-passage-box { border-left: 4px solid #0073aa; }
.msa-align-right .msa-quiz-header { flex-direction: row; } .msa-align-left .msa-quiz-header { flex-direction: row-reverse; }

/* الأزرار العامة */
.msa-btn {
    background: linear-gradient(135deg, #0073aa, #005b88); color: white; border: none;
    padding: 10px 20px; /* تقليل الحشو من 12 إلى 10 */
    border-radius: 8px; cursor: pointer; font-size: 1.05em; font-weight: bold;
    transition: all 0.2s ease; box-shadow: 0 4px 10px rgba(0, 115, 170, 0.15);
    touch-action: manipulation; /* تحسين استجابة اللمس للموبايل */
}
.msa-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 15px rgba(0, 115, 170, 0.25); }
.msa-btn:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; box-shadow: none; }

/* أزرار الخيارات (Options) - الضغط المريح */
.msa-option-btn {
    display: block; width: 100%; 
    margin-bottom: 8px; /* تقليل الهامش السفلي بين الخيارات من 12 إلى 8 */
    padding: 10px 15px; /* تقليل الارتفاع الداخلي من 15 إلى 10 */
    background: #ffffff; border: 2px solid #e2e8f0; border-radius: 8px; 
    cursor: pointer; font-size: 1em; color: #495057;
    transition: all 0.15s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    touch-action: manipulation;
}
.msa-align-right .msa-option-btn { text-align: right; } .msa-align-left .msa-option-btn { text-align: left; }
.msa-align-right .msa-option-btn:hover:not(:disabled) { border-color: #0073aa; background: #f8fcff; transform: translateX(-3px); }
.msa-align-left .msa-option-btn:hover:not(:disabled) { border-color: #0073aa; background: #f8fcff; transform: translateX(3px); }
.msa-selected { background: #e6f6ff !important; border-color: #0073aa !important; color: #0073aa !important; font-weight: bold; transform: none !important; }

/* حقول الإدخال (Inputs) */
.msa-text-input {
    width: 100%; padding: 12px; font-size: 1em; border: 2px solid #e2e8f0; border-radius: 8px;
    box-sizing: border-box; margin-bottom: 10px; font-family: inherit; transition: border-color 0.2s ease; background: #f8f9fa;
}
.msa-align-right .msa-text-input { text-align: right; } .msa-align-left .msa-text-input { text-align: left; }
.msa-text-input:focus { outline: none; border-color: #0073aa; background: #ffffff; }

/* حالات الإجابة والصور */
.msa-correct { background: #d4edda !important; border-color: #28a745 !important; color: #155724 !important; font-weight: bold; }
.msa-incorrect { background: #f8d7da !important; border-color: #dc3545 !important; color: #721c24 !important; animation: shake 0.4s; }
.msa-quiz-container img { max-width: 100%; height: auto; } /* لمنع تجاوز الصور لربع الشاشة */
.msa-animate-in { animation: slideUpFade 0.3s ease-out forwards; } /* تسريع حركة الدخول من 0.4 إلى 0.3 */

/* مراجعة الإجابات */
.msa-review-section { margin-top: 30px; text-align: right; border-top: 2px solid #e9ecef; padding-top: 20px; }
.msa-align-left .msa-review-section { text-align: left; }
.msa-review-section h3 { color: #2c3e50; font-size: 1.3em; margin-bottom: 15px; text-align: center; }
.msa-review-item { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; margin-bottom: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.msa-review-q { font-weight: bold; color: #34495e; font-size: 1.05em; margin-bottom: 10px; line-height: 1.4; }
.msa-review-ans { font-size: 0.95em; padding: 10px 12px; border-radius: 6px; margin-bottom: 6px; }
.msa-review-wrong { background: #f8d7da; color: #721c24; border-right: 4px solid #dc3545; }
.msa-align-left .msa-review-wrong { border-right: none; border-left: 4px solid #dc3545; }
.msa-review-right { background: #d4edda; color: #155724; border-right: 4px solid #28a745; }
.msa-align-left .msa-review-right { border-right: none; border-left: 4px solid #28a745; }

/* الأوسمة (Badges) */
.msa-personal-best { font-size: 0.9em; color: #6c757d; text-align: center; margin-bottom: 15px; padding: 8px; background: #f8f9fa; border-radius: 6px; border: 1px dashed #ced4da; }
.msa-badges-container { display: flex; justify-content: center; gap: 10px; margin: 20px 0; flex-wrap: wrap; }
.msa-badge { display: flex; flex-direction: column; align-items: center; padding: 15px; border-radius: 10px; background: #fff; box-shadow: 0 4px 10px rgba(0,0,0,0.05); border: 2px solid #e9ecef; animation: popIn 0.5s forwards; opacity: 0; transform: scale(0.5); width: 130px; box-sizing: border-box;}
.msa-badge-icon { font-size: 3em; margin-bottom: 8px; }
.msa-badge-title { font-weight: bold; color: #2c3e50; font-size: 1em; margin-bottom: 4px; text-align:center;}
.msa-badge-desc { font-size: 0.75em; color: #7f8c8d; text-align: center; line-height: 1.3; }
.badge-perfect { border-color: #ffd700; background: linear-gradient(to bottom, #fffcf0, #fff); }
.badge-great { border-color: #28a745; background: linear-gradient(to bottom, #f0fdf4, #fff); }
.badge-good { border-color: #17a2b8; background: linear-gradient(to bottom, #f0f9ff, #fff); }
.msa-celebration { font-size: 2.2em; display: block; margin-bottom: 10px; animation: bounce 1s infinite alternate; }

/* Animations */
@keyframes slideUpFade { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { 0% { opacity: 0; transform: scale(0.5) translateY(15px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(4px); } 50% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes pulseRed { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes bounce { 0% { transform: translateY(0); } 100% { transform: translateY(-10px); } }

/* ==========================================================================
   Responsive Design for Small Screens (Mobile-First) - شاشات الجوال
   ========================================================================== */
@media (max-width: 576px) {
    .msa-quiz-container { padding: 15px; border-radius: 8px; margin: 10px auto; }
    .msa-quiz-header { flex-direction: column; gap: 10px; margin-bottom: 15px; padding-bottom: 0; border-bottom: none; }
    .msa-quiz-header h2 { order: 1; text-align: center; width: 100%; justify-content: center; }
    .msa-header-stats { order: 2; display: flex; justify-content: space-around; width: 100%; background-color: #f8f9fa; padding: 8px; border-radius: 10px; border: 1px solid #e9ecef; }
    .msa-score-board, .msa-timer-display { margin: 0; padding: 4px 8px; font-size: 0.95em; }
    .msa-option-btn { font-size: 0.95em; padding: 10px; }
    .msa-btn { font-size: 1em; padding: 10px; }
}
