/* ==========================================================================
   MEDCORE Weekly Exam Portal — File 3: Master Exam Stylesheet (exam-style.css)
   Academic Identity: Navy (#162238) / Maroon (#7b1113) / Gold (#c5a059)
   Includes: Anti-Copy, Anti-Print, Blur Blackout Shield, Watermark & Responsive UI
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@500;600;700;800;900&family=Inter:wght@500;600;700;800;900&display=swap');

:root {
    --navy: #162238;
    --navy-dark: #0b1322;
    --navy-light: #1e3150;
    --maroon: #7b1113;
    --maroon-light: #9e1b1e;
    --gold: #c5a059;
    --gold-bright: #facc15;
    --gold-light: #e2c78c;
    --font-main: 'Inter', 'Cairo', system-ui, -apple-system, sans-serif;

    /* الوضع الليلي الأكاديمي (الافتراضي) */
    --bg: #0b1322;
    --bg-gradient: linear-gradient(160deg, #162238 0%, #0b1322 65%, #16111d 100%);
    --surface: #162238;
    --surface-elevated: #1e3150;
    --surface-soft: rgba(30, 49, 80, 0.6);
    --surface-glass: rgba(22, 34, 56, 0.95);
    --text: #f8fafc;
    --text-muted: #cbd5e1;
    --primary: #3b82f6;
    --primary-light: rgba(59, 130, 246, 0.15);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.18);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.18);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.18);
    --border: #2d4263;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

body.light-theme {
    --bg: #e2e8f0;
    --bg-gradient: linear-gradient(145deg, #e2e8f0 0%, #f1f5f9 100%);
    --surface: #ffffff;
    --surface-elevated: #f8fafc;
    --surface-soft: #eef2f6;
    --surface-glass: rgba(255, 255, 255, 0.96);
    --text: #0f172a;
    --text-muted: #475569;
    --primary: #162238;
    --primary-light: #eff6ff;
    --success: #15803d;
    --success-light: #dcfce7;
    --error: #b91c1c;
    --error-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --border: #cbd5e1;
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    --shadow-sm: 0 3px 10px rgba(15, 23, 42, 0.05);
}

/* ==========================================================================
   1. القواعد العامة ومنع النسخ والطباعة
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    font-family: var(--font-main);
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0 0 80px 0;
    background: var(--bg);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    line-height: 1.65;
    overflow-x: hidden;
}

/* منع تحديد النصوص أو سحب الصور داخل منطقة الامتحان النشط */
.exam-protected-zone {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-touch-callout: none !important;
}

.exam-protected-zone img {
    pointer-events: none !important;
    -webkit-user-drag: none !important;
}

/* حجب كامل لمحتوى الصفحة عند محاولة الطباعة أو حفظ الصفحة كـ PDF */
@media print {
    body * {
        display: none !important;
        visibility: hidden !important;
    }
    body::after {
        content: "🚫 غير مسموح بطباعة أو تصوير اختبارات منصة MEDCORE الرسمية.";
        display: block !important;
        visibility: visible !important;
        font-size: 2rem;
        font-weight: 900;
        text-align: center;
        padding: 100px 20px;
        color: #b91c1c;
    }
}

/* ==========================================================================
   2. الشريط العلوي للامتحان (المؤقت، حالة الشبكة، عداد الإنذارات)
   ========================================================================== */
.exam-navbar {
    position: sticky;
    top: 0;
    z-index: 1200;
    background: var(--surface-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 4px solid var(--navy);
    border-bottom: 2.5px solid var(--maroon);
    padding: 8px 14px;
    box-shadow: var(--shadow-sm);
}

.exam-navbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--gold);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

body.light-theme .logo-text {
    color: var(--navy);
}

.status-pill {
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.status-pill.offline {
    background: var(--error-light);
    color: var(--error);
    border-color: var(--error);
    animation: pulseAlert 1s infinite;
}

.status-pill.warning-pill {
    background: var(--warning-light);
    color: var(--warning);
    border-color: var(--warning);
}

@keyframes pulseAlert {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.75; }
}

.exam-timer-box {
    background: linear-gradient(135deg, var(--maroon), #52090b);
    color: #ffffff;
    border: 1.5px solid var(--gold);
    padding: 6px 16px;
    border-radius: 999px;
    font-weight: 900;
    font-family: monospace;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 3px 12px rgba(123, 17, 19, 0.45);
    direction: ltr;
}

.exam-timer-box.danger {
    background: linear-gradient(135deg, #dc2626, #7f1d1d);
    animation: pulseAlert 0.8s infinite;
}

/* ==========================================================================
   3. شاشة الإظلام والطمس الفوري لمنع الغش (Blackout & Blur Shield)
   ========================================================================== */
.blackout-shield {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(11, 19, 34, 0.96);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: #ffffff;
}

.blackout-shield.active {
    display: flex;
}

.blackout-card {
    background: #162238;
    border: 2px solid var(--error);
    border-top: 6px solid var(--gold);
    border-radius: var(--radius-lg);
    padding: 28px 22px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
}

/* طمس محتوى الأسئلة فوراً عند تفعيل الدرع */
body.shield-triggered #exam-active-view {
    filter: blur(25px) !important;
    pointer-events: none !important;
}

/* ==========================================================================
   4. العلامة المائية الديناميكية المانعة للتسريب (Dynamic Watermark)
   ========================================================================== */
.question-card-wrapper {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-top: 5px solid var(--gold);
    border-radius: var(--radius-lg);
    padding: 22px 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.watermark-layer {
    position: absolute;
    inset: -40px;
    pointer-events: none !important;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-content: space-around;
    justify-content: space-around;
    transform: rotate(-22deg);
    opacity: 0.11;
    overflow: hidden;
    user-select: none;
}

body.light-theme .watermark-layer {
    opacity: 0.085;
}

.watermark-item {
    font-size: 0.88rem;
    font-weight: 900;
    color: var(--gold-bright);
    white-space: nowrap;
    padding: 18px 26px;
    font-family: monospace;
    direction: ltr;
}

body.light-theme .watermark-item {
    color: var(--navy);
}

/* ==========================================================================
   5. الحاويات، البطاقات، والأزرار القياسية
   ========================================================================== */
.container {
    width: 100%;
    max-width: 820px;
    margin: 18px auto;
    padding: 0 12px;
}

.admin-container {
    width: 100%;
    max-width: 1180px;
    margin: 18px auto;
    padding: 0 14px;
}

.portal-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-top: 5px solid var(--gold);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.info-box {
    background: var(--surface-elevated);
    border: 1.5px solid var(--border);
    border-inline-start: 5px solid var(--gold);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 14px;
}

.info-box.danger-box {
    border-inline-start-color: var(--error);
    background: var(--error-light);
}

.info-box.success-box {
    border-inline-start-color: var(--success);
    background: var(--success-light);
}

.btn-main {
    border: none;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 0.94rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.18s ease;
    text-decoration: none;
    color: #ffffff;
}

.btn-main:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.btn-main:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-gold { background: linear-gradient(135deg, var(--gold), #9e7a32); color: #0b1322; font-weight: 900; }
.btn-maroon { background: var(--maroon); border: 1px solid var(--gold); }
.btn-navy { background: var(--navy); border: 1px solid var(--gold); }
.btn-green { background: #15803d; }
.btn-red { background: #dc2626; }
.btn-outline {
    background: var(--surface-elevated);
    color: var(--text);
    border: 1.5px solid var(--border);
}

.input-field {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text);
    font-size: 0.96rem;
    font-weight: 700;
    transition: border-color 0.18s;
}

.input-field:focus {
    outline: none;
    border-color: var(--gold);
}

/* ==========================================================================
   6. شريط أرقام الأسئلة، نص السؤال، صور الـ OSPE، والخيارات
   ========================================================================== */
.q-palette-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 4px 12px 4px;
    margin-bottom: 12px;
}

.q-nav-dot {
    min-width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text);
    font-weight: 900;
    font-size: 0.84rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: 0.15s;
}

.q-nav-dot.current {
    border-color: var(--gold);
    background: var(--maroon);
    color: #ffffff;
    transform: scale(1.06);
}

.q-nav-dot.answered {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.q-nav-dot:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.question-stem-box {
    position: relative;
    z-index: 6;
    background: var(--surface-elevated);
    color: var(--text);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    border-left: 5px solid var(--maroon);
    font-weight: 800;
    font-size: 1.08rem;
    line-height: 1.65;
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
    margin: 10px 0 16px 0;
    word-break: break-word;
}

.ospe-image-frame {
    position: relative;
    z-index: 6;
    text-align: center;
    margin: 10px 0 16px 0;
    background: #050911;
    border: 2px solid var(--gold);
    border-radius: var(--radius-md);
    padding: 8px;
    overflow: hidden;
}

.ospe-image-frame img {
    max-width: 100%;
    max-height: 390px;
    border-radius: 8px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* خيارات الـ MCQ مع زر الاستبعاد */
.mcq-option-row {
    position: relative;
    z-index: 6;
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 9px;
    direction: ltr;
}

.mcq-opt-btn {
    flex: 1;
    background: var(--surface-elevated);
    color: var(--text);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    font-weight: 700;
    font-size: 0.96rem;
    text-align: left;
    direction: ltr;
    transition: all 0.15s ease;
}

.mcq-opt-btn:hover {
    border-color: var(--gold);
}

.mcq-opt-btn.selected {
    border: 2px solid var(--gold);
    background: rgba(197, 160, 89, 0.24);
    font-weight: 900;
}

.mcq-opt-btn .opt-letter {
    background: var(--navy);
    color: var(--gold-light);
    border: 1px solid var(--gold);
    min-width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.86rem;
    font-weight: 900;
    flex-shrink: 0;
}

.mcq-opt-btn.selected .opt-letter {
    background: var(--gold);
    color: #0b1322;
}

.mcq-opt-btn.struck {
    text-decoration: line-through;
    opacity: 0.38;
}

.strike-btn {
    background: var(--surface-elevated);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    width: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* صندوق إجابة الـ MEQ والـ OSPE الكتابي (English Only) */
.written-answer-wrap {
    position: relative;
    z-index: 6;
    direction: ltr;
    text-align: left;
}

.written-textarea {
    width: 100%;
    min-height: 120px;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    direction: ltr;
    text-align: left;
    line-height: 1.6;
    resize: vertical;
}

.written-textarea:focus {
    outline: none;
    border-color: var(--gold);
}

.english-only-alert {
    display: none;
    margin-top: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--error-light);
    color: var(--error);
    border: 1px solid var(--error);
    font-size: 0.84rem;
    font-weight: 800;
    text-align: center;
}

/* ==========================================================================
   7. بطاقة المراجعة بعد انتهاء الامتحان (صور السلايدات، PDF، والتماس الـ AI)
   ========================================================================== */
.review-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-left: 6px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.review-card.full-mark { border-left-color: var(--success); }
.review-card.partial-mark { border-left-color: var(--warning); }
.review-card.zero-mark { border-left-color: var(--error); }

.slide-source-box {
    margin-top: 12px;
    padding: 12px;
    background: var(--surface-elevated);
    border: 1px dashed var(--gold);
    border-radius: var(--radius-sm);
}

.slide-preview-img {
    max-width: 100%;
    max-height: 340px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    margin-top: 8px;
    cursor: zoom-in;
    display: block;
}

/* الجداول وشاشات الموبايل */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    font-size: 0.86rem;
}

th {
    background: var(--navy);
    color: var(--gold-light);
    font-weight: 900;
}

.toast-msg {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100000;
    background: var(--navy);
    color: #ffffff;
    border: 2px solid var(--gold);
    padding: 10px 20px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
}

@media (max-width: 640px) {
    .portal-card, .question-card-wrapper {
        padding: 15px 12px;
        border-radius: 14px;
    }
    .question-stem-box {
        font-size: 0.98rem;
        padding: 12px;
    }
    .mcq-opt-btn {
        font-size: 0.9rem;
        padding: 10px 11px;
    }
    .exam-timer-box {
        font-size: 0.92rem;
        padding: 5px 12px;
    }
}