/* ==========================================================================
   إعادة الضبط العامة والتنقل بين الثيمات (Original Reset & Transition)
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* === ضبط خلفية الصفحة الأساسية وإخفاء شريط التمرير === */
html {
    min-height: 100%;
    background-color: #020712;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    background-color: transparent;
    color: #ffffff;
}

/* === تثبيت خلفية الكانفاس وتفعيل معالجة الـ GPU الفائقة === */
#ps3-canvas {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: -1 !important;
    pointer-events: none;
    transform: translateZ(0);
    will-change: transform;
    transition: filter 0.5s ease;
}

.page-wrapper {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem 2.5rem;
}

/* ==========================================================================
   أنيميشن دخول وخروج المحتوى
   ========================================================================== */
.glass-card, 
.hero-card, 
.item-card, 
.info-card, 
.poll-card,
.main-layout {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    will-change: opacity, transform;
}

body.page-loaded .glass-card,
body.page-loaded .hero-card,
body.page-loaded .item-card,
body.page-loaded .info-card,
body.page-loaded .poll-card,
body.page-loaded .main-layout {
    opacity: 1;
    transform: translateY(0);
}

body.page-exit .glass-card,
body.page-exit .main-layout {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.15s ease-in, transform 0.15s ease-in;
}

/* === المربعات والبطاقات الزجاجية (Dark Mode) === */
.glass-card {
    background: linear-gradient(135deg, rgba(14, 38, 78, 0.88), rgba(6, 20, 46, 0.94));
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.15);
    padding: 1.8rem;
}

/* ==========================================================================
   وضع النهار (Light Theme)
   ========================================================================== */
html.light-theme {
    background-color: #e6f2fa;
}

html.light-theme body {
    background-color: transparent;
    color: #123249;
}

html.light-theme .glass-card {
    background: rgba(224, 240, 250, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(160, 200, 225, 0.85);
    box-shadow: 0 10px 25px rgba(20, 60, 95, 0.08);
    color: #123249;
}

/* ==========================================================================
   الهيدر والقائمة العلوية (Header & Navigation)
   ========================================================================== */
.header-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(14, 38, 78, 0.92), rgba(6, 20, 46, 0.96));
    padding: 10px 24px;
    border-radius: 50px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

html.light-theme .header-brand {
    background: rgba(224, 240, 250, 0.95);
    border-color: rgba(160, 200, 225, 0.85);
    box-shadow: 0 8px 20px rgba(20, 60, 95, 0.06);
}

.brand-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-container {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #1e5631, #0a2f16, #020b05);
    border: 2px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.custom-logo {
    width: 130%;
    height: 130%;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.brand-subtitle {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
}

.desktop-nav {
    display: flex;
    list-style: none;
    gap: 20px;
}

.desktop-nav a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.3s;
}

.desktop-nav a.active, .desktop-nav a:hover {
    color: #81d4fa;
    font-weight: 700;
}

html.light-theme .brand-title,
html.light-theme .desktop-nav a,
html.light-theme .section-header h2,
html.light-theme .item-card h3,
html.light-theme .drawer-links a {
    color: #0f2d47;
    font-weight: 700;
}

html.light-theme .desktop-nav a.active,
html.light-theme .desktop-nav a:hover {
    color: #0284c7;
}

html.light-theme .brand-subtitle,
html.light-theme .card-date,
html.light-theme .footer-text,
html.light-theme .hero-card p,
html.light-theme .item-card p {
    color: #3b5b74;
    font-weight: 500;
}

html.light-theme .hero-card h1,
html.light-theme .poll-card h3,
html.light-theme .info-card h3 {
    color: #0369a1;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

html.light-theme .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(2, 132, 199, 0.3);
    color: #0c4a6e;
}

.theme-toggle-btn:hover { transform: scale(1.1); }

.lang-switcher {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

html.light-theme .lang-switcher {
    background: rgba(255, 255, 255, 0.45);
    border-color: rgba(2, 132, 199, 0.25);
}

.lang-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 15px;
    transition: all 0.3s;
}

html.light-theme .lang-btn { color: rgba(15, 45, 71, 0.75); }

.lang-btn.active {
    background: #0056b3;
    color: #ffffff !important;
    box-shadow: 0 0 10px rgba(0, 86, 179, 0.5);
}

.menu-toggle-btn, .drawer-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ==========================================================================
   القائمة الجانبية للشاشات الصغيرة (Mobile Drawer)
   ========================================================================== */
.mobile-drawer {
    position: fixed;
    top: 0;
    right: -280px;
    width: 260px;
    height: 100%;
    background: rgba(4, 19, 45, 0.97);
    backdrop-filter: blur(20px);
    z-index: 1000;
    padding: 2rem 1.5rem;
    transition: right 0.3s ease;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

[dir="ltr"] .mobile-drawer {
    right: auto;
    left: -280px;
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    transition: left 0.3s ease;
}

.mobile-drawer.open { right: 0; }
[dir="ltr"] .mobile-drawer.open { left: 0; }

.drawer-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 999;
    display: none;
}
.drawer-overlay.active { display: block; }

.drawer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.drawer-links a { color: white; text-decoration: none; font-size: 1.1rem; }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.drawer-header h3 {
    font-size: 1.1rem;
    color: #ffffff;
}

.drawer-close-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
}

html.light-theme .drawer-header {
    border-bottom-color: rgba(2, 132, 199, 0.2);
}

html.light-theme .drawer-header h3 {
    color: #0f2d47;
}

html.light-theme .drawer-close-btn {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(2, 132, 199, 0.3);
    color: #0c4a6e;
}

/* ==========================================================================
   تخطيط المحتوى الرئيسي (Layout Grid)
   ========================================================================== */
.main-layout {
    display: grid;
    grid-template-columns: 2.8fr 1fr;
    gap: 1.8rem;
    margin: 2rem 0;
}

.main-layout.main-single {
    grid-template-columns: 1fr;
    max-width: 1100px;
    margin: 2rem auto;
    width: 100%;
}

.primary-content, .sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

/* ==========================================================================
   قسم الـ Hero والبطاقات (Hero & Cards Grid)
   ========================================================================== */
.hero-card h1 { color: #81d4fa; margin-bottom: 0.8rem; font-size: 1.9rem; }
.hero-card p { line-height: 1.8; color: rgba(255, 255, 255, 0.9); }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    background: rgba(0, 160, 255, 0.15);
    border: 1px solid rgba(100, 200, 255, 0.4);
    border-radius: 20px;
    font-size: 0.82rem;
    color: #81d4fa;
    margin-bottom: 1rem;
}

.status-dot {
    width: 8px; height: 8px;
    background-color: #29b6f6;
    border-radius: 50%;
    box-shadow: 0 0 10px #29b6f6;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 { font-size: 1.3rem; color: #ffffff; }

.more-link {
    color: #29b6f6;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
}

html.light-theme .more-link { color: #0284c7; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.2rem;
}

.item-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.item-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.4);
}

.card-tag {
    display: inline-block;
    align-self: flex-start;
    padding: 4px 10px;
    background: rgba(0, 122, 255, 0.25);
    border: 1px solid rgba(0, 122, 255, 0.5);
    border-radius: 12px;
    font-size: 0.75rem;
    color: #90caf9;
    margin-bottom: 0.8rem;
}

.item-card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.6rem;
    line-height: 1.4;
}

.item-card p {
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.85;
    margin-bottom: 1rem;
}

.card-footer-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.card-date {
    font-size: 0.8rem;
    opacity: 0.7;
}

.card-btn {
    display: inline-block;
    padding: 6px 14px;
    background: #0284c7;
    color: #ffffff;
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    transition: background 0.2s;
}

.card-btn:hover {
    background: #0369a1;
}

/* ==========================================================================
   الاستطلاع والقائمة الجانبية (Poll & Sidebar)
   ========================================================================== */
.poll-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.poll-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.vote-btn {
    width: 100%;
    padding: 10px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.vote-btn:hover {
    background: #1d4ed8;
}

.poll-result-msg {
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: #4ade80;
}

/* ==========================================================================
   نتائج استطلاع الرأي (أشرطة النسب المئوية)
   ========================================================================== */
.poll-results {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.poll-result-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.poll-result-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
}

.poll-percent {
    font-weight: 700;
    color: #29b6f6;
}

html.light-theme .poll-percent {
    color: #0284c7;
}

.poll-bar-track {
    width: 100%;
    height: 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

html.light-theme .poll-bar-track {
    background: rgba(2, 132, 199, 0.1);
}

.poll-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    background: linear-gradient(90deg, #2563eb, #29b6f6);
    transition: width 0.5s ease;
}

.poll-bar-fill.poll-bar-selected {
    background: linear-gradient(90deg, #059669, #4ade80);
}

.poll-total-votes {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    opacity: 0.7;
    text-align: center;
}

/* ==========================================================================
   الفتر وسوشيال ميديا (Footer)
   ========================================================================== */
.footer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 0 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin-top: 2rem;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    transition: transform 0.2s;
}

.social-icon svg { width: 20px; height: 20px; }
.social-icon:hover { transform: scale(1.1); }

@keyframes pulse-glow-whatsapp {
    0%, 100% { box-shadow: 0 0 5px rgba(37, 211, 102, 0.55), 0 0 0 rgba(37, 211, 102, 0); }
    50% { box-shadow: 0 0 16px rgba(37, 211, 102, 1), 0 0 26px rgba(37, 211, 102, 0.5); }
}

@keyframes pulse-glow-facebook {
    0%, 100% { box-shadow: 0 0 5px rgba(24, 119, 242, 0.55), 0 0 0 rgba(24, 119, 242, 0); }
    50% { box-shadow: 0 0 16px rgba(24, 119, 242, 1), 0 0 26px rgba(24, 119, 242, 0.5); }
}

.social-icon.whatsapp {
    background: rgba(37, 211, 102, 0.18);
    border: 1px solid rgba(37, 211, 102, 0.5);
}

.social-icon.facebook {
    background: rgba(24, 119, 242, 0.18);
    border: 1px solid rgba(24, 119, 242, 0.5);
}

.social-icon.whatsapp:hover {
    animation: pulse-glow-whatsapp 1s ease-in-out infinite;
}

.social-icon.facebook:hover {
    animation: pulse-glow-facebook 1s ease-in-out infinite;
}

.footer-text {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* ==========================================================================
   حماية عامة: منع أي صورة داخل محتوى الخبر/الشرح من تجاوز حدود الحاوية
   ========================================================================== */
#article-content img,
#guide-content img {
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   التجاوب مع الهواتف (Responsive Media Queries)
   ========================================================================== */
@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .desktop-nav {
        display: none;
    }
    .menu-toggle-btn, .drawer-toggle-btn {
        display: block;
    }
    .page-wrapper {
        padding: 1rem;
    }
    .header-controls .lang-switcher {
        display: none;
    }
    .drawer-lang-switcher {
        justify-content: center;
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 600px) {
    .header-brand {
        padding: 8px 12px 8px 8px;
        border-radius: 30px;
        gap: 6px;
    }

    .brand-left {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .logo-container {
        width: 38px;
        height: 38px;
        flex-shrink: 0;
    }

    .brand-text {
        min-width: 0;
        flex: 1;
    }

    .brand-title {
        font-size: 0.8rem;
        line-height: 1.3;
        white-space: normal;
        word-break: break-word;
    }

    .brand-subtitle {
        display: none;
    }

    .header-controls {
        gap: 4px;
        flex-shrink: 0;
    }

    .theme-toggle-btn {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
    }

    .menu-toggle-btn, .drawer-toggle-btn {
        font-size: 1.25rem;
    }
}