/* متغيرات CSS */
:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --gray-color: #7f8c8d;
    --sidebar-width: 250px;
}

/* إعدادات عامة */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    direction: rtl;
}

/* تخطيط لوحة التحكم */
.dashboard-container {
    display: flex;
    flex-direction: row-reverse;
    position: relative;
    min-height: calc(100vh - 60px);
    margin-top: 60px; /* إضافة هامش علوي لتجنب تداخل المحتوى مع الهيدر */
}

/* الشريط الجانبي */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    padding: 0;
    position: fixed;
    right: 0;
    top: 60px; /* بدء الشريط الجانبي بعد الهيدر */
    height: calc(100vh - 60px);
    overflow-y: auto;
    z-index: 100;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
}

/* المحتوى الرئيسي */
.main-content {
    flex: 1;
    padding: 20px;
    margin-right: var(--sidebar-width);
    margin-left: 0;
    width: calc(100% - var(--sidebar-width));
    box-sizing: border-box;
    position: relative;
}

/* الهيدر الرئيسي */
.main-header {
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: 60px;
    z-index: 1000;
}

/* شعار وعنوان الموقع */
.header-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2rem;
    text-decoration: none;
}

.header-brand i {
    font-size: 1.4rem;
}

.toggle-sidebar {
    background: none;
    border: none;
    color: var(--gray-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.toggle-sidebar:hover {
    background-color: #f0f0f0;
}

/* إجراءات الهيدر (التنبيهات والملف الشخصي) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* تنسيق التنبيهات */
.notifications {
    position: relative;
}

.notifications-toggle {
    position: relative;
    color: var(--gray-color);
    font-size: 1.2rem;
    text-decoration: none;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notifications-toggle:hover {
    background-color: #f0f0f0;
}

.badge {
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.notifications-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 300px;
    display: none;
    z-index: 1001;
    margin-top: 10px;
    overflow: hidden;
}

.notifications:hover .notifications-dropdown {
    display: block;
}

.notifications-header {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    background-color: #f9f9f9;
}

.notifications-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--gray-color);
}

.notifications-list {
    max-height: 300px;
    overflow-y: auto;
}

.notifications-footer {
    padding: 10px 15px;
    border-top: 1px solid #eee;
    text-align: center;
    background-color: #f9f9f9;
}

.view-all {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
    transition: color 0.3s;
}

.view-all:hover {
    color: var(--secondary-color);
}

.notification-item {
    display: flex;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    gap: 10px;
    align-items: flex-start;
    transition: background-color 0.3s;
}

.notification-item:hover {
    background-color: #f9f9f9;
}

.notification-item i {
    margin-top: 2px;
    font-size: 1rem;
}

.notification-content {
    flex: 1;
}

.notification-content p {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
}

.notification-content small {
    color: var(--gray-color);
    font-size: 0.8rem;
}

/* تنسيق حسب شدة التنبيه */
.severity-high i {
    color: var(--danger-color);
}

.severity-medium i {
    color: var(--warning-color);
}

.severity-low i {
    color: var(--primary-color);
}

/* تنسيق الملف الشخصي */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.user-profile-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.user-profile-toggle:hover {
    background-color: #f0f0f0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    color: #333;
    font-weight: bold;
}

.user-role {
    font-size: 0.8rem;
    color: var(--gray-color);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 200px;
    display: none;
    z-index: 1001;
    margin-top: 10px;
    overflow: hidden;
}

.user-profile:hover .user-dropdown {
    display: block;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.3s;
}

.user-dropdown-item:hover {
    background-color: #f9f9f9;
}

.user-dropdown-item i {
    color: var(--gray-color);
    width: 20px;
    text-align: center;
}

/* الشريط الجانبي */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    padding: 0;
    position: fixed;
    right: 0;
    top: 60px; /* بدء الشريط الجانبي بعد الهيدر */
    height: calc(100vh - 60px);
    overflow-y: auto;
    z-index: 100;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
}

/* تنسيق الترويسة */
.main-header {
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: 60px;
    z-index: 1000;
}

/* الشريط الجانبي */
.sidebar-logo {
    text-align: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* تنسيق العناصر في الشريط الجانبي */
.sidebar-nav {
    padding: 10px 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav ul li {
    margin-bottom: 2px;
}

.sidebar-nav ul li a {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: rgba(255,255,255,0.8);
    border-radius: 0; /* إزالة الزوايا المدورة */
    transition: all 0.3s ease;
    text-decoration: none;
    font-size: 14px;
}

.sidebar-nav ul li a:hover, .sidebar-nav ul li a.active {
    background-color: rgba(255,255,255,0.1);
    color: white;
    border-right: 4px solid var(--secondary-color); /* إضافة خط للتمييز */
}

.sidebar-nav ul li a i {
    margin-left: 10px;
    margin-right: 0;
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* زر التبديل للشريط الجانبي */
.toggle-sidebar {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 20px;
    cursor: pointer;
    margin-left: 15px;
    display: none;
}

@media (max-width: 768px) {
    .toggle-sidebar {
        display: block;
    }
}

/* بطاقات الإحصائيات */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    text-align: center;
    transition: all 0.3s ease;
    border-top: 4px solid var(--secondary-color);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.card i {
    font-size: 36px;
    color: var(--secondary-color);
    margin-bottom: 15px;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--gray-color);
    font-weight: normal;
}

.card p {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0;
}

/* شبكة لوحة التحكم */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.dashboard-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
    height: 100%;
}

.dashboard-section h2 {
    padding: 15px 20px;
    margin: 0;
    font-size: 18px;
    border-bottom: 1px solid #eee;
    color: var(--primary-color);
    background-color: #f9f9f9;
}

.activity-list, .alerts-list, .tasks-list {
    padding: 0 20px;
    max-height: 350px;
    overflow-y: auto;
}

/* العنوان الرئيسي للصفحة */
.page-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.page-header h1 {
    font-size: 24px;
    color: var(--primary-color);
    margin: 0;
}

/* تنسيق الأنشطة */
.activity-item {
    display: flex;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.activity-icon {
    margin-left: 15px;
    margin-right: 0;
    width: 40px;
    height: 40px;
    background-color: rgba(52, 152, 219, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
}

/* قسم التنبيهات */
.alerts-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.alert {
    display: flex;
    align-items: center;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 10px;
}

.alert-high {
    background-color: rgba(231, 76, 60, 0.1);
    border-right: 4px solid var(--danger-color);
    border-left: none;
}

.alert-medium {
    background-color: rgba(241, 196, 15, 0.1);
    border-right: 4px solid var(--warning-color);
    border-left: none;
}

.alert-low {
    background-color: rgba(46, 204, 113, 0.1);
    border-right: 4px solid var(--success-color);
    border-left: none;
}

.alert-icon {
    margin-left: 15px;
    font-size: 20px;
}

/* تنسيق التنبيهات */
.alert-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background-color: white;
    border-radius: 5px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.alert-item i {
    margin-left: 15px;
    margin-right: 0;
    color: var(--warning-color);
    font-size: 18px;
}

/* قسم المهام */
.tasks-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.task {
    padding: 15px;
    border-bottom: 1px solid var(--light-color);
}

.task:last-child {
    border-bottom: none;
}

.task-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.task-details p {
    display: flex;
    align-items: center;
}

.task-details i {
    margin-left: 8px;
    color: var(--secondary-color);
}

/* تنسيق المهام */
.task-item {
    display: flex;
    padding: 15px;
    background-color: white;
    border-radius: 5px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.task-status {
    margin-left: 15px;
    margin-right: 0;
    width: 30px;
    color: var(--secondary-color);
}

/* قسم الرسوم البيانية */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.chart {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* النماذج */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--light-color);
    border-radius: 5px;
    font-size: 16px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: 0.3s;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

/* الجداول */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.table th,
.table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid var(--light-color);
}

.table th {
    background-color: var(--light-color);
    font-weight: bold;
}

.table tr:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

/* تجاوب الموقع */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
        transform: translateX(250px);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
    }
    
    .main-content.sidebar-active {
        margin-right: 250px;
    }
    
    .toggle-sidebar {
        display: block;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-cards {
        grid-template-columns: 1fr;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
}

/* الرسائل والتنبيهات */
.message {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.message-success {
    background-color: rgba(46, 204, 113, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.message-error {
    background-color: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.message-warning {
    background-color: rgba(241, 196, 15, 0.1);
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
}

/* الأزرار الإضافية */
.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

/* التحميل */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
}

.loading-spinner {
    border: 4px solid var(--light-color);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* الترويسة */
.main-header {
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: 60px;
    z-index: 1000;
}

.header-brand {
    display: flex;
    align-items: center;
}

.header-brand a {
    display: flex;
    align-items: center;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    font-size: 18px;
}

.header-brand a i {
    margin-left: 10px;
    font-size: 22px;
}

.header-actions {
    display: flex;
    align-items: center;
}

/* تنسيق التنبيهات */
.notifications {
    position: relative;
}

.notifications-toggle {
    color: var(--primary-color);
    font-size: 18px;
    text-decoration: none;
    position: relative;
    display: block;
    padding: 0 10px;
}

.badge {
    position: absolute;
    top: -5px;
    left: 0;
    background-color: var(--warning-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notifications-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 300px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
}

.notifications-dropdown.active {
    display: block;
}

.notifications-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.notifications-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--primary-color);
}

.notifications-list {
    max-height: 300px;
    overflow-y: auto;
}

.notification-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: flex-start;
}

.notification-icon {
    margin-left: 15px;
    width: 30px;
    height: 30px;
    background-color: rgba(52, 152, 219, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.notification-time {
    font-size: 12px;
    color: var(--gray-color);
}

/* النوافذ المنبثقة */
.modal {
    display: none;
    position: fixed;
    z-index: 2000; /* قيمة أعلى من السايدبار والهيدر */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    padding-top: 60px;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    width: 80%;
    max-width: 600px;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-start;
    gap: 10px;
}