/* ============================================================
   app.css — رصد الحرب
   Mobile-First · RTL · iOS Safe Area · Dark Mode
   ============================================================ */

/* ============================================================
   1. متغيرات الألوان والثوابت
   ============================================================ */
:root {
    /* الألوان الرئيسية */
    --bg:           #F2F2F7;
    --bg-card:      #FFFFFF;
    --bg-card2:     #F9F9FB;
    --fg:           #1C1C1E;
    --fg2:          #6C6C70;
    --fg3:          #AEAEB2;
    --accent:       #C62828;
    --accent-light: rgba(198, 40, 40, 0.08);
    --border:       rgba(0, 0, 0, 0.07);
    --radius:       14px;
    --shadow:       0 1px 4px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:      #0C0C0E;
        --bg-card: #1C1C1E;
        --bg-card2:#2C2C2E;
        --fg:      #F5F5F7;
        --fg2:     #8E8E93;
        --fg3:     #48484A;
        --border:  rgba(255, 255, 255, 0.07);
        --shadow:  0 1px 4px rgba(0, 0, 0, 0.3);
    }
}


/* ============================================================
   2. Reset شامل
   ============================================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* إزالة تأثير الضغط الأزرق على الهواتف */
    -webkit-tap-highlight-color: transparent;
}


/* ============================================================
   3. هيكل الشاشة — الحل النهائي المضمون
   ============================================================
   النهج: header و bottom-nav و appScroll كلهم position:fixed
   بأبعاد تُحسب بـ JS ديناميكياً.
   
   هذا يضمن:
   - لا مساحة فارغة أسفل الـ nav أبداً
   - لا تأثر بشريط عنوان المتصفح
   - يعمل على iOS/Android/PWA بنفس الطريقة
   ============================================================ */

html {
    width: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    scroll-behavior: smooth;
    overflow: hidden;
    touch-action: pan-x pan-y;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    overflow: hidden;
    background: var(--bg);
    font-family: 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    touch-action: pan-x pan-y;
}

@viewport {
  orientation: portrait;
}

@media (prefers-color-scheme: dark) {
    html, body { background: #0C0C0E; }
}

/* ============================================================
   4. الهيدر — مثبّت في الأعلى
   ============================================================ */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top, 0px);
}


/* ============================================================
   5. منطقة المحتوى — تملأ الفراغ بين الهيدر والـ nav بالضبط
   ============================================================ */
#appScroll {
    position: fixed;
    left: 0;
    right: 0;
    /* top و bottom يُعيَّنان بـ JS عبر --header-h و --nav-h */
    top:    var(--header-h, 116px);
    bottom: var(--nav-h,    80px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
    background: var(--bg);
}


/* ============================================================
   6. شريط التنقل — مثبّت في الأسفل (موبايل)
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10001; /* فوق lockOverlay */
    width: 100%;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    will-change: transform;
}

/* الشعار مخفي على الموبايل - يظهر فقط على سطح المكتب */
.nav-brand { display: none; }

/* الحاوية الداخلية */
.nav-inner {
    display: flex;
    width: 100%;
    align-items: stretch;
}

.nav-btn {
    flex: 1;
    padding: 10px 4px;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--fg3);
    font-size: 10px;
    font-family: inherit;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn svg {
    width: 24px;
    height: 24px;
}

.nav-btn.active {
    color: var(--accent);
}

/* #mainContent على الموبايل: غير موجود كـ flex container */
#mainContent {
    display: contents; /* يتجاهل الـ div ويعرض الأبناء مباشرة */
}

/* ============================================================
   7. شارة الأخبار الجديدة (عائمة في الوسط)
   ============================================================ */
.new-badge {
    /* عائمة فوق المحتوى */
    position: fixed;
    top: 120px;   /* يُحدَّث بالجافاسكريبت بعد حساب ارتفاع الهيدر */
    inset-inline: 0;  /* يعمل مع RTL وLTR تلقائياً */
    margin: 0 auto;
    width: fit-content;
    z-index: 150;
    pointer-events: auto;

    /* التصميم */
    background: var(--accent);
    color: #fff;
    padding: 10px 22px;
    border-radius: 24px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;

    box-shadow:
        0 6px 24px rgba(198, 40, 40, 0.5),
        0 2px 8px  rgba(0, 0, 0, 0.2);

    animation: slideDown 0.3s ease-out;
}

.new-badge.pulse {
    animation: slideDown 0.3s ease-out, badgePulse 1.4s ease-in-out infinite;
}


/* ============================================================
   8. الحركات (Animations)
   ============================================================ */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-18px); }
    to   { opacity: 1; transform: translateY(0);     }
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 4px 18px rgba(198, 40, 40, 0.45); transform: scale(1);    }
    50%       { box-shadow: 0 4px 28px rgba(198, 40, 40, 0.8);  transform: scale(1.06); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes urgencyPulse {
    0%, 100% { box-shadow: 0 0 0 0   rgba(183, 28, 28, 0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(183, 28, 28, 0);   }
}

@keyframes missileFly {
    0%   { transform: translateX(0)   translateY(0)   rotate(-45deg); }
    25%  { transform: translateX(-3px) translateY(-4px) rotate(-45deg); }
    50%  { transform: translateX(3px)  translateY(-2px) rotate(-45deg); }
    75%  { transform: translateX(-2px) translateY(-5px) rotate(-45deg); }
    100% { transform: translateX(0)   translateY(0)   rotate(-45deg); }
}

@keyframes missilePulse {
    0%, 100% { transform: scale(1);   opacity: 0.6;  }
    50%       { transform: scale(1.5); opacity: 0.15; }
}

.spinning { animation: spin 0.8s linear infinite !important; }


/* ============================================================
   9. أيقونة الصاروخ
   ============================================================ */
.missile-icon {
    font-size: 22px;
    display: inline-block;
    animation: missileFly 2.4s ease-in-out infinite;
    transform-origin: center;
}

.missile-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.missile-wrap::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(198, 40, 40, 0.25) 0%, transparent 70%);
    animation: missilePulse 2.4s ease-in-out infinite;
}

.site-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #C62828, #E53935);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}


/* ============================================================
   10. بطاقة الخبر
   ============================================================ */
.news-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}

.news-card:active {
    transform: scale(0.985);
    box-shadow: none;
}

.news-card.urgent-breaking {
    border-right: 3px solid #B71C1C;
}


/* ============================================================
   11. الوسائط (صور وفيديو)
   ============================================================ */
.media-wrap {
    position: relative;
    background: #111;
    width: 100%;
}

.media-img {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
    background: #111;
}

.modal-img {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    background: #111;
    display: block;
    border-radius: 10px;
}

.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
}

.play-icon-wrap {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.video-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.detail-body {
    line-height: 1.95;
    font-size: 15px;
    white-space: pre-wrap;
    word-break: break-word;
}


/* ============================================================
   12. الوسوم (Tags)
   ============================================================ */
.tag {
    font-size: 9px;
    padding: 2px 7px;
    border-radius: 5px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.tag-telegram  { background: #1976D215; color: #1565C0; }
.tag-rss       { background: #2E7D3215; color: #1B5E20; }
.tag-translated{ background: #6A1B9A15; color: #4A148C; }
.tag-video     { background: #BF360C15; color: #BF360C; }
.tag-image     { background: #00695C15; color: #00695C; }
.tag-duplicate { background: #78909C15; color: #546E7A; }


/* ============================================================
   13. شارات الخطورة
   ============================================================ */
.urgency-badge {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 5px;
    font-weight: 800;
    white-space: nowrap;
    letter-spacing: 0.4px;
}

.urgency-جداً { background: #B71C1C; color: #fff; animation: urgencyPulse 1.5s ease-in-out infinite; }
.urgency-عاجل { background: #E65100; color: #fff; }
.urgency-عادي { background: #37474F20; color: #546E7A; }


/* ============================================================
   14. تصنيفات الأخبار
   ============================================================ */
.cat {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 5px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}

.cat-عسكري    { background: #C62828; }
.cat-سياسي    { background: #1565C0; }
.cat-إنساني   { background: #2E7D32; }
.cat-اقتصادي  { background: #E65100; }
.cat-دبلوماسي { background: #6A1B9A; }
.cat-عام      { background: #455A64; }


/* ============================================================
   15. شريط الفلترة
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 12px 10px;
    scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar { display: none; }

.fchip {
    flex-shrink: 0;
    font-size: 11px;
    padding: 5px 13px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--fg2);
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}

.fchip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}


/* ============================================================
   16. شريط البحث
   ============================================================ */
.search-bar { display: none; padding: 0 12px 10px; }
.search-bar.show { display: block; }

.search-input {
    width: 100%;
    padding: 9px 14px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    color: var(--fg);
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--accent); }


/* ============================================================
   17. الصفحات
   ============================================================ */
.page { display: none; }
.page.active { display: block; }


/* ============================================================
   18. المودال (نافذة التفاصيل)
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: none;
    align-items: flex-end;
}

.modal.show { display: flex; }

.modal-inner {
    background: var(--bg-card);
    width: 100%;
    /* نخصم ارتفاع الـ nav والـ safe areas */
    max-height: calc(94% - var(--nav-h) - env(safe-area-inset-bottom, 0px));
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--fg3);
    border-radius: 2px;
    margin: 10px auto 0;
    opacity: 0.5;
}


/* ============================================================
   19. حقول الإدخال والأزرار
   ============================================================ */
.ifield {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    color: var(--fg);
    outline: none;
    transition: border-color 0.15s;
}

.ifield:focus { border-color: var(--accent); }

.btn-red {
    width: 100%;
    padding: 13px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-red:active { opacity: 0.85; }

.btn-outline {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-outline:active { background: var(--accent-light); }


/* ============================================================
   20. بطاقات الإعدادات
   ============================================================ */
.settings-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 16px;
}

.settings-card-header {
    padding: 14px 16px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.settings-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-row {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-child { border-bottom: none; }


/* ============================================================
   21. حالة الاتصال
   ============================================================ */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.status-ok  { background: rgba(46, 125, 50, 0.12); color: #2E7D32; }
.status-err { background: rgba(198, 40, 40, 0.12); color: #C62828; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-g { background: #4CAF50; box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2); }
.dot-r { background: #F44336; box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.2); }


/* ============================================================
   22. بطاقة المصدر
   ============================================================ */
.source-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.source-type-badge {
    font-size: 9px;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 700;
}

.st-rss { background: #2E7D3215; color: #1B5E20; }
.st-tg  { background: #1976D215; color: #1565C0; }


/* ============================================================
   23. ملخص الأخبار
   ============================================================ */
.summary-headline {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--fg);
    margin-bottom: 12px;
}

.summary-urgency {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
    letter-spacing: 0.3px;
}

.urg-هادئ  { background: #E8F5E9; color: #2E7D32; }
.urg-متوتر { background: #FFF3E0; color: #E65100; }
.urg-ساخن  { background: #FFEBEE; color: #C62828; }
.urg-متفجر { background: #B71C1C; color: #fff; animation: urgencyPulse 1.5s ease-in-out infinite; }

.summary-overview {
    font-size: 14px;
    line-height: 1.9;
    color: var(--fg2);
    background: var(--bg-card);
    padding: 14px 16px;
    margin-bottom: 14px;
    border-right: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.summary-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
}

.summary-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.summary-section-title { font-size: 13px; font-weight: 700; color: var(--fg); }

.summary-point {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.7;
    color: var(--fg2);
}

.summary-point:last-child { border-bottom: none; }

.summary-point::before {
    content: '•';
    color: var(--accent);
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

.summary-conclusion {
    background: var(--bg-card2);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--fg2);
    font-style: italic;
    margin-bottom: 10px;
}

.summary-actors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.summary-actor {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--fg2);
    border: 1px solid var(--border);
    font-weight: 500;
}

.summary-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 4px;
}

.summary-providers { font-size: 10px; color: var(--fg3); }


/* ============================================================
   24. أكورديون الإعدادات
   ============================================================ */
.acc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}

.acc-arrow {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.2s;
    color: var(--fg3);
}

.acc-header.open .acc-arrow { transform: rotate(180deg); }

.acc-body {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.28s ease;
}

.acc-body.open { max-height: 1200px; }

.acc-inner { padding: 0 16px 16px; }


/* ============================================================
   25. تنسيقات خاصة بالهواتف (Mobile-Specific)
   ============================================================ */

/* ============================================================
   25. تنسيقات خاصة بالهواتف (Mobile-Specific)
   ============================================================ */

/* --- هواتف صغيرة جداً: عرض أقل من 360px --- */
@media screen and (max-width: 359px) {
    .fchip { font-size: 10px; padding: 4px 10px; }
    .nav-btn { font-size: 9px; }
    .nav-btn svg { width: 22px; height: 22px; }
    .site-title { font-size: 17px; }
    .news-card p { font-size: 13px; }
}

/* --- هواتف عادية: 360px–480px --- */
@media screen and (min-width: 360px) and (max-width: 480px) {
    .filter-bar { padding: 6px 10px 8px; }
    .fchip { font-size: 11px; padding: 5px 12px; }
    .news-card .p-3 { padding: 10px; }
}

/* --- هواتف كبيرة وPhablet: 481px–768px --- */
@media screen and (min-width: 481px) and (max-width: 768px) {
    #newsFeed {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .site-title { font-size: 22px; }
}

/* ============================================================
   26. تخطيط سطح المكتب — شامل وكامل الشاشة
   ============================================================
   النهج: CSS Grid بدلاً من position:fixed
   • شريط جانبي على اليمين (RTL)
   • المحتوى الرئيسي يملأ باقي المساحة
   • الهيدر يلتصق بالأعلى داخل المحتوى
   ============================================================ */
@media screen and (min-width: 769px) {

    html, body {
        height: 100dvh;
        overflow: hidden;
        max-width: none;
        background: var(--bg);
    }

    /* التخطيط العام: الشريط الجانبي + المحتوى */
    body {
        display: flex;
        flex-direction: row;   /* اليمين→اليسار بسبب RTL */
        margin: 0;
    }

    /* ===== الشريط الجانبي ===== */
    .bottom-nav {
        position: relative;
        bottom: unset;
        left: unset;
        right: unset;
        width: 220px;
        min-width: 220px;
        height: 100dvh;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        border-top: none;
        border-left: 1px solid var(--border);
        padding-bottom: 0;
        z-index: auto;
        flex-shrink: 0;
        overflow-y: auto;
        background: var(--bg-card);
    }

    /* شعار التطبيق في رأس الشريط الجانبي */
    .nav-brand {
        display: flex !important;
        align-items: center;
        gap: 10px;
        padding: 22px 20px 18px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 6px;
        flex-shrink: 0;
    }

    .nav-brand-title {
        font-size: 17px;
        font-weight: 700;
        background: linear-gradient(135deg, #C62828, #E53935);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    /* أزرار التنقل في الشريط الجانبي */
    .nav-inner {
        flex-direction: column;
        width: 100%;
        gap: 2px;
        padding: 4px 12px;
    }

    .nav-btn {
        flex-direction: row;
        justify-content: flex-start;
        padding: 12px 14px;
        min-height: unset;
        gap: 12px;
        font-size: 13px;
        font-weight: 500;
        border-radius: 10px;
        width: 100%;
        text-align: right;
    }

    .nav-btn:hover {
        background: var(--bg);
        color: var(--fg);
    }

    .nav-btn.active {
        background: var(--accent-light);
        color: var(--accent);
        font-weight: 600;
    }

    .nav-btn svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    /* ===== الغلاف الرئيسي (هيدر + محتوى) ===== */
    #mainContent {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100dvh;
        overflow: hidden;
        min-width: 0;
    }

    /* الهيدر: لاصق في الأعلى داخل #mainContent */
    header {
        position: sticky;
        top: 0;
        left: unset;
        right: unset;
        width: 100%;
        transform: none;
        z-index: 10;
        flex-shrink: 0;
    }

    /* منطقة التمرير: تملأ الارتفاع المتبقي */
    #appScroll {
        position: relative;
        top: unset;
        bottom: unset;
        left: unset;
        right: unset;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
    }

    /* شارة الأخبار الجديدة */
    .new-badge {
        position: fixed;
        top: 80px;
    }

    /* شبكة أخبار على سطح المكتب */
    #newsFeed {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
        gap: 12px;
    }

    /* تمتد صفحات الإعدادات والمصادر لعرض أكبر */
    #settingsPage, #sourcesPage, #summaryPage, #analysisPage {
        max-width: 860px;
    }

    /* المودال يحترم الشريط الجانبي */
    .modal-inner {
        max-width: 680px;
        margin: 0 auto;
        border-radius: 20px 20px 0 0;
    }
}

/* --- الشاشات الطويلة جداً (tall phones مثل iPhone 14 Pro Max) --- */
@media screen and (max-width: 768px) and (min-height: 850px) {
    .nav-btn { min-height: 62px; }
    .filter-bar { padding: 10px 12px 12px; }
}

/* --- الوضع الأفقي على الهواتف --- */
@media screen and (orientation: landscape) and (max-height: 500px) {
    header { position: sticky; top: 0; z-index: 50; }
    .filter-bar { padding: 4px 12px 6px; }
    .fchip { padding: 3px 10px; font-size: 10px; }
    .nav-btn { min-height: 44px; padding: 6px 4px; }
    .nav-btn svg { width: 20px; height: 20px; }
    .nav-btn span { display: none; }
}

/* --- تعطيل الانيميشن لمن يفضل ذلك --- */
@media (prefers-reduced-motion: reduce) {
    .missile-icon,
    .missile-wrap::after,
    .urgency-جداً,
    .urg-متفجر,
    .new-badge,
    .new-badge.pulse {
        animation: none;
    }
    * { transition-duration: 0.01ms !important; }
}

/* ============================================================
   27. صفحة التحليلات الميدانية
   ============================================================ */
:root {
    --analysis-accent: #5C35C8;
    --analysis-light:  rgba(92, 53, 200, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root { --analysis-accent: #7C5CE8; }
}

/* تبويبات التحليل */
.analysis-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 12px;
    scrollbar-width: none;
}
.analysis-tabs::-webkit-scrollbar { display: none; }

.atab {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--fg2);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.atab.active {
    background: var(--analysis-accent);
    color: #fff;
    border-color: var(--analysis-accent);
}

/* محتوى التبويبات */
.analysis-tab-content { display: none; }
.analysis-tab-content.active { display: block; }

/* بطاقة التحليل */
.analysis-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    padding: 16px;
}

.analysis-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.analysis-card-icon { font-size: 20px; line-height: 1; }
.analysis-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fg);
    flex: 1;
}

.analysis-intensity {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
}
.intensity-calm     { background: #E8F5E9; color: #2E7D32; }
.intensity-tense    { background: #FFF3E0; color: #E65100; }
.intensity-hot      { background: #FFEBEE; color: #C62828; }
.intensity-explosive{ background: #B71C1C; color: #fff; }

.analysis-text {
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--fg2);
    margin-bottom: 10px;
}

.analysis-point {
    font-size: 13px;
    line-height: 1.75;
    color: var(--fg2);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.analysis-point:last-of-type { border-bottom: none; }

.analysis-sources-note {
    font-size: 11px;
    color: var(--fg3);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* سيناريوهات التوقعات */
.scenario-card {
    border-radius: 10px;
    padding: 13px 14px;
    margin-bottom: 10px;
    border-right: 3px solid;
}
.scenario-high   { border-color: #C62828; background: rgba(198,40,40,.04); }
.scenario-medium { border-color: #E65100; background: rgba(230,81,0,.04); }
.scenario-low    { border-color: #2E7D32; background: rgba(46,125,50,.04); }

.scenario-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.scenario-num {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--analysis-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.scenario-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--fg);
    flex: 1;
}
.scenario-prob {
    font-size: 11px;
    font-weight: 700;
    color: var(--analysis-accent);
    background: var(--analysis-light);
    padding: 2px 8px;
    border-radius: 10px;
}
.scenario-body {
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--fg2);
}
.scenario-indicators {
    font-size: 11.5px;
    color: var(--fg3);
    margin-top: 6px;
}

/* بطاقة الطرف الفاعل */
.actor-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    flex-wrap: nowrap;
}
.actor-flag { font-size: 24px; line-height: 1.2; flex-shrink: 0; }
.actor-name { font-size: 13px; font-weight: 700; color: var(--fg); white-space: normal; word-break: break-word; }
.actor-role { font-size: 11px; color: var(--fg3); margin-top: 2px; white-space: normal; word-break: break-word; }
.actor-stance {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    flex-shrink: 0;
    white-space: nowrap;
    align-self: flex-start;
    margin-right: 0;
    margin-left: auto;
}
.stance-hostile    { background: #FFEBEE; color: #C62828; }
.stance-aggressive { background: #FFF3E0; color: #E65100; }
.stance-neutral    { background: #ECEFF1; color: #546E7A; }
.stance-defensive  { background: #E8F5E9; color: #2E7D32; }
.stance-diplomatic { background: #E3F2FD; color: #1565C0; }

.actor-moves {
    font-size: 12px;
    color: var(--fg3);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    line-height: 1.6;
}

/* خلاصة استراتيجية */
.analysis-conclusion {
    background: var(--analysis-light);
    border-right: 3px solid var(--analysis-accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 14px 16px;
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--fg);
    font-style: italic;
    margin-bottom: 12px;
}

.analysis-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 2px;
}
.analysis-providers { font-size: 10px; color: var(--fg3); }

/* حالة التحميل */
.analysis-loading-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 36px 20px;
    text-align: center;
    margin-top: 12px;
}
.analysis-spinner-wrap {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--analysis-light);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
}

/* شريط التقدم */
.analysis-progress-bar {
    width: 100%;
    max-width: 260px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}
.analysis-progress-fill {
    height: 100%;
    background: var(--analysis-accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.4s ease;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}