/* متغيرات الألوان (مأخوذة من payments.css) */
:root {
    --primary-color: #3f51b5; /* لون أساسي - أزرق غامق */
    --secondary-color: #ff9800; /* لون ثانوي - برتقالي */
    --accent-color: #4caf50; /* لون مميز - أخضر */
    --background-color: #e8eaf6; /* خلفية خفيفة */
    --surface-color: #ffffff; /* لون أسطح البطاقات */
    --text-color-dark: #212121;
    --text-color-light: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    
    /* متغيرات التحكم في القائمة الجانبية */
    --sidebar-width-expanded: 280px;
    --sidebar-width-collapsed: 80px;
}

/* ------------------------------------------- */
/* 1. إعدادات عامة وتخطيط الجسم (Body Layout) */
/* ------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', sans-serif; /* استخدام خط Cairo */
}

body {
    direction: rtl; /* اتجاه من اليمين لليسار */
    background-color: var(--background-color);
    color: var(--text-color-dark);
    display: flex;
    min-height: 100vh;
    padding: 0; 
}

/* ------------------------------------------- */
/* 2. الرأس (Header) - نمط ثابت */
/* ------------------------------------------- */
header {
    background: var(--primary-color);
    color: var(--text-color-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    box-shadow: var(--shadow);
    z-index: 100;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 80px; 
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

#userInfo {
    display: flex;
    align-items: center;
    gap: 15px;
}

#loggedInUser {
    font-weight: 600;
    font-size: 1.1rem;
}

/* توحيد أنماط الأزرار/الروابط في الرأس */
#dashboardBtn {
    background-color: var(--secondary-color);
    color: var(--text-color-light);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: background-color 0.3s ease;
    text-decoration: none;
}

#dashboardBtn:hover {
    background-color: #e68a00; /* لون أغمق لـ secondary-color */
}

/* ------------------------------------------- */
/* 3. القائمة الجانبية (Aside) - نمط الإظهار والإخفاء */
/* ------------------------------------------- */
aside {
    background-color: var(--surface-color);
    width: var(--sidebar-width-collapsed); 
    padding: 20px 10px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    position: fixed;
    top: 80px; 
    right: 0;
    height: calc(100vh - 80px); 
    overflow-y: auto;
    z-index: 50;
    transition: width 0.3s ease; 
}

/* توسيع القائمة الجانبية عند مرور الفأرة */
aside:hover {
    width: var(--sidebar-width-expanded);
}

aside ul {
    list-style: none;
    padding: 0;
}

aside ul li {
    margin-bottom: 5px;
    overflow: hidden;
}

aside ul li a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 10px;
    color: var(--text-color-dark);
    text-decoration: none;
    font-size: 1rem;
    border-radius: 8px;
    transition: background-color 0.3s, color 0.3s;
    white-space: nowrap; 
}

/* إخفاء نص الرابط في الحالة المصغرة */
aside ul li a {
    /* تطبيق الأسلوب القديم لإخفاء النص في CSS */
    text-indent: -9999px; /* إخفاء النص */
    position: relative;
    justify-content: center; /* توسيط الأيقونة */
}
aside:hover ul li a {
    text-indent: 0; /* إظهار النص عند التوسيع */
    justify-content: flex-start; /* إعادة محاذاة النص والأيقونة */
}

aside ul li a i {
    font-size: 1.2rem;
    color: var(--primary-color);
    min-width: 30px; 
    text-indent: 0; /* ضمان رؤية الأيقونة دائماً */
    position: absolute;
    right: 15px;
}

aside:hover ul li a i {
    position: static;
}


/* نمط العنصر النشط */
aside ul li a.active {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    text-indent: 0;
}
aside ul li a.active i {
    color: var(--text-color-light);
    position: static;
}

aside ul li a:hover {
    background-color: #f1f1f1;
}

aside ul li a.active:hover {
    background-color: var(--primary-color);
}

/* ------------------------------------------- */
/* 4. المحتوى الرئيسي (Main Content) */
/* ------------------------------------------- */
main {
    margin-top: 80px; 
    margin-right: var(--sidebar-width-collapsed); 
    padding: 30px;
    flex-grow: 1;
    transition: margin-right 0.3s ease; 
    max-width: none; 
}

/* تعديل الهامش عند توسيع القائمة الجانبية */
body:hover main {
    margin-right: var(--sidebar-width-expanded);
}

/* ------------------------------------------- */
/* 5. تنسيقات البطاقات والعناصر الأخرى */
/* ------------------------------------------- */

.card {
    background-color: var(--surface-color);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.4rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

/* الأزرار العامة */
button {
    background-color: var(--accent-color); /* استخدام اللون الأخضر كزر أساسي */
    color: var(--text-color-light);
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #43a047; /* لون أخضر أغمق */
}

/* أزرار الإجراءات */
.action-btn {
    padding: 8px 15px;
    margin: 0 5px;
    font-size: 0.9rem;
}

.edit-btn {
    background-color: #17a2b8; /* لون أزرق سماوي/info */
}

.edit-btn:hover {
    background-color: #117a8b;
}

.delete-btn {
    background-color: #e74c3c;
}

.delete-btn:hover {
    background-color: #c0392b;
}

/* تنسيق البحث */
#searchUser {
    margin-bottom: 20px;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 100%;
}

/* ------------------------------------------- */
/* 6. تنسيق الجداول (Table) */
/* ------------------------------------------- */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

th {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    font-weight: 700;
    border-bottom: none;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}
tr:hover {
    background-color: #f1f1f1;
}

.editable:hover {
    background-color: #e9ecef;
    cursor: pointer;
}

.editable-input {
    padding: 8px;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
}

/* ------------------------------------------- */
/* 7. تنسيق النموذج (Form) - لإضافة وتعديل المستخدمين */
/* ------------------------------------------- */

/* تحسين تنسيق مجموعة الحقول */
.form-group {
    margin-bottom: 1.2rem;
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 15px;
}

.form-group label {
    text-align: right; /* محاذاة لليمين ليتناسب مع RTL */
    margin-bottom: 0;
    font-weight: 600;
    color: var(--primary-color);
}

/* تحسين عرض حقول الإدخال */
input, select {
    width: 100%;
    max-width: 350px; /* زيادة قليلة للعرض الأقصى */
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 1rem;
    background-color: #f8f9fa;
    transition: all 0.3s;
}

input:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(63, 81, 181, 0.25);
    background-color: var(--surface-color);
    outline: none;
}

/* تحسين تنسيق أزرار الإرسال في نموذج الإضافة */
.add-user-form button[type="submit"] {
    grid-column: 2;
    justify-self: start;
    padding: 10px 25px;
    background-color: var(--primary-color);
    margin-top: 10px;
}
.add-user-form button[type="submit"]:hover {
    background-color: #303f9f;
}


/* تحسين تنسيق رسائل الخطأ */
.error-message {
    grid-column: 2;
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 0.3rem;
    font-weight: 500;
}

/* تنسيق خاص لعناصر الـ select */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233f51b5'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 10px center; /* محاذاة لليسار في نظام RTL */
    background-size: 15px;
    padding-left: 35px; /* زيادة البادينج ليظهر السهم */
}

.note {
    grid-column: 2;
    color: #95a5a6;
    font-size: 0.8rem;
    margin-top: -5px;
    display: block;
}

/* ------------------------------------------- */
/* 8. تنسيق النافذة المنبثقة (Modal) */
/* ------------------------------------------- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-start;
}

.form-actions button:nth-child(2) {
    background-color: #95a5a6;
}

.form-actions button:nth-child(2):hover {
    background-color: #7f8c8d;
}

/* ------------------------------------------- */
/* 9. تذييل الصفحة (Footer) */
/* ------------------------------------------- */
footer {
    text-align: center;
    padding: 20px;
    color: #777;
    font-size: 14px;
    margin-top: 30px; /* تباعد كافٍ بعد المحتوى */
}


/* ------------------------------------------- */
/* 10. الاستجابة (Responsive) */
/* ------------------------------------------- */

@media (max-width: 992px) {
    /* تعطيل التخطيط الثابت والشريط الجانبي الموسع */
    header {
        position: static;
        padding: 15px 20px;
        height: auto;
    }
    aside {
        position: static;
        width: 100%;
        height: auto;
        padding: 10px 20px;
        box-shadow: none;
        width: 100% !important; 
    }
    aside:hover {
        width: 100%; 
    }
    aside ul li a {
        padding: 10px 5px; 
        text-indent: 0; /* إظهار النص */
        justify-content: flex-start;
    }
    aside ul li a i {
        position: static;
        min-width: 25px;
    }
    main {
        margin-top: 0;
        margin-right: 0;
        padding: 20px;
    }
    body:hover main {
        margin-right: 0;
    }
    
    /* تنسيق نموذج الإضافة والتعديل في شاشة الجوال */
    .form-group {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .form-group label {
        text-align: right;
        padding-right: 0;
    }
    
    input, select {
        max-width: 100%;
    }
    
    .add-user-form button[type="submit"] {
        grid-column: 1;
        width: 100%;
    }
    
    .error-message {
        grid-column: 1;
    }
    .note {
        grid-column: 1;
    }
    .form-actions {
        justify-content: center;
    }
}
/* تنسيق قسم الصلاحيات */
.full-width {
    grid-column: 1 / -1; /* لجعل العنصر يمتد على كامل عرض النموذج */
    display: block; 
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    background: #f9f9f9;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    background: white;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #eee;
}

.permission-item input[type="checkbox"] {
    width: auto;
    margin: 0;
    max-width: none;
}

.permission-item label {
    cursor: pointer;
    margin: 0;
    color: var(--text-color-dark);
    font-weight: normal;
}
/* في ملف users_style.css */

.source-selector {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-bottom: 20px;
    display: flex;
    align-items: center; /* لضمان محاذاة التسمية مع الأزرار */
}

.radio-group {
    display: flex;
    gap: 30px; /* هذه هي القيمة التي تتحكم في المسافة الأفقية بين الخيارين */
    justify-content: flex-start; /* تجعل الخيارات تبدأ من اليمين بجانب بعضها */
}

.radio-group label {
    margin-bottom: 0; /* إلغاء أي هوامش سفلية قد تعطل المحاذاة */
    display: flex;
    align-items: center;
    gap: 10px; /* المسافة بين نقطة الراديو والنص التابع لها */
    cursor: pointer;
}