/* ==================================
   متغيرات الألوان والخطوط (بنفس أسلوبك)
   ================================== */
: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;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    direction: rtl;
    background-color: var(--background-color);
    color: var(--text-color-dark);
    display: flex;
    min-height: 100vh;
}

/* ==================================
   الهيدر العلوي (نفس أسلوب payments.css)
   ================================== */
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;
}

#username {
    font-weight: 600;
    font-size: 1.1rem;
}

#logoutBtn {
    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;
}
#logoutBtn:hover {
    background-color: #e68a00;
}

/* ==================================
   الشريط الجانبي (نفس أسلوب payments.css)
   ================================== */
aside.sidebar {
    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.sidebar:hover {
    width: var(--sidebar-width-expanded); /* التوسيع عند المرور */
}

.sidebar .logo {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    padding: 15px 0;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
    white-space: nowrap;
    overflow: hidden;
    opacity: 0; /* مخفي افتراضياً */
    transition: opacity 0.2s ease 0.1s;
}
aside.sidebar:hover .logo {
    opacity: 1;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar ul li {
    margin-bottom: 5px;
    overflow: hidden;
}

.sidebar 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; 
}

/* أيقونات Font Awesome */
.sidebar ul li a i.fas {
    font-size: 1.2rem;
    color: var(--primary-color);
    min-width: 30px; /* لضمان ثبات الأيقونات */
    margin-left: 5px; /* (لضبط التوسيط في RTL) */
    text-align: center;
}

/* إخفاء النص (الذي بداخل <span>) */
.sidebar ul li a span {
    opacity: 0;
    transition: opacity 0.1s ease 0.1s;
}
aside.sidebar:hover ul li a span {
    opacity: 1;
}

.sidebar ul li a:hover,
.sidebar ul li a.active {
    background-color: var(--primary-color);
    color: var(--text-color-light);
}

.sidebar ul li a:hover i.fas,
.sidebar ul li a.active i.fas {
    color: var(--text-color-light);
}

/* ==================================
   المحتوى الرئيسي (نفس أسلوب payments.css)
   ================================== */
main.content-area {
    margin-top: 80px; /* تحت الهيدر */
    margin-right: var(--sidebar-width-collapsed); /* الهامش الأولي */
    padding: 30px;
    flex-grow: 1;
    transition: margin-right 0.3s ease;
}

/* تعديل الهامش عند توسيع القائمة */
body:has(aside.sidebar:hover) main.content-area {
    margin-right: var(--sidebar-width-expanded);
}

/* ==================================
   تنسيقات المحتوى (بطاقات، نماذج، جداول)
   ================================== */

/* البطاقات */
.card {
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}
.card-header h2 {
    font-size: 1.4rem;
    color: var(--primary-color);
}
.header-search {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    width: 300px;
}

/* الأزرار */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary { background-color: var(--primary-color); color: var(--text-color-light); }
.btn-primary:hover { background-color: #303f9f; }
.btn-danger { background-color: #f44336; color: var(--text-color-light); }
.btn-danger:hover { background-color: #d32f2f; }

/* النماذج */
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #555;
}
.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}
.form-group select.hidden {
    display: none;
}
.form-message {
    margin-top: 10px;
    font-size: 0.9rem;
}

/* الجداول */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    font-size: 0.95rem;
}
.data-table th {
    background-color: #f9f9f9;
    color: #333;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
}
.data-table tbody tr:nth-child(even) {
    background-color: #fcfcfc;
}
.data-table tbody tr:hover {
    background-color: #f1f5f9;
}
.data-table .text-center {
    text-align: center;
}

/* ==================================
   التوافق مع الشاشات الصغيرة
   ================================== */
@media (max-width: 992px) {
    header {
        position: static;
        padding: 15px 20px;
        height: auto;
    }
    aside.sidebar {
        position: static;
        width: 100% !important; /* إلغاء التضييق */
        height: auto;
        padding: 10px 20px;
        box-shadow: none;
    }
    aside.sidebar:hover {
        width: 100% !important;
    }
    .sidebar .logo {
        opacity: 1;
        text-align: left;
        border: none;
    }
    .sidebar ul {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }
    .sidebar ul li a span {
        opacity: 1; /* إظهار النص دائماً */
    }
    .sidebar ul li a {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    main.content-area {
        margin-top: 0;
        margin-right: 0;
        padding: 20px;
    }
    body:has(aside.sidebar:hover) main.content-area {
        margin-right: 0;
    }
    
    .form-grid-3 {
        grid-template-columns: 1fr; /* عمود واحد في الشاشات الصغيرة */
    }
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .header-search {
        width: 100%;
    }
}