:root {
    --primary-color: #2E7D32;
    --secondary-color: #81C784;
    --bg-color: #F1F8E9;
    --text-dark: #333;
    --text-light: #fff;
    --font-main: 'Cairo', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Top Bar ===== */
.top-bar {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 10px 0;
}
.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo h1 { font-size: 1.2rem; }

.exchange-ticker {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
}
.exchange-ticker strong { color: #FFEB3B; }

.btn-small {
    background-color: #fff;
    color: var(--primary-color);
    padding: 5px 12px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ===== Navigation ===== */
.main-nav {
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
    z-index: 100;
}
.main-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 5px;
    padding: 0;
    flex-wrap: wrap;
}
.main-nav > .container > ul > li > a {
    display: block;
    padding: 15px 18px;
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.95rem;
}
.main-nav > .container > ul > li > a:hover {
    color: var(--primary-color);
    background-color: #E8F5E9;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff !important;
    padding: 8px 15px !important;
    border-radius: 5px;
    margin-top: 7px;
}
.btn-primary:hover {
    background-color: #1B5E20 !important;
}

/* ===== القوائم المنسدلة ===== */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropbtn { cursor: pointer; }

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #ffffff;
    min-width: 220px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.15);
    border-radius: 8px;
    z-index: 1000;
    top: 100%;
    right: 0;
    overflow: hidden;
    border-top: 3px solid #2E7D32;
}
.dropdown-content a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: right;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}
.dropdown-content a:last-child { border-bottom: none; }
.dropdown-content a:hover {
    background-color: #E8F5E9;
    color: #2E7D32;
    padding-right: 22px;
}

/* ===== القائمة الفرعية ===== */
.dropdown-submenu {
    position: relative;
}
.dropdown-submenu .submenu-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dropdown-submenu .submenu-toggle::after {
    content: "◂";
    font-size: 0.8rem;
    color: #2E7D32;
}
.submenu-content {
    display: none;
    position: absolute;
    top: 0;
    right: 100%;
    background-color: #ffffff;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.15);
    border-radius: 8px;
    border-top: 3px solid #2E7D32;
    overflow: hidden;
    z-index: 1001;
}
.submenu-content a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: right;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}
.submenu-content a:last-child { border-bottom: none; }
.submenu-content a:hover {
    background-color: #E8F5E9;
    color: #2E7D32;
    padding-right: 22px;
}

/* ===== Hero Section ===== */
.hero {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-radius: 10px;
    margin: 20px 0;
}
.hero h2 { font-size: 2rem; color: var(--primary-color); margin-bottom: 15px; }

/* ===== Cards ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}
.card {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border-top: 4px solid var(--primary-color);
    transition: transform 0.3s;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(46, 125, 50, 0.2);
}
.card h3 { color: var(--primary-color); margin-bottom: 10px; }

/* ===== Forms ===== */
.form-container {
    max-width: 450px;
    margin: 50px auto;
    background: #fff;
    padding: 35px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.form-container h2 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 25px;
}
.form-container input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 1rem;
}
.form-container button {
    width: 100%;
    padding: 12px;
    border: none;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 1rem;
}
.success { color: green; text-align: center; margin-bottom: 15px; }
.error { color: red; text-align: center; margin-bottom: 15px; }

/* ===== Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 40px;
}
.data-table thead {
    background-color: var(--primary-color);
    color: #fff;
}
.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #eee;
}
.data-table tbody tr:hover { background-color: #F1F8E9; }

/* ===== Footer ===== */
footer {
    background-color: #1B5E20;
    color: #fff;
    text-align: center;
    padding: 25px 0;
    margin-top: 40px;
}
.footer-links a {
    color: #A5D6A7;
    text-decoration: none;
    margin: 0 10px;
    font-size: 0.9rem;
}
.footer-links a:hover { color: #fff; }
footer p { margin-top: 15px; font-size: 0.85rem; }

/* ===== تنسيق شريط البحث ===== */
.search-form form {
    display: flex;
    align-items: center;
    background-color: #fff;
    border: 1px solid #2E7D32;
    border-radius: 20px;
    overflow: hidden;
    height: 35px;
}
.search-form input[type="text"] {
    border: none;
    outline: none;
    padding: 0 15px;
    font-family: var(--font-main);
    font-size: 0.85rem;
    width: 150px;
    height: 100%;
}
.search-form button[type="submit"] {
    background-color: #2E7D32;
    color: #fff;
    border: none;
    padding: 0 15px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: bold;
    font-size: 0.85rem;
    height: 100%;
}

/* =========================================
   إعدادات شاشات الهواتف (Mobile - Horizontal Menu)
   ========================================= */

@media screen and (max-width: 991px) {
    
    body, html {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        overflow-x: hidden; 
    }

    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 10px !important; 
        margin: 0 auto !important;
    }

    /* الشريط العلوي */
    .top-bar .container {
        flex-direction: column;
        text-align: center;
        padding: 15px 5px !important;
    }
    .logo { justify-content: center; margin-bottom: 10px; }
    .exchange-ticker { justify-content: center; width: 100%; }

    /* القائمة الرئيسية (سطر واحد) */
    .main-nav ul {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
        background-color: #fff;
        padding: 5px 0 !important;
    }

    .main-nav ul li {
        width: auto !important;
        border-bottom: none !important;
    }

    .main-nav > .container > ul > li > a {
        padding: 8px 10px !important;
        font-size: 0.85rem !important;
        font-weight: 700;
        color: #333;
    }

    /* القوائم المنسدلة على الهاتف (تفتح بالضغط) */
    .dropdown-content, .submenu-content {
        display: none;
        position: static !important; /* يجعلها تفتح تحت القائمة مباشرة */
        box-shadow: none !important;
        border: none !important;
        background-color: #f1f8e9 !important;
        width: 100%;
        margin-top: 10px;
        padding-right: 15px;
    }
    
    .dropdown-content.active, .submenu-content.active {
        display: block !important;
    }

    /* المحتوى ليملأ الشاشة */
    .hero {
        border-radius: 0 !important; 
        padding: 30px 15px !important;
        margin: 0 0 20px 0 !important;
    }
    .hero h2 { font-size: 1.4rem; }
    
    .cards-grid {
        grid-template-columns: 1fr; 
        gap: 15px;
        padding: 0 !important;
    }
    .card {
        border-radius: 0 !important; 
        margin: 0 !important;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    .data-table, table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
}
/* =========================================
   إصلاح عرض الجداول على شاشات الهواتف
   ========================================= */

@media screen and (max-width: 991px) {
    
    /* تغليف الجداول لتصبح قابلة للسحب */
    .data-table, table {
        display: block !important; /* يجعل الجدول كتلة مستقلة */
        width: 100% !important;
        overflow-x: auto !important; /* تفعيل السحب الأفقي */
        -webkit-overflow-scrolling: touch; /* سحب سلس على الآيفون */
        white-space: nowrap; /* منع النصوص من الالتفاف وتكسير الجدول */
    }

    /* تصغير حجم الخطوط والحشوات قليلاً ليناسب الشاشة */
    .data-table th, .data-table td, table th, table td {
        padding: 10px 12px !important;
        font-size: 0.85rem !important;
    }
    
    /* إصلاح أي عرض ثابت في جداول البنوك (إذا وجد) */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
    }
}
/* ===== تحسين شريط التنقل في لوحة التحكم ===== */
.nav-links {
    display: flex;
    flex-wrap: wrap; /* يسمح للروابط بالنزول لسطر جديد إذا امتلأ العرض */
    gap: 8px; /* مسافة بين الروابط */
    align-items: center;
    justify-content: flex-start;
    line-height: 1.8;
}

.nav-links a {
    margin-left: 0 !important; /* إلغاء الهامش القديم لأننا سنستخدم gap */
    white-space: nowrap; /* منع كسر النص داخل الرابط */
}

/* إزالة علامات | واستبدالها بمسافات من خلال تنسيق الـ gap */
/* (اختياري: يمكنك إبقاء العلامات إذا أردت) */
/* ===== الوضع الليلي (Dark Mode) ===== */
body.dark-mode {
    background-color: #121212 !important;
    color: #e0e0e0 !important;
}

body.dark-mode .card,
body.dark-mode .form-container,
body.dark-mode .data-table,
body.dark-mode .main-nav ul {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
}

body.dark-mode .main-nav a,
body.dark-mode .data-table th,
body.dark-mode .data-table td {
    color: #e0e0e0 !important;
    border-color: #333 !important;
}

body.dark-mode .hero {
    background: linear-gradient(135deg, #1e1e1e 0%, #2c2c2c 100%) !important;
}

body.dark-mode .hero h2,
body.dark-mode .card h3,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3 {
    color: #81C784 !important; /* لون أخضر فاتح للعناوين */
}

body.dark-mode .exchange-ticker {
    color: #fff;
}

body.dark-mode .dropdown-content {
    background-color: #1e1e1e !important;
    border-color: #333 !important;
}

body.dark-mode .dropdown-content a {
    color: #e0e0e0 !important;
    border-bottom-color: #333 !important;
}

body.dark-mode .dropdown-content a:hover {
    background-color: #2c2c2c !important;
}

body.dark-mode footer {
    background-color: #0a0a0a !important;
}
/* =========================================
   إصلاحات الوضع الليلي (Dark Mode Fixes)
   ========================================= */

/* 1. إصلاح الشريط العلوي (Header) */
body.dark-mode .top-bar {
    background-color: #1a1a1a !important;
    border-bottom: 2px solid #333;
}

body.dark-mode .main-nav {
    background-color: #121212 !important;
}

body.dark-mode .main-nav a {
    color: #e0e0e0 !important;
}

/* 2. إصلاح الخلفيات البيضاء للحاويات (Containers) */
body.dark-mode .container,
body.dark-mode .card,
body.dark-mode .form-container,
body.dark-mode div[style*="background: #fff"],
body.dark-mode div[style*="background-color: #fff"] {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
}

/* 3. إصلاح الجداول (Tables) بالكامل */
body.dark-mode .data-table,
body.dark-mode table {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
    border-color: #333 !important;
}

body.dark-mode .data-table th,
body.dark-mode table th {
    background-color: #2E7D32 !important; /* الحفاظ على رأس الجدول أخضر */
    color: #fff !important;
    border-color: #333 !important;
}

body.dark-mode .data-table td,
body.dark-mode table td {
    border-color: #333 !important;
    color: #e0e0e0 !important;
}

/* إصلاح الصفوف المخططة (Zebra Striping) أو الخلايا ذات الخلفية الفاتحة */
body.dark-mode .data-table tr:nth-child(even),
body.dark-mode table tr:nth-child(even) {
    background-color: #2c2c2c !important;
}

body.dark-mode .data-table td[style*="background-color: #E8F5E9"],
body.dark-mode table td[style*="background-color: #E8F5E9"] {
    background-color: #2c2c2c !important; /* تغميق الخلفية الفاتحة */
    color: #e0e0e0 !important;
}

/* 4. إصلاح النماذج (Forms) وحقول الإدخال */
body.dark-mode input, 
body.dark-mode textarea,
body.dark-mode select {
    background-color: #2c2c2c !important;
    color: #fff !important;
    border: 1px solid #444 !important;
}

/* 5. إصلاح الأزرار والأيقونات */
body.dark-mode .btn-small {
    background-color: #2c2c2c !important;
    color: #81C784 !important;
    border: 1px solid #444;
}

/* 6. إصلاح صفحات العرض (Details) التي تحتوي على الجداول */
body.dark-mode .container > div[style*="max-width: 800px"] {
    background-color: transparent !important;
}
/* ===== إصلاح صندوق معلومات التمويل في الوضع الليلي ===== */
body.dark-mode div[style*="background-color: #E8F5E9"],
body.dark-mode div[style*="background-color:#E8F5E9"] {
    background-color: #2c2c2c !important; /* لون داكن */
    color: #e0e0e0 !important; /* نص فاتح */
    border-right-color: #81C784 !important; /* الحفاظ على الخط الأخضر */
}

/* إصلاح النصوص داخل الصندوق */
body.dark-mode div[style*="background-color: #E8F5E9"] p,
body.dark-mode div[style*="background-color: #E8F5E9"] strong {
    color: #e0e0e0 !important;
}