:root {
    --primary-red: #ce1126;
    --primary-black: #1a1a1a;
    --primary-green: #007a3d;
    --primary-white: #ffffff;
    --light-gray: #f8f9fa;
    --dark-gray: #333;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Cairo', sans-serif; background-color: #fff; direction: rtl; color: var(--primary-black); }
html { scroll-behavior: smooth; }

/* =========================================
   1. تصميم الموقع الرئيسي
   ========================================= */
.top-bar { background: var(--primary-black); color: #fff; padding: 8px 0; font-size: 0.85em; }
.container { width: 90%; max-width: 1200px; margin: 0 auto; }
.navbar { background: var(--primary-white); box-shadow: 0 2px 15px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 1000; }
.nav-container { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo img { height: 55px; }
.logo h1 { font-size: 1.1rem; font-weight: 700; color: var(--primary-black); }
.nav-links { display: flex; list-style: none; gap: 20px; }
.nav-links li a { text-decoration: none; color: var(--dark-gray); font-weight: 600; font-size: 0.95rem; transition: 0.3s; padding: 8px 12px; border-radius: 4px; }
.nav-links li a:hover, .nav-links li a.active { color: var(--primary-red); background: rgba(206,17,38,0.05); }
.menu-toggle { display: none; font-size: 24px; cursor: pointer; color: var(--primary-black); }

.modern-hero { position: relative; width: 100%; height: 85vh; overflow: hidden; display: flex; align-items: center; justify-content: center; }
#heroSliderContainer { position: absolute; top:0; left:0; width:100%; height:100%; z-index: 1; }
.hero-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; opacity: 0; transition: opacity 1.5s ease-in-out; }
.hero-bg.active { opacity: 1; animation: kenBurns 20s infinite alternate; }
@keyframes kenBurns { 0% { transform: scale(1); } 100% { transform: scale(1.15); } }
.hero-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(45deg, rgba(0,0,0,0.6) 0%, rgba(206,17,38,0.2) 100%); z-index: 2; }
.hero-content { position: relative; z-index: 3; width: 90%; max-width: 800px; text-align: center; }
.glass-box { background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.3); padding: 50px; border-radius: 20px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2); color: white; }
.badge { background: var(--primary-green); color: white; padding: 5px 15px; border-radius: 50px; font-size: 0.85rem; margin-bottom: 15px; display: inline-block; }
.glass-box h1 { font-size: 2.8rem; margin-bottom: 20px; font-weight: 800; }
.glass-box p { font-size: 1.1rem; line-height: 1.6; margin-bottom: 30px; color: #f0f0f0; }
.hero-btns { display: flex; justify-content: center; gap: 15px; }
.btn-primary { background: var(--primary-red); color: white; padding: 12px 35px; border-radius: 50px; text-decoration: none; font-weight: bold; transition: 0.3s; border: 2px solid var(--primary-red); }
.btn-primary:hover { background: #a50e1e; border-color: #a50e1e; }
.btn-secondary { background: transparent; border: 2px solid white; color: white; padding: 12px 35px; border-radius: 50px; text-decoration: none; font-weight: bold; transition: 0.3s; }
.btn-secondary:hover { background: white; color: var(--primary-black); }

.section-padding { padding: 80px 0; }
.bg-light { background-color: var(--light-gray); }
.section-title { text-align: center; margin-bottom: 50px; color: var(--primary-black); position: relative; font-size: 2rem; }
.section-title::after { content: ''; display: block; width: 80px; height: 4px; background: var(--primary-red); margin: 15px auto 0; border-radius: 2px; }

.about-container { display: flex; align-items: center; gap: 50px; }
.about-text { flex: 1; }
.about-text p { font-size: 1.1rem; line-height: 1.8; color: #555; margin-bottom: 20px; }
.check-list { list-style: none; }
.check-list li { margin-bottom: 10px; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.check-list li i { color: var(--primary-green); }
.about-image { flex: 1; }
.about-image img { width: 100%; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }

.stats-section { background: linear-gradient(rgba(0,0,0,0.8), rgba(0,0,0,0.8)), url('https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?q=80'); background-size: cover; background-attachment: fixed; color: white; padding: 60px 0; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); text-align: center; gap: 30px; }
.stat-item i { font-size: 3rem; color: var(--primary-red); margin-bottom: 15px; }
.stat-item h3 { font-size: 2.5rem; font-weight: 700; margin-bottom: 5px; }
.stat-item p { font-size: 1.1rem; opacity: 0.9; }

.services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 30px; }
.service-card { background: white; padding: 30px; border-radius: 10px; text-align: center; box-shadow: 0 5px 20px rgba(0,0,0,0.05); transition: 0.3s; border-bottom: 4px solid transparent; }
.service-card:hover { transform: translateY(-10px); border-bottom-color: var(--primary-red); }
.icon-box { width: 70px; height: 70px; background: #fdf2f3; color: var(--primary-red); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; margin: 0 auto 20px; }
.service-card h3 { margin-bottom: 15px; font-size: 1.3rem; }
.service-card p { color: #666; line-height: 1.6; }

.depts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.dept-item { background: white; padding: 20px; text-align: center; border: 1px solid #eee; border-radius: 8px; font-weight: 600; color: var(--primary-black); transition: 0.3s; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.dept-item:hover { background: var(--primary-green); color: white; border-color: var(--primary-green); }

.org-chart { text-align: center; max-width: 800px; margin: 0 auto; }
.org-box { background: white; border: 2px solid var(--primary-black); padding: 15px 30px; display: inline-block; border-radius: 8px; font-weight: bold; position: relative; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.level-1 { background: var(--primary-red); color: white; border: none; font-size: 1.2rem; }
.org-lines { height: 30px; width: 2px; background: #ccc; margin: 0 auto; }
.org-row { display: flex; justify-content: space-around; position: relative; margin-top: 0; }
.org-row::before { content: ''; position: absolute; top: -30px; left: 25%; right: 25%; height: 30px; border: 2px solid #ccc; border-bottom: none; }
.level-2 { width: 180px; }
.org-lines-2 { height: 30px; width: 2px; background: #ccc; margin: 0 auto; }
.org-row-bottom { display: flex; justify-content: center; gap: 20px; border-top: 2px solid #ccc; padding-top: 20px; }
.org-small { background: #eee; padding: 10px 20px; border-radius: 50px; font-size: 0.9rem; }

.news-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 25px; }
.news-card { background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 5px 15px rgba(0,0,0,0.08); transition: transform 0.3s; }
.news-card:hover { transform: translateY(-5px); }
.news-img { width: 100%; height: 220px; object-fit: cover; }
.news-content { padding: 25px; }
.news-content h3 { color: var(--primary-red); margin-bottom: 12px; font-size: 1.2rem; line-height: 1.4; }
.news-content p { color: #666; font-size: 0.95rem; line-height: 1.7; }

footer { background: #111; color: white; padding-top: 70px; border-top: 5px solid var(--primary-red); }
.footer-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 40px; margin-bottom: 50px; }
.footer-section h3 { font-size: 1.3rem; margin-bottom: 25px; color: var(--primary-white); border-right: 3px solid var(--primary-red); padding-right: 15px; }
.footer-section p { color: #bbb; line-height: 1.8; margin-bottom: 15px; }
.footer-section ul { list-style: none; }
.footer-section ul li { margin-bottom: 12px; }
.footer-section ul li a { color: #bbb; text-decoration: none; transition: 0.3s; }
.footer-section ul li a:hover { color: var(--primary-red); padding-right: 5px; }
.contact-info p { display: flex; align-items: center; gap: 10px; }
.social-icons { display: flex; gap: 15px; margin-top: 20px; }
.social-icons a { width: 40px; height: 40px; background: #333; color: white; display: flex; align-items: center; justify-content: center; border-radius: 50%; text-decoration: none; transition: 0.3s; }
.social-icons a:hover { background: var(--primary-red); transform: rotate(360deg); }
.copyright { background: black; text-align: center; padding: 20px 0; color: #777; font-size: 0.9rem; border-top: 1px solid #222; }

@media (max-width: 768px) {
    .nav-links { display: none; }
    .menu-toggle { display: block; }
    .about-container { flex-direction: column; }
    .org-row { flex-direction: column; gap: 20px; align-items: center; }
    .org-row::before { display: none; }
}

/* =========================================
   2. تصميم لوحة التحكم وتسجيل الدخول (Dashboard & Login)
   ========================================= */
body.login-bg { background-color: var(--light-gray); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
.login-box { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); width: 350px; text-align: center; border-top: 4px solid var(--primary-green); }
.login-box input { width: 90%; padding: 10px; margin: 10px 0; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-family: 'Cairo', sans-serif; }
.login-box button { background: var(--primary-green); color: white; border: none; padding: 10px 20px; width: 100%; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 16px; margin-top: 10px; font-family: 'Cairo', sans-serif; }
.login-box button:hover { background: #006030; }
.error-msg { color: var(--primary-red); margin-bottom: 10px; font-weight: bold; font-size: 14px; }

.dashboard-wrapper { max-width: 900px; margin: 30px auto; padding: 0 20px; }
.dashboard-card { background: #fff; padding: 30px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); margin-bottom: 30px; border: 1px solid #eee; }
h2.dash-title { color: var(--primary-red); margin-bottom: 20px; border-bottom: 2px solid #f4f4f4; padding-bottom: 10px; font-weight: 700; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #444; }
.form-group input, .form-group textarea { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-family: 'Cairo', sans-serif; font-size: 0.95rem; box-sizing: border-box; }
.preview-box { max-width: 100%; height: 180px; object-fit: cover; border-radius: 8px; margin-top: 10px; display: none; border: 2px dashed #ddd; }
.admin-list { margin-top: 25px; border-top: 2px solid #f9f9f9; padding-top: 15px; }
.admin-item { background: #fdfdfd; border: 1px solid #eee; padding: 12px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; border-radius: 10px; }
.thumb-box { display: flex; align-items: center; gap: 15px; }
.thumb-img { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; border: 1px solid #eee; }
.item-title { font-weight: 600; color: #333; }
.btn-add { background: var(--primary-red); color: white; border: none; padding: 14px; cursor: pointer; width: 100%; font-size: 1rem; font-weight: bold; border-radius: 6px; transition: 0.3s; font-family: 'Cairo', sans-serif;}
.btn-add:hover { background: #a50e1e; transform: translateY(-2px); }
.btn-news { background: var(--primary-green); }
.btn-news:hover { background: #006030; }
.delete-btn { background: #333; color: #fff; padding: 8px 16px; border: none; cursor: pointer; border-radius: 5px; font-size: 0.85rem; transition: 0.3s; font-family: 'Cairo', sans-serif;}
.delete-btn:hover { background: #000; }
.logout-btn { background: var(--primary-red); color: white; text-decoration: none; padding: 6px 15px; border-radius: 4px; font-weight: bold; font-size: 14px; transition: 0.3s; margin-right: 15px;}
.logout-btn:hover { background: #a50e1e; }
.preview-link { display:inline-block; margin-bottom:20px; text-decoration:none; color: var(--primary-green); font-weight:bold; }

/* =========================================
   3. تصميم نظام العقارات (lawdash.html) معزول داخل #law-system-root
   ========================================= */
#law-system-root { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #ffffff; color: #012820; min-height: 100vh; text-align: right; direction: rtl;}
#law-system-root header { background-color: #012820; color: #ffffff; padding: 15px 30px; display: flex; justify-content: space-between; align-items: center; border-bottom: 5px solid #e9d6bf; margin-bottom: 40px; }
#law-system-root .logo-container { display: flex; align-items: center; gap: 15px; }
#law-system-root .logo-placeholder img { width: 50px; border-radius: 50%; }
#law-system-root h1 { font-size: 20px; color: #e9d6bf; margin: 0; }
#law-system-root button { background-color: #39c765; color: #ffffff; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-weight: bold; transition: background 0.3s; font-family: inherit;}
#law-system-root button:hover { background-color: #2ea652; }
#law-system-root button.secondary { background-color: #e04f5f; }
#law-system-root button.secondary:hover { background-color: #c93b4a; }
#law-system-root .container { max-width: 800px; margin: 0 auto 40px; padding: 20px; }
#law-system-root .view-section { display: none; background-color: #f9f9f9; padding: 30px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); border-top: 4px solid #39c765; }
#law-system-root .view-section.active { display: block; }
#law-system-root .form-group { margin-bottom: 15px; }
#law-system-root .form-group label { display: block; margin-bottom: 5px; font-weight: bold; }
#law-system-root .form-group input, #law-system-root .form-group textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; box-sizing: border-box;}
#law-system-root .form-group input[type="file"] { background: #fff; padding: 7px; }
#law-system-root .grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
#law-system-root .full-width { grid-column: 1 / -1; }
#law-system-root .action-buttons { margin-top: 20px; display: flex; gap: 10px; }
#law-system-root #login-view { max-width: 500px; margin: 0 auto; }
#law-system-root .loading { color: #39c765; font-weight: bold; display: none; margin-top: 10px;}
#law-system-root .file-link { color: #0056b3; text-decoration: none; font-weight: bold; }
#law-system-root .file-link:hover { text-decoration: underline; }
@media print {
    body * { visibility: hidden; }
    #law-system-root #user1-results, #law-system-root #user1-results * { visibility: visible; }
    #law-system-root #user1-results { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
    #law-system-root button, #law-system-root header { display: none !important; }
}

/* إصلاح تنسيق شبكة الخدمات */
.services-modern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

.modern-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 25px 25px;
    position: relative;
    border: 1px solid #eee;
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.modern-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-red);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.card-icon {
    font-size: 2.2rem;
    color: var(--primary-red);
    margin-bottom: 15px;
}

.modern-card h3 {
    font-size: 1.15rem;
    margin-bottom: 10px;
    color: var(--primary-black);
}

.modern-card p {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
}

.card-tag {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: bold;
}

.tag-digital { background: #e8f5e9; color: var(--primary-green); }
.tag-info { background: #e3f2fd; color: #1976d2; }
.tag-hybrid { background: #fff3e0; color: #f57c00; }

.card-footer {
    border-top: 1px solid #f5f5f5;
    padding-top: 10px;
    font-size: 0.8rem;
    color: #999;
    font-weight: bold;
}

/* تنسيقات الهيكلية الشجرية */
.tree-wrapper { text-align: center; padding: 40px 0; }
.tree-node {
    background: #fff; border: 1px solid #4472c4; padding: 12px;
    border-radius: 6px; font-weight: bold; font-size: 0.85rem;
    display: inline-block; box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    min-width: 140px; transition: 0.3s;
}
.tree-node.boss {
    background: #4472c4; color: white; padding: 18px 40px;
    font-size: 1.1rem; border: none; margin-bottom: 40px;
}
.tree-body { display: flex; justify-content: center; gap: 30px; border-top: 2px solid #ccc; padding-top: 30px; }
.node-row { display: flex; gap: 10px; margin-bottom: 15px; justify-content: center; }
.tree-node.side { border-right: 4px solid #4472c4; text-align: right; margin-bottom: 8px; }
.tree-node.branch-mgmt { background: #f8f9fa; border-style: dashed; }

/* تنسيقات صفحة التقرير */
.report-card { background: white; padding: 30px; border-radius: 15px; margin-bottom: 25px; border: 1px solid #eee; }
.content-text { line-height: 2; color: #444; font-size: 1.05rem; }
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 15px; }
.goal-item { background: #fdf2f3; padding: 15px; border-radius: 8px; color: #ce1126; font-weight: 600; border-right: 4px solid #ce1126; }
.ach-row { padding: 12px; border-bottom: 1px solid #f5f5f5; line-height: 1.8; }

/* تصميم صفحة Overview */
.main-overview {
    border-right: 5px solid var(--primary-red);
    padding: 40px;
    background: #fff;
    line-height: 1.8;
}

.overview-heading {
    color: var(--primary-red);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.management-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.mgmt-card {
    background: #fff;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.mgmt-card i {
    font-size: 2.5rem;
    color: var(--primary-green);
    margin-bottom: 15px;
}

.dept-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.dept-full-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    border: 1px solid #eee;
}

.dept-header {
    background: var(--primary-black);
    color: #fff;
    padding: 15px;
    font-weight: bold;
}

.dept-header span {
    background: var(--primary-red);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
    font-size: 0.9rem;
}

.dept-body {
    padding: 20px;
}

.sub-units {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
    font-size: 0.9rem;
    color: #555;
}

.branches-box {
    background: #f9f9f9;
    padding: 30px;
    border-radius: 15px;
}

.branch-names {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 30px;
}

.branch-names span {
    background: #fff;
    border: 1px solid var(--primary-green);
    color: var(--primary-green);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
}

.branch-structure {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    border-right: 4px solid var(--primary-green);
}

.branch-structure ul {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 10px;
}

.branch-structure li::before {
    content: "•";
    color: var(--primary-red);
    font-weight: bold;
    margin-left: 10px;
}

/* =========================================
   4. تحسينات الأداء (LCP & CLS Fixes)
   ========================================= */
#newsContainer, #allNewsContainer {
    min-height: 400px; /* يمنع قفز الصفحة (CLS) عن طريق حجز مساحة مسبقة */
}
.news-img {
    aspect-ratio: 16/9; /* يحافظ على نسبة الصورة لتجنب تشوهها أو تغيير حجمها فجأة */
    object-fit: cover;
    width: 100%;
}