/* ==========================================================================
   Al-Khwarizmi — واجهة الاختبارات داخل WebView (RTL)
   تصميم مستقل، لا يعتمد على ثيم ووردبريس.
   ========================================================================== */

.wp-site-blocks , main, .entry-content{
    margin: 0 !important;
    padding: 0 !important;
}
footer, header, .wp-block-post-title
{
    display: none !important;
}

/* فرض الوضع الفاتح دائماً ومنع WebView/المتصفح من عكس الألوان في الوضع الليلي */
:root { color-scheme: light only; }

html, body
{
    background-color: #EBEFF5 !important;
    color: #1F2937;
    font-family: 'Cairo', system-ui, sans-serif;
    direction: rtl;
    forced-color-adjust: none;
}

#kh-exam-root, #kh-exam-root * { box-sizing: border-box; }

#kh-exam-root {
    /* هوية التطبيق البصرية */
    --kh-primary: #055E98;         /* الأزرق الأساسي */
    --kh-primary-dark: #03436E;
    --kh-primary-light: #4B92E2;
    --kh-accent: #FFA500;          /* البرتقالي (أزرار التطبيق) */
    --kh-accent-dark: #E08E00;
    --kh-success: #16A34A;
    --kh-danger: #F44336;
    --kh-warning: #FFB74D;
    --kh-bg: #EBEFF5;              /* خلفية شاشات التطبيق */
    --kh-surface: #FFFFFF;
    --kh-border: #E3E8EF;
    --kh-text: #1F2937;
    --kh-text-muted: #6B7280;
    --kh-radius: 18px;
    --kh-shadow: 0 6px 20px rgba(5,94,152,.08);
    --kh-shadow-lg: 0 10px 30px rgba(5,94,152,.14);

    direction: rtl;
    font-family: 'Cairo', system-ui, "Segoe UI", Tahoma, sans-serif;
    color: var(--kh-text);
    background: var(--kh-bg);
    min-height: 100vh;
    margin: 0;
    /* 60px من الأعلى لإبعاد المحتوى عن شريط حالة الهاتف داخل الـ WebView */
    padding: 60px 16px 32px;
    max-width: 820px;
    margin-inline: auto;
}

/* ---- حالات عامة ---- */
.kh-exam-center { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.kh-spinner {
    width: 42px; height: 42px; border-radius: 50%;
    border: 4px solid var(--kh-border); border-top-color: var(--kh-primary);
    animation: kh-spin .8s linear infinite;
}
@keyframes kh-spin { to { transform: rotate(360deg); } }

.kh-msg { text-align: center; color: var(--kh-text-muted); padding: 40px 16px; font-size: 16px; }
.kh-msg--error { color: var(--kh-danger); }

/* ---- ترويسة الشاشة ---- */
.kh-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 18px; padding: 16px 18px;
    background: linear-gradient(135deg, var(--kh-primary), var(--kh-primary-light));
    border-radius: var(--kh-radius);
    box-shadow: var(--kh-shadow-lg);
    color: #fff;
}
.kh-header h1 { font-size: 19px; margin: 0; font-weight: 800; color: #fff; }
.kh-back {
    background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
    border-radius: 12px; width: 40px; height: 40px; font-size: 20px;
    cursor: pointer; color: #fff; flex: 0 0 auto;
    transition: background .15s;
}
.kh-back:hover { background: rgba(255,255,255,.3); }

/* ---- بطاقات قائمة الاختبارات ---- */
.kh-card {
    background: var(--kh-surface); border: 1px solid var(--kh-border);
    border-radius: var(--kh-radius); box-shadow: var(--kh-shadow);
    padding: 16px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 12px;
    position: relative; overflow: hidden;
    transition: transform .15s, box-shadow .15s;
}
/* شريط جانبي ملوّن يعطي البطاقة طابع التطبيق */
.kh-card::before {
    content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
    width: 5px; background: linear-gradient(180deg, var(--kh-primary), var(--kh-primary-light));
}
.kh-card:hover { transform: translateY(-2px); box-shadow: var(--kh-shadow-lg); }
.kh-card__body { flex: 1 1 auto; min-width: 0; }
.kh-card__title { font-weight: 700; font-size: 16px; margin: 0 0 6px; }
.kh-card__meta { font-size: 13px; color: var(--kh-text-muted); display: flex; gap: 14px; flex-wrap: wrap; }
.kh-card__meta span { display: inline-flex; align-items: center; gap: 4px; }

.kh-badge {
    font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
    white-space: nowrap; flex: 0 0 auto;
}
.kh-badge--pending  { background: #E3F0FA; color: var(--kh-primary); }
.kh-badge--completed{ background: #DCFCE7; color: #166534; }
.kh-badge--expired  { background: #F1F3F7; color: var(--kh-text-muted); }
.kh-badge--type     { background: #FFF4E0; color: #B26A00; }

.kh-score { font-weight: 800; color: var(--kh-primary); }

/* ---- الأزرار ---- */
.kh-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: linear-gradient(135deg, var(--kh-accent), var(--kh-accent-dark));
    color: #fff; border: 0; cursor: pointer;
    font-family: inherit; font-weight: 700; font-size: 16px;
    padding: 14px 20px; border-radius: 14px; width: 100%;
    box-shadow: 0 4px 14px rgba(255,165,0,.32);
    transition: transform .12s, box-shadow .15s, filter .15s;
}
.kh-btn:hover  { filter: brightness(1.05); box-shadow: 0 6px 18px rgba(255,165,0,.42); }
.kh-btn:active { transform: translateY(1px); }
.kh-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; filter: none; }
.kh-btn--ghost {
    background: var(--kh-surface); color: var(--kh-primary);
    border: 1.5px solid var(--kh-primary); box-shadow: none;
}
.kh-btn--ghost:hover { background: #F2F8FC; filter: none; box-shadow: none; }
.kh-btn--start {
    width: auto; padding: 10px 20px; font-size: 14px;
    background: linear-gradient(135deg, var(--kh-primary), var(--kh-primary-light));
    box-shadow: 0 4px 14px rgba(5,94,152,.3);
}
.kh-btn--start:hover { box-shadow: 0 6px 18px rgba(5,94,152,.4); }

/* ---- المؤقّت ---- */
.kh-timer {
    position: sticky; top: 8px; z-index: 20;
    background: var(--kh-surface); border: 1.5px solid var(--kh-border);
    border-radius: 14px; box-shadow: var(--kh-shadow);
    padding: 12px 18px; display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; font-weight: 800; font-size: 19px;
    font-variant-numeric: tabular-nums; /* يمنع اهتزاز الأرقام */
    transition: border-color .25s, color .25s;
}
.kh-timer__label { font-size: 13px; color: var(--kh-text-muted); font-weight: 600; }
.kh-timer.is-warning { color: #B26A00; border-color: var(--kh-warning); background: #FFFBF2; }
.kh-timer.is-danger  {
    color: var(--kh-danger); border-color: var(--kh-danger); background: #FFF5F5;
    animation: kh-pulse 1.4s ease-in-out infinite;
}
@keyframes kh-pulse {
    0%, 100% { box-shadow: var(--kh-shadow); }
    50%      { box-shadow: 0 0 0 4px rgba(244,67,54,.14); }
}

/* ---- أسئلة الاختيار من متعدد ---- */
.kh-question {
    background: var(--kh-surface); border: 1px solid var(--kh-border);
    border-radius: var(--kh-radius); box-shadow: var(--kh-shadow);
    padding: 16px; margin-bottom: 14px;
}
.kh-question__title { font-weight: 700; margin: 0 0 14px; font-size: 16px; line-height: 1.7; }
.kh-question__index {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 9px; margin-inline-end: 6px;
    background: linear-gradient(135deg, var(--kh-primary), var(--kh-primary-light));
    color: #fff; font-size: 14px; font-weight: 800;
}

.kh-option {
    display: flex; align-items: center; gap: 12px;
    border: 1.5px solid var(--kh-border); border-radius: 12px;
    padding: 13px 15px; margin-bottom: 10px; cursor: pointer;
    background: #FBFCFE;
    transition: border-color .15s, background .15s, transform .12s;
}
.kh-option:last-child { margin-bottom: 0; }
.kh-option:hover { border-color: var(--kh-primary-light); }
.kh-option.is-selected {
    border-color: var(--kh-primary); background: #EAF3FA;
    box-shadow: inset 0 0 0 1px var(--kh-primary);
}
.kh-option:active { transform: scale(.995); }
.kh-option input { width: 20px; height: 20px; accent-color: var(--kh-primary); flex: 0 0 auto; }
.kh-option span { flex: 1 1 auto; line-height: 1.6; }

/* ---- اختبار الصورة (ai) ---- */
.kh-ai-question {
    background: var(--kh-surface); border: 1px solid var(--kh-border);
    border-radius: var(--kh-radius); box-shadow: var(--kh-shadow);
    padding: 16px; margin-bottom: 16px; font-size: 18px; line-height: 1.7;
}
.kh-ai-question img { max-width: 100%; height: auto; }
.kh-preview {
    max-width: 100%; border-radius: 12px; margin: 12px 0;
    border: 1px solid var(--kh-border); display: none;
}
.kh-preview.is-shown { display: block; }
.kh-file { display: none; }

/* ---- شاشة النتيجة ---- */
.kh-result {
    background: var(--kh-surface); border: 1px solid var(--kh-border);
    border-radius: var(--kh-radius); box-shadow: var(--kh-shadow);
    padding: 24px; text-align: center;
}
.kh-result__score {
    font-size: 52px; font-weight: 900; margin: 10px 0;
    line-height: 1.1; letter-spacing: -1px;
}
.kh-result.is-pass .kh-result__score {
    background: linear-gradient(135deg, var(--kh-success), #4ADE80);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.kh-result.is-fail .kh-result__score {
    background: linear-gradient(135deg, var(--kh-danger), #FF8A80);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.kh-result__row { text-align: start; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--kh-border); }
.kh-result__row h4 { margin: 0 0 4px; font-size: 14px; color: var(--kh-text-muted); }
.kh-result__row p  { margin: 0; line-height: 1.6; }

.kh-toast {
    position: fixed; bottom: 20px; inset-inline: 20px; z-index: 999;
    background: #111827; color: #fff; padding: 14px 18px; border-radius: 12px;
    text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.25);
    opacity: 0; transform: translateY(12px); transition: .2s; pointer-events: none;
}
.kh-toast.is-shown { opacity: 1; transform: translateY(0); }

/* ---- حركة دخول ناعمة للبطاقات ---- */
.kh-card, .kh-question, .kh-result, .kh-ai-question {
    animation: kh-rise .3s ease both;
}
@keyframes kh-rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .kh-card, .kh-question, .kh-result, .kh-ai-question,
    .kh-timer.is-danger { animation: none; }
}

/* الصفحة فاتحة دائماً — لا تتبع وضع الجهاز الليلي (مطابقة لثيم التطبيق) */
