/* --- استيراد خط Cairo --- */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

/* --- المتغيرات اللونية (لتسهيل التعديل مستقبلاً) --- */
:root {
    --primary-color: #2c3e50;    /* كحلي غامق للهيدر */
    --secondary-color: #3498db;  /* أزرق فاتح للتفاعل */
    --bg-color: #f4f7f6;         /* لون خلفية الصفحة */
    --card-bg: #ffffff;          /* لون خلفية البطاقة */
    --text-color: #333333;       /* لون النص */
    --danger-color: #e74c3c;     /* لون زر الخروج */
    --success-color: #27ae60;    /* لون زر الحفظ */
    --border-radius: 8px;
}

/* --- الإعدادات العامة --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: 'Cairo', Tahoma, sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-color); 
    direction: rtl; 
}

/* --- الشريط العلوي (Navbar) الموحد --- */
.navbar {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 40px;
    padding-top: 30px !important;    
    padding-bottom: 30px !important; 
    display: flex !important;
    justify-content: space-between !important; 
    align-items: center !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: relative !important;   
    top: 0;
    z-index: 1000;
    overflow: visible !important;  
}

.navbar-logo {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important; 
    height: 180px !important; 
    width: auto !important;
    object-fit: contain !important;
    z-index: 9999 !important; 
    pointer-events: none !important; 
}

.navbar h2 { font-size: 22px; margin: 0; font-weight: 700; }

/* 🎯 التعديل الأساسي: تنزيل القوائم عند مستوى الخط الأصفر تماماً */
.navbar-links { 
    display: flex; 
    gap: 10px !important; 
    align-items: center; 
    align-self: flex-end !important; /* يربط القوائم بالحافة السفلية للـ Navbar */
    transform: translateY(18px) !important; /* ينزل القوائم بدقة فوق الخط الأصفر مباشرة */
}

.navbar-links a { 
    color: #bdc3c7; 
    text-decoration: none; 
    padding: 6px 10px !important; 
    border-radius: 5px; 
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap !important;
    transition: all 0.3s ease; 
}
.navbar-links a:hover { background-color: rgba(255, 255, 255, 0.1); color: white; }
.navbar-links a.logout { color: var(--danger-color); }
.navbar-links a.logout:hover { background-color: rgba(231, 76, 60, 0.1); }

/* --- الحاوية الرئيسية للمحتوى --- */
.main-container { 
    max-width: 1000px; 
    margin: 40px auto; 
    padding: 0 20px; 
}
.card { 
    background: var(--card-bg); 
    padding: 40px; 
    border-radius: var(--border-radius); 
    box-shadow: 0 5px 20px rgba(0,0,0,0.05); 
}
h3 { color: var(--primary-color); border-bottom: 2px solid #eee; padding-bottom: 12px; margin-bottom: 25px; }

/* --- تصميم النماذج والحقول --- */
.form-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 20px;}
.form-group { flex: 1; min-width: 250px; }
label { display: block; margin-bottom: 8px; font-weight: 600; color: #34495e; font-size: 15px; }
select, input { 
    width: 100%; padding: 12px; margin-bottom: 15px; 
    border: 1px solid #dcdde1; border-radius: 6px; 
    font-family: inherit; font-size: 14px; 
    transition: border-color 0.3s, box-shadow 0.3s; 
}
select:focus, input:focus { border-color: var(--secondary-color); outline: none; box-shadow: 0 0 5px rgba(52, 152, 219, 0.3); }

/* --- تصميم شبكة الحصص --- */
.classes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 20px; }
.class-box { 
    border: 1px solid #eee; padding: 20px; 
    border-radius: var(--border-radius); 
    background-color: #fafbfc; 
    transition: transform 0.2s, box-shadow 0.2s; 
}
.class-box:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.08); }
.class-box label { color: var(--primary-color); }

/* --- زر الحفظ --- */
button { 
    width: 100%; padding: 16px; background-color: var(--success-color); 
    color: white; border: none; border-radius: 6px; 
    margin-top: 30px; cursor: pointer; font-size: 18px; 
    font-weight: bold; font-family: inherit; 
    transition: background 0.3s, transform 0.1s; 

    width: fit-content !important;   
    padding: 6px 6px !important;     
    white-space: nowrap !important;  
    display: inline-block !important;
}

button:hover { background-color: #219150; }
button:active { transform: scale(0.98); }

/* حاوية القائمة المنسدلة */
.dropdown-container {
    position: relative;
    display: inline-block;
}

/* القائمة المنسدلة */
.dropdown-menu {
    display: none;
    position: absolute;
    background-color: #ffffff !important;
    min-width: 160px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.2) !important;
    z-index: 9999 !important;
    border-radius: 6px;
    top: 100%;
    right: 0;
    margin-top: 2px;
    padding: 0;
}

/* جسر لمنع اختفاء القائمة */
.dropdown-menu::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
}

/* روابط القائمة المنسدلة من الداخل */
.dropdown-menu a {
    color: #2c3e50 !important;
    padding: 12px 16px !important;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid #f1f1f1 !important;
    font-size: 0.95rem;
    transition: background 0.3s;
}

.dropdown-menu a:last-child {
    border-bottom: none !important;
}

.dropdown-menu a:hover {
    background-color: #f8f9fa;
    color: #3498db !important;
}

.dropdown-container:hover .dropdown-menu {
    display: block;
}

/* تنسيق النافذة الرئيسية */
.custom-modal {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  direction: rtl;
}

/* رأس النافذة */
.modal-header {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.close-btn:hover {
  opacity: 1;
}

/* جسم النافذة */
.modal-body {
  padding: 24px 20px 16px 20px;
}

/* منطقة السحب والإفلات */
.drop-zone {
  display: block;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  background-color: #f8fafc;
  cursor: pointer;
  transition: all 0.25s ease;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: #3b82f6;
  background-color: #eff6ff;
}

.upload-icon {
  color: #3b82f6;
  margin-bottom: 10px;
}

.drop-title {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
  color: #334155;
  font-weight: 500;
}

.drop-title span {
  color: #2563eb;
  text-decoration: underline;
  font-weight: 600;
}

.drop-hint {
  margin: 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* مربع اسم الملف المختار */
.file-info-box {
  margin-top: 14px;
  padding: 10px 14px;
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #166534;
  font-size: 0.9rem;
}

.file-name {
  flex-grow: 1;
  margin: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.remove-file {
  cursor: pointer;
  font-size: 1.2rem;
  color: #dc2626;
  font-weight: bold;
}

/* أسفل النافذة والزر */
.modal-footer {
  padding: 0 20px 20px 20px;
}

.btn-submit {
  width: 100%;
  padding: 12px;
  background-color: #10b981;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-submit:hover {
  background-color: #059669;
}

.btn-submit:active {
  transform: scale(0.99);
}

/* ==========================================
   📱 تنسيقات الاستجابة مع الشاشات الصغيرة والجوال
   ========================================== */
@media (max-width: 768px) {
    h2 {
        font-size: 1.25rem !important;
    }
    
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .main-card, .summary-card {
        padding: 15px !important;
        margin-bottom: 15px;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table th, .table td {
        font-size: 10px !important;
        padding: 4px 2px !important;
        white-space: nowrap;
    }

    .summary-card .d-flex {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .btn-save, #btnClear {
        width: 100% !important;
    }
}

/* تنسيق زر القائمة للموبايل */
.menu-toggle, #menuToggle {
    display: none !important;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
}

/* 📱 قواعد الشاشات الصغيرة */
@media (max-width: 768px) {
    .navbar {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 40px;
    padding-top: 50px !important;    /* 👈 قَلِّل هذا الرقم لتصغير الارتفاع أو زِده للتكبير */
    padding-bottom: 50px !important; /* 👈 خليه مساوي للرقم العلوي لتتنسق العناصر */
    /* ... باقي الأكواد كما هي */
}
  .navbar {
    background-color: var(--primary-color);
    color: white;
    
    /* 🎯 حدد الارتفاع الأدنى للشريط هنا مباشرة */
    min-height: 70px !important; /* يمكنك تجربة 60px أو 100px للتأكد من التغيير */
    
    padding: 10px 40px !important; /* تقليل الحشوة لتلائم الارتفاع الجديد */
    display: flex !important;
    justify-content: space-between !important; 
    align-items: center !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: relative !important;   
    top: 0;
    z-index: 1000;
    overflow: visible !important;  
}

    #schoolName {
        font-size: 0.95rem !important;
    }

    .menu-toggle, #menuToggle {
        display: block !important;
    }

    .navbar-links {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 6px !important;
        margin-top: 10px !important;
        transform: none !important; /* إلغاء التنزيل على الجوال لتبقى منظمة رأسيّاً */
        align-self: stretch !important;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }

    .navbar-links.active {
        display: flex;
    }

    .navbar-links a {
        width: 100%;
        text-align: left;
        padding: 8px !important;
        background-color: rgba(255, 255, 255, 0.08);
        border-radius: 6px;
    }

    .dropdown-container {
        width: 100%;
        text-align: center;
    }

    .dropdown-menu {
        position: static !important;
        width: 100%;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.2);
        margin-top: 4px;
        border-radius: 6px;
    }
}
/* إضافة تنعيم للحركة على كل البطاقات */
.main-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.main-card:hover {
  transform: scale(1.03); /* تكبير البطاقة بنسبة 3% */
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15) !important;
  cursor: pointer;
}