/* --- 1. الإعدادات العامة والخطوط --- */
@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@400;700&family=Cairo:wght@600;700&display=swap');

:root {
    --logo-blue: #1b4370;
    --logo-blue-dark: #0f172a;
    --logo-teal: #36a1a1;
    --logo-green: #6ca935;
    --logo-gold: #fbc008;
    --logo-red: #ef4444;
    --bg-light: #f8fafc;
    --border-color: #e2e8f0;
    --bg-gradient: linear-gradient(135deg, #1b4370 0%, #36a1a1 100%);
}

* { box-sizing: border-box; }

body {
    margin: 0; padding: 0;
    font-family: 'Almarai', 'Cairo', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex; flex-direction: column;
    direction: rtl;
}

/* --- 2. الهيدر والفوتر (Header & Footer) --- */
header {
    width: 100%; background: rgba(255, 255, 255, 0.98); margin-bottom: 5px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); border-bottom: 5px solid var(--logo-gold);
}

.header-container {
    display: flex; justify-content: space-between; align-items: center; 
    max-width: 1300px; margin: 0 auto; padding: 15px 25px; gap: 15px; text-align: center;
    flex-wrap: wrap; /* للسماح بالتكيف مع الهواتف */
}

.header-section {
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.header-section img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    margin-bottom: 5px;
}

/* ضبط أحجام اللوغوهات بدقة */
.header-section:first-child img, 
.header-section:last-child img {
    max-height: 80px; 
}

.center-section img {
    max-height: 100px; /* لوغو الوزارة المستطيل */
    width: auto;
}

.header-section h2, .header-section h3 { font-size: 0.9rem; margin: 0; color: var(--logo-blue); }
.center-section h1 { font-family: 'Cairo', sans-serif; font-size: 1.4rem; margin: 5px 0; color: var(--logo-blue); text-shadow: 2px 3px 6px rgba(0, 0, 0, 0.2); }

footer {
    margin-top: auto; width: 100%; padding: 25px; border-top: 5px solid var(--logo-gold);
    background: linear-gradient(to right, rgba(13, 38, 68, 0.9), rgba(20, 50, 90, 0.95));
    color: white; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
footer img { height: 45px; background: white; padding: 5px 15px; border-radius: 10px; }

/* --- 3. التوزيع الرئيسي (Panels & Wrappers) --- */
#wrapper, #mainWrapper {
    display: flex; gap: 20px; margin: 25px auto;
    max-width: 1580px; width: 95%; flex-grow: 1;
}

#leftPanel, #sidePanel { width: 250px; flex-shrink: 0; display: flex; flex-direction: column; gap: 15px; }

.panel-box, .side-box, .stat-box {
    background: white; padding: 18px; border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08); border: 1px solid var(--border-color);
    border-top: 4px solid var(--logo-teal); text-align: center;
}

/* --- 4. الأزرار (Buttons) --- */
.btn-base, .btn-action, .btn-game, .btn, .tablinks {
    text-decoration: none; display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 12px; border-radius: 12px; font-weight: bold;
    transition: all 0.3s ease; border: none; cursor: pointer; width: 100%; color: white;
}

.btn-base:hover, .btn-action:hover, .btn:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); filter: brightness(1.1); }

.home-btn { background: var(--logo-gold) !important; color: var(--logo-blue) !important; }
.btn-primary, .btn-add { background: var(--logo-blue); }
.btn-teal { background: var(--logo-teal); }
.btn-export { background: var(--logo-green); }
.btn-danger, .btn-reset { background: var(--logo-red); }
.btn-secondary { background: #475569; }

/* --- 5. حقول الإدخال (Inputs & Forms) --- */
input[type="text"], input[type="number"], input[type="date"], select, .m-input {
    /*width: 100%;*/ padding: 8px; border-radius: 10px; margin-top: 8px;
    border: 1px solid var(--logo-teal); outline: none;
    font-family: inherit; background: var(--bg-light);
    transition: border-color 0.3s ease;
}

input:focus, select:focus { border-color: var(--logo-gold); box-shadow: 0 0 0 3px rgba(251, 192, 8, 0.1); }

/* --- 6. الجداول (Tables) --- */
#tableArea, #tableContainer {
    flex-grow: 1; background: white; padding: 10px; border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15); overflow-x: auto;
}

table, .m-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    border-radius: 12px; overflow: hidden; border: 1px solid var(--border-color);
}

th { background: linear-gradient(180deg, #1b4370 0%, #36a1a1 100%); color: white; padding: 15px; font-size: 14px; }
td { padding: 12px; border: 1px solid var(--border-color); text-align: center; font-weight: bold; font-size: 13px; }

.student-name-col { text-align: right !important; background: #fdfdfd !important; position: sticky; right: 0; z-index: 10; border-left: 3px solid var(--logo-gold) !important; }

/* --- 7. النوافذ المنبثقة (Modals) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75); display: none; align-items: center;
    justify-content: center; z-index: 1000; backdrop-filter: blur(4px);
}
.modal-content { background: white; padding: 30px; border-radius: 20px; width: 90%; max-width: 550px; position: relative; }

/* --- 8. التجاوب (Responsive Design) --- */

/*@media screen and (max-width: 992px) {
    #wrapper, #mainWrapper { flex-direction: column; margin: 15px auto; }
    #leftPanel, #sidePanel { width: 100%; flex-direction: row; flex-wrap: wrap; justify-content: center; }
    #leftPanel .btn-base, .btn-action { flex: 1; min-width: 140px; width: auto; }
}*/

@media screen and (max-width: 768px) {
    .header-container { flex-direction: column; gap: 20px; padding: 20px 15px; }
    .header-section { width: 100%; border-bottom: 1px dashed #eee; padding-bottom: 10px; }
    .header-section:last-child { border-bottom: none; }
    .header-section img { max-height: 70px; }
    .center-section img { max-height: 80px; }
    .center-section h1 { font-size: 1.3rem; }
    
    table { font-size: 11px; }
    td, th { padding: 8px 4px; }
}

/* --- 9. الطباعة (Print) --- */
@media print {
    .no-print { display: none !important; }
    #wrapper, #mainWrapper { margin: 0; width: 100%; display: block; }
    #tableArea, #tableContainer { box-shadow: none; border: 1px solid #ccc; padding: 0; }
    body { background: white !important; }
}


/* بطاقة المستخدم الزجاجية */
.user-info-box {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 22px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.user-avatar {
    font-size: 2.5rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(251, 192, 8, 0.3)); /* توهج ذهبي خفيف */
}

.user-name {
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    display: block;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.user-role {
    color: var(--logo-gold);
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(251, 192, 8, 0.1);
    padding: 2px 12px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 5px;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px; /* مسافة بين الأيقونة والنص */
    margin-top: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05); /* زجاجي شفاف */
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-logout i {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7); /* الأيقونة باهتة قليلاً لتبرز عند التمرير */
    transition: 0.3s;
}

/* تأثير التمرير (Hover) */
.btn-logout:hover {
    background: #ef4444; /* أحمر صريح ونظيف */
    color: white;
    border-color: #ef4444;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.btn-logout:hover i {
    color: white;
    transform: translateX(-3px); /* حركة خفيفة للأيقونة لليسار توحي بالخروج */
}

/* لمنع انكسار التصميم في الشاشات الصغيرة */
.btn-logout span {
    white-space: nowrap;
}

/* الحاوية القابلة للطي - الحالة المغلقة */
/* تنسيق العنوان داخل رأس القائمة */
.menu-header .menu-title {
    color: #ffffff; /* لون أبيض ناصع */
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); /* ظل خفيف لزيادة الوضوح */
    pointer-events: none; /* لضمان أن الضغط يمر عبر النص إلى الحاوية */
}

/* السهم الذهبي بجانب العنوان */
#menu-arrow {
    color: var(--logo-gold);
    font-size: 0.85rem;
    filter: drop-shadow(0 0 5px rgba(251, 192, 8, 0.4));
}
.menu-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 5px;
}

/* الحالة المفتوحة */
.menu-content.show {
    max-height: 1000px; /* القيمة كافية لكل الروابط */
    opacity: 1;
    margin-top: 15px;
    padding-bottom: 20px;
}


/* رأس القائمة الزجاجي */
.menu-header {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px 18px;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.3s;
}

.menu-header:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--logo-teal);
}

/* الروابط الداخلية */
.menu-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 3px solid transparent;
}

.menu-item:hover {
    background: rgba(54, 161, 161, 0.15);
    color: #fff;
    transform: translateX(-6px);
    border-right: 3px solid var(--logo-green);
}

/* تنسيق الأيقونات (i) داخل عناصر القائمة - الحالة العادية */
.menu-item i {
    width: 25px; /* عرض موحد للأيقونات لتصطف الرابط بانتظام */
    font-size: 1.15rem; /* تكبير بسيط لحجم الأيقونة */
    margin-left: 12px;
    text-align: center;
    transition: 0.3s;
    
    /* التعديل الجوهري: جعل الأيقونة بيضاء مع توهج خفيف لبروزها */
    color: #ffffff; 
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.4));
}

/* تأثير الأيقونة عند تمرير الماوس (Hover) */
.menu-item:hover i {
    color: var(--logo-gold); /* الأيقونة تتحول للذهبي عند التفاعل */
    filter: drop-shadow(0 0 8px rgba(251, 192, 8, 0.6)); /* توهج ذهبي أقوى */
    transform: scale(1.1); /* تكبير الأيقونة قليلاً عند التفاعل */
}

/* العنصر النشط */
.menu-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--logo-gold);
    border-right: 3px solid var(--logo-gold);
}

/* الأيقونة في العنصر النشط (Active) - تظل ذهبية بوضوح */
.menu-item.active i {
    color: var(--logo-gold);
    filter: drop-shadow(0 0 6px rgba(251, 192, 8, 0.5));
}