/* ملف CSS الرئيسي لنظام إدارة الموارد البشرية */

/* الخطوط العربية */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&display=swap');

/* المتغيرات العامة */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-width: 280px;
    --header-height: 70px;
    --transition-speed: 0.3s;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* إعدادات عامة */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    direction: rtl;
    text-align: right;
    background-color: var(--light-color);
    color: var(--dark-color);
    line-height: 1.6;
    overflow-x: hidden;
    /* New: Flexbox for main layout below header */
    display: flex;
    flex-direction: column; /* Stacks header on top, then main content area */
    min-height: 100vh;
}

/* الهيدر */
.header {
    position: fixed; /* Keep header fixed at the top */
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    z-index: 1000;
    box-shadow: var(--box-shadow);
    transition: all var(--transition-speed) ease;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    font-size: 28px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-menu {
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) ease;
}

.user-info:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* New: Wrapper for sidebar and main-content to enable flex layout */
.wrapper {
    display: flex;
    flex: 1; /* Allows it to take up remaining vertical space */
    margin-top: var(--header-height); /* Push content below the fixed header */
}

/* القائمة الجانبية */
.sidebar {
    position: fixed; /* Make the sidebar fixed */
    top: var(--header-height); /* Position it below the header */
    right: 0; /* Align to the right (RTL layout) */
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height)); /* Take full height below header */
    background: white;
    box-shadow: var(--box-shadow);
    z-index: 999; /* Ensure it's above main content but below header */
    overflow-y: auto;
    transition: transform var(--transition-speed) ease; /* For sliding effect on small screens */

}

.sidebar.active {
    transform: translateX(0); /* For smaller screens when activated */
}

/* Keep the rest of .sidebar styling */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: var(--light-color);
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

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

.menu-item {
    border-bottom: 1px solid #f0f0f0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: var(--dark-color);
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    position: relative;
}

.menu-link:hover {
    background-color: var(--light-color);
    color: var(--secondary-color);
    padding-right: 25px;
}

.menu-link.active {
    background-color: var(--secondary-color);
    color: white;
}

.menu-link.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-color);
}

.menu-icon {
    margin-left: 12px;
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.menu-text {
    font-weight: 500;
}

/* المحتوى الرئيسي */
.main-content {
    flex: 1; /* Allow main content to take up remaining width */
    padding: 0; /* Keep padding flexible, can add to inner container */
    transition: margin-right var(--transition-speed) ease;
    min-height: calc(100vh - var(--header-height)); /* Ensure it fills remaining vertical space */
    /* Removed margin-top as it's handled by .wrapper */
    margin-right: var(--sidebar-width); /* Default margin for larger screens */
}

.main-content.sidebar-open {
    margin-right: var(--sidebar-width); /* This class is now redundant for desktop, useful for mobile */
}

/* صورة الهيرو */
.hero-section {
    position: relative;
    height: 400px;
    background: linear-gradient(135deg, #fff, var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../images/logo-2.png');
    background-size: contain; /* تأكد من أن الصورة بالكامل ظاهرة */
    background-position: center; /* ضع الصورة في المنتصف */
    background-repeat: no-repeat; /* منع تكرار الصورة */
}

/* عندما يكون عرض الشاشة 768px أو أقل */
@media (max-width: 768px) {
    .hero-background {
        background-size: contain; /* تعديل الحجم ليظهر بالكامل */
        background-repeat: no-repeat; /* منع تكرار الصورة */
    }
}

.hero-content {
    position: relative;
    text-align: center;
    color: white;
    z-index: 2;
}

.hero-title {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.hero-subtitle {
    font-size: 20px;
    font-weight: 400;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* منطقة المحتوى */
.content-area {
    padding: 30px;
}

.page-header {
    margin-bottom: 30px;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.page-subtitle {
    color: #666;
    font-size: 16px;
}

/* البطاقات */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.card-header {
    padding: 20px;
    background: var(--light-color);
    border-bottom: 1px solid #eee;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* الأزرار */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-align: center;
}

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

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

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

.btn-success:hover {
    background: #229954;
    transform: translateY(-1px);
}

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

.btn-warning:hover {
    background: #e67e22;
    transform: translateY(-1px);
}

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

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

/* الجداول */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.table {
    width: 100%;
    background: white;
    border-collapse: collapse;
    margin: 0;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid #eee;
}

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

.table tbody tr:hover {
    background: #f8f9fa;
}

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

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
    transition: all var(--transition-speed) ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* التنبيهات */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-warning {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.alert-danger {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-info {
    background: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

/* خلفية التراكب */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-speed) ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* الاستجابة  اظهار واخفاء زر االسايدبار للشاشات */
@media (max-width: 2000.98px) { /* Adjusted breakpoint for better mobile handling */
    .sidebar {
        width: var(--sidebar-width); /* Maintain width for consistency */
        transform: translateX(100%); /* Hidden by default on small screens */
        position: fixed; /* Keep it fixed for sliding */
    }

    .sidebar.active {
        transform: translateX(0); /* Visible when active */
    }
    
    .main-content {
         padding-top: 60px; /* ✅ تمت الإضافة: مسافة بادئة من الأعلى للمحتوى */
        margin-right: 0; /* Remove margin for main content on small screens */
    }
    
    .hero-title {
        font-size: 32px;
    }
    
    .hero-subtitle {
        font-size: 16px;
    }
    
    .content-area {
        padding: 20px 15px;
    }
    
    .header-content {
        padding: 0 15px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .user-info span {
        display: none;
    }
}

@media (min-width: 2000px) {
    .sidebar {
        position: fixed; /* Still fixed, but always visible */
        transform: translateX(0); /* Always visible */
        /* Removed relative/auto height - keep fixed positioning for consistency */
        border-left: 1px solid #eee; /* Maintain visual separation */
    }
    
/* المحتوى الرئيسي */
.main-content {
    flex: 1; /* Allow main content to take up remaining width */
    padding-top: 60px; /* ✅ تمت الإضافة: مسافة بادئة من الأعلى للمحتوى */
    padding-left: 0; /* لضمان عدم وجود مسافات بادئة أفقية إذا لم تكن مطلوبة بشكل صريح */
    padding-right: 0; /* لضمان عدم وجود مسافات بادئة أفقية إذا لم تكن مطلوبة بشكل صريح */
    padding-bottom: 0; /* لضمان عدم وجود مسافات بادئة سفلية إذا لم تكن مطلوبة بشكل صريح */
    transition: margin-right var(--transition-speed) ease;
    min-height: calc(100vh - var(--header-height)); /* Ensure it fills remaining vertical space */
    margin-right: var(--sidebar-width); /* Default margin for larger screens */
}
    
    .sidebar-toggle {
        display: none; /* Hide toggle button on large screens */
    }
    
    .sidebar-overlay {
        display: none; /* Hide overlay on large screens */
    }
}

/* تحسينات إضافية */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* تحسينات للطباعة */
@media print {
    .header,
    .sidebar,
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        margin-top: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}