/*
// *******************************************************************
// MARKS INPUT CSS - دمج الأنماط الأساسية والخاصة بالجداول
// *******************************************************************
*/

/* متغيرات الألوان (مأخوذة من 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;
}

/* إعدادات عامة */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* تأكد من ربط خط Cairo في ملف HTML أو استبدله بخط متاح */
    /* font-family: 'Cairo', sans-serif; */
    font-family: Tahoma, sans-serif;
}

body {
    direction: rtl;
    background-color: var(--background-color);
    color: var(--text-color-dark);
    display: flex;
    min-height: 100vh;
}

/* 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;
}

#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;
}

#logoutBtn:hover {
    background-color: #e68a00;
}

/* ------------------------------------------- */
/* Sidebar (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 span {
    opacity: 0;
    transition: opacity 0.1s ease 0.1s; 
}
aside:hover ul li a span {
    opacity: 1;
}

aside ul li a i {
    font-size: 1.2rem;
    color: var(--primary-color);
    min-width: 30px;
}

aside ul li a:hover,
aside ul li a.active {
    background-color: var(--primary-color);
    color: var(--text-color-light);
}

aside ul li a:hover i,
aside ul li a.active i {
    color: var(--text-color-light);
}


/* ------------------------------------------- */
/* Main Content and Layout */
/* ------------------------------------------- */
main {
    margin-top: 80px; 
    margin-right: var(--sidebar-width-collapsed);
    padding: 30px;
    flex-grow: 1;
    transition: margin-right 0.3s ease;
    background-color: var(--background-color); /* تأكيد الخلفية */
}

/* تعديل الهامش عند توسيع القائمة الجانبية */
body:hover main {
    margin-right: var(--sidebar-width-expanded);
}

.controls-section {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.filter-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-color-dark);
}

.filter-item select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    min-width: 180px;
    font-size: 1rem;
}

/* الأزرار العامة */
.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-secondary { background-color: #6c757d; color: var(--text-color-light); }
.btn-secondary:hover { background-color: #5a6268; }

/* ------------------------------------------- */
/* Data Table - تنسيقات الجداول (مأخوذة من payments.css) */
/* ------------------------------------------- */

.data-table { 
    width: 100%; 
    border-collapse: collapse; 
    background-color: var(--surface-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border-radius: 8px;
    overflow: hidden; /* لحفظ حدود الجدول */
}

.data-table th, .data-table td { 
    padding: 10px; 
    border: 1px solid var(--border-color); 
    text-align: right; 
    font-size: 0.9em; 
    vertical-align: middle;
}

.data-table th { 
    background-color: var(--primary-color); 
    color: var(--text-color-light); 
    font-weight: bold; 
    text-align: center;
}
.data-table tbody tr:nth-child(even) { background-color: #f9f9f9; }


/* ------------------------------------------- */
/* MARK INPUT SPECIFIC STYLES - الأنماط الخاصة بصفحة العلامات */
/* ------------------------------------------- */

/* تنسيقات حقل إدخال العلامة */
.mark-input {
    width: 100%; /* استخدام عرض العمود كاملاً */
    padding: 5px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 60px; /* لضمان ألا يضيق كثيراً */
}

/* ألوان حالة الحفظ */
.mark-input.saving {
    background-color: #fff3cd; /* أصفر للحفظ */
    border-color: #ffeaa7;
}

.mark-input.saved-success {
    background-color: #d4edda; /* أخضر فاتح للنجاح */
    border-color: #c3e6cb;
}

.mark-input.saved-error {
    background-color: #f8d7da; /* أحمر فاتح للخطأ */
    border-color: #f5c6cb;
}

.final-mark {
    font-weight: bold;
    color: #28a745;
    text-align: center;
    display: block; /* لضمان توسيط النص */
}

/* -------------------- */
/* رؤوس الجدول الديناميكية */
/* -------------------- */

#mainHeaders th {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    font-weight: bold;
    text-align: center;
}

/* رأس المادة (الصف الأول من الرؤوس) */
.subject-header {
    background-color: #007bff; /* أزرق مختلف قليلاً */
    color: white;
    font-weight: bold;
    text-align: center;
}

/* الصف لرؤوس مكونات العلامات (الصف الثاني) */
#subTermHeaders th {
    background-color: #e9ecef;
    font-size: 0.9em;
    text-align: center;
    padding: 8px 4px;
    white-space: nowrap;
    color: var(--text-color-dark);
    border-left: 1px solid var(--border-color);
}

/* تنسيق خاص لعمود المحصلة النهائية */
.final-mark-header {
    background-color: var(--accent-color); /* أخضر */
    color: white;
    font-weight: bold;
}

/* -------------------- */
/* تنسيقات تلوين الصفوف للنتائج */
/* -------------------- */
.highest-mark-row td {
    background-color: #e6ffed !important; /* لون فاتح للأعلى علامة */
    font-weight: bold;
}

.lowest-mark-row td {
    background-color: #ffe6e6 !important; /* لون فاتح للأدنى علامة */
}

/* -------------------- */
/* قسم الإجراءات (تصدير/طباعة) */
/* -------------------- */
.actions-section {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    padding: 15px;
    background-color: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    justify-content: flex-start;
}

/* -------------------- */
/* رسائل الحالة والتحميل */
/* -------------------- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-data-message {
    text-align: center;
    padding: 40px;
    background-color: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: #6c757d;
    font-size: 1.1rem;
    margin-top: 25px;
}
.no-data-message i {
    font-size: 2.5rem;
    color: #ffc107;
    margin-bottom: 10px;
}

/* ------------------------------------------- */
/* Footer */
/* ------------------------------------------- */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #343a40;
    color: #fff;
    text-align: center;
    padding: 10px 0;
    font-size: 0.9rem;
    z-index: 90;
}


/* ------------------------------------------- */
/* Responsive Design */
/* ------------------------------------------- */
@media (max-width: 1200px) {
    .filter-group {
        display: block;
    }
    .filter-item {
        margin-bottom: 15px;
    }
}

@media (max-width: 768px) {
    header {
        position: static;
        flex-direction: column;
        height: auto;
        padding: 15px;
        text-align: center;
    }
    #userInfo {
        margin-top: 10px;
        width: 100%;
        justify-content: space-around;
    }
    aside {
        position: static;
        width: 100%;
        height: auto;
        padding: 10px 20px;
        box-shadow: none;
    }
    aside:hover {
        width: 100%; 
    }
    aside ul li a {
        padding: 10px;
        justify-content: center;
    }
    aside ul li a span {
        display: none;
    }
    aside ul li a i {
        min-width: auto;
    }
    main {
        margin-top: 0;
        margin-right: 0;
        padding: 15px;
    }
    body:hover main {
        margin-right: 0;
    }
    .filter-group {
        gap: 10px;
    }
    .actions-section {
        flex-direction: column;
        gap: 15px;
    }
    .data-table {
        overflow-x: auto; /* السماح بالتمرير الأفقي للجداول الكبيرة */
        display: block;
        width: 100%;
    }
}