/* === 1. إعدادات عامة (الوضع الفاتح) === */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl; 
    background-color: #f4f6f9; /* رمادي فاتح جداً للخلفية */
    color: #212529; /* رمادي غامق للنصوص (بدل الأسود الصريح لراحة العين) */
    margin: 0;
    padding: 0;
}

a { text-decoration: none; }

/* === 2. القائمة الجانبية (Sidebar) === */
.sidebar {
    width: 250px;
    background-color: #343a40; /* سنبقي القائمة غامقة للتباين الجميل (مثل AdminLTE) */
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    z-index: 100;
    color: #fff;
}
.sidebar-header {
    padding: 20px;
    text-align: center;
    background-color: #23272b; /* درجة أغمق للهيدر */
    border-bottom: 1px solid #4b545c;
}
.sidebar-header h3 {
    margin: 0;
    color: #fff;
    font-size: 1.2rem;
}
.sidebar-nav a {
    display: block;
    padding: 15px 20px;
    color: #c2c7d0;
    border-bottom: 1px solid #4b545c;
    transition: all 0.3s;
}
.sidebar-nav a:hover {
    background-color: #494e53;
    color: #fff;
    padding-right: 25px; /* حركة بسيطة عند الهوفر */
}
.sidebar-nav a.active {
    background-color: #007bff; /* أزرق زاهي */
    color: #fff;
}

/* === 3. حاوية الصفحة والشريط العلوي === */
.page-container {
    margin-right: 250px; /* إزاحة المحتوى */
    transition: margin-right 0.3s;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ffffff; /* أبيض */
    padding: 15px 30px;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.top-bar .welcome-message { 
    font-size: 16px; 
    font-weight: bold;
    color: #495057;
}
.top-bar .logout-link a {
    color: #fff;
    background-color: #dc3545;
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 14px;
}
.top-bar .logout-link a:hover { background-color: #c82333; }

/* رابط الملف الشخصي */
.top-bar-link {
    color: #007bff;
    font-weight: normal;
    margin-right: 10px;
}
.top-bar-link:hover, .top-bar-link.active {
    color: #0056b3;
    text-decoration: underline;
}

.main-content {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}
.main-content h1 {
    border-bottom: 2px solid #007bff; /* خط أزرق تحت العنوان */
    padding-bottom: 10px;
    color: #343a40;
    font-size: 24px;
    margin-bottom: 25px;
}

/* === 4. تنسيقات صفحة الدخول (login.php) === */
body.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #e9ecef; /* خلفية رمادي فاتح */
}
body.login-body .page-container { margin-right: 0; }

.login-container {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    width: 380px;
    border-top: 5px solid #007bff;
}
.login-container h2 {
    text-align: center;
    color: #343a40;
    margin-top: 0;
    margin-bottom: 20px;
}
.login-container .btn {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.login-container .btn:hover { background-color: #0056b3; }

/* === 5. كروت الإحصائيات (KPI Boxes) === */
.kpi-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 0; 
}
.kpi-box {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e3e6f0;
    border-left-width: 5px; /* الشريط الملون على اليمين */
}
.kpi-title {
    font-size: 14px;
    color: #6c757d; /* رمادي متوسط */
    margin-bottom: 10px;
    text-transform: uppercase;
    font-weight: bold;
}
.kpi-value {
    font-size: 24px;
    font-weight: bold;
    color: #343a40;
}
/* ألوان الكروت */
.kpi-box.kpi-overdue { border-left-color: #dc3545; } /* أحمر */
.kpi-box.kpi-overdue .kpi-value { color: #dc3545; }

.kpi-box.kpi-expected { border-left-color: #28a745; } /* أخضر */
.kpi-box.kpi-expected .kpi-value { color: #28a745; }

.kpi-box.kpi-customers { border-left-color: #ffc107; } /* أصفر */
.kpi-box.kpi-customers .kpi-value { color: #856404; }

.kpi-box.kpi-active { border-left-color: #17a2b8; } /* أزرق فاتح */
.kpi-box.kpi-active .kpi-value { color: #17a2b8; }

/* === 6. الأقسام والفورم (Containers) === */
.section-container {
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    padding: 25px;
    margin-bottom: 30px;
    border: 1px solid #e3e6f0;
}
.form-container {
    background-color: #f8f9fa; /* خلفية رمادي فاتح جداً للفورم */
    padding: 25px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-top: 20px;
}

/* حقول الإدخال (Inputs) */
.input-group { margin-bottom: 15px; }
.input-group label {
    display: block;
    margin-bottom: 6px;
    color: #495057;
    font-weight: 600;
}
.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="file"],
.input-group input[type="date"],
.input-group input[type="search"],
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 10px;
    font-size: 1.25rem;
    border: 1px solid #ced4da; /* حدود رمادي فاتح */
    background-color: #ffffff;
    /*color: #495057;*/
    color: #000000;
    border-radius: 4px;
    box-sizing: border-box; 
    transition: border-color 0.2s;
}
.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}
.input-group textarea { resize: vertical; }

.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* === 7. الأزرار === */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.9; }

.btn-primary { background-color: #007bff; }
.btn-success { background-color: #28a745; }
.btn-secondary { background-color: #6c757d; }
.btn-danger { background-color: #dc3545; }
.btn-warning { background-color: #ffc107; color: #212529; }
.btn-info { background-color: #17a2b8; }
.btn-small { padding: 4px 8px; font-size: 13px; margin-left: 3px; }

/* === 8. رسائل التنبيه === */
.message { padding: 15px; margin-bottom: 20px; border-radius: 4px; text-align: center; border: 1px solid transparent; }
.message.success { color: #155724; background-color: #d4edda; border-color: #c3e6cb; }
.message.error { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; }

/* === 9. الجداول (Tables) === */
.content-area { margin-top: 20px; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.data-table th, .data-table td {
    padding: 12px;
    border: 1px solid #dee2e6;
    text-align: right;
}
.data-table th {
    background-color: #343a40; /* هيدر الجدول غامق */
    color: #ffffff;
    font-weight: 600;
}
.data-table tbody tr:nth-child(even) {
    background-color: #f8f9fa; /* صفوف متبادلة */
}
.data-table tbody tr:hover {
    background-color: #e2e6ea; /* تأثير عند المرور */
}

/* === 10. ألوان حالات الأقساط (مهم جداً للوضوح) === */
.data-table tr.status-overdue-heavy {
    background-color: #f8d7da !important; /* أحمر فاتح */
    border-left: 5px solid #dc3545;
}
.data-table tr.status-overdue-light {
    background-color: #fff3cd !important; /* أصفر فاتح */
    border-left: 5px solid #ffc107;
}
.data-table tr.status-due {
    background-color: #d4edda !important; /* أخضر فاتح */
    border-left: 5px solid #28a745;
}
.data-table tr.status-finished {
    background-color: #e9ecef !important; /* رمادي */
    color: #6c757d;
}
.data-table tr.status-finished a.btn { opacity: 0.6; }
.data-table td.status-cell { font-weight: bold; }

/* عدد الأقساط السارية (Badge) */
.status-active-count {
    background-color: #17a2b8;
    color: white;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: bold;
}

/* === 11. تفاصيل العملية والمستندات === */
.details-table { width: 100%; border-collapse: collapse; }
.details-table th, .details-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
}
.details-table th {
    width: 25%;
    background-color: #f8f9fa;
    font-weight: bold;
    color: #495057;
}
.details-table tr.highlighted-row { background-color: #e8f4f8; } /* أزرق فاتح جداً للتمييز */
.details-table tr.bold-row th, .details-table tr.bold-row td {
    font-weight: bold;
    color: #0056b3;
    font-size: 1.05em;
}
/* لون المتبقي (تحذيري) */
.details-table tr.bold-row[style*="#59481e"] { 
    background-color: #fff3cd !important; 
    color: #856404 !important;
}

/* شبكة الصور */
.documents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; margin-top: 20px; }
.document-item {
    border: 1px solid #dee2e6;
    border-radius: 5px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
}
.document-item img { width: 100%; height: 150px; object-fit: cover; display: block; }
.document-item .doc-title {
    padding: 8px;
    text-align: center;
    font-size: 13px;
    color: #495057;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: block;
}
/* زر حذف الصورة */
.doc-delete-btn {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 25px;
    height: 25px;
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    text-decoration: none;
    font-weight: bold;
    border: 1px solid white;
    opacity: 0;
    transition: opacity 0.2s;
}
.document-item:hover .doc-delete-btn { opacity: 1; }
.doc-delete-btn:hover { background-color: #c82333; }

/* === 12. تنسيق البحث والفلترة === */
.search-container {
    background-color: #f1f3f5;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 20px;
}
.search-container form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 15px;
}
.filter-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    flex-grow: 1;
}

/* === 13. قسم الدفعات === */
.payment-section { display: grid; grid-template-columns: 1fr 2fr; gap: 25px; align-items: flex-start; }
.note { font-size: 14px; color: #495057; background-color: #fff3cd; border: 1px solid #ffeeba; padding: 10px; border-radius: 4px; }

hr.separator { border: 0; height: 1px; background-color: #dee2e6; margin: 30px 0; }

/* الموبايل */
@media (max-width: 768px) {
    .sidebar { width: 100%; position: relative; height: auto; }
    .page-container { margin-right: 0; }
    .payment-section { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: 1fr; }
}


/* === 18. تنسيقات صفحة التقارير (جديد) === */
.kpi-box.kpi-today {
    border-left-color: #6f42c1; /* بنفسجي */
    background-color: #f3e5f5; /* خلفية فاتحة جداً */
}
.kpi-box.kpi-today .kpi-value {
    color: #6f42c1;
}

.kpi-box.kpi-month {
    border-left-color: #20c997; /* تيل (أخضر مزرق) */
    background-color: #e6fffa;
}
.kpi-box.kpi-month .kpi-value {
    color: #20c997;
}


