/* متغيرات الألوان */
: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);
}

/* إعدادات عامة */
* {
    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;
    flex-direction: column;
    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;
}

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: 280px;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    overflow-y: auto;
    transition: right 0.3s ease;
}

aside ul {
    list-style: none;
    padding: 0;
}

aside ul li {
    margin-bottom: 10px;
}

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;
}

aside ul li a i {
    font-size: 1.2rem;
    color: var(--primary-color);
}

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 */
main {
    margin-right: 280px;
    padding: 30px;
    flex-grow: 1;
}

/* Sections */
.student-management-controls,
.student-list {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

/* Control Bar */
.student-management-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.search-bar {
    display: flex;
    gap: 10px;
    flex-grow: 1;
    margin-left: 20px;
}

#studentSearch {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

#studentSearch:focus {
    outline: none;
    border-color: var(--primary-color);
}

#searchBtn {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#searchBtn:hover {
    background-color: #303f9f;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-color-light);
}

.btn-primary:hover {
    background-color: #303f9f;
}

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-secondary:hover {
    background-color: var(--primary-color);
    color: var(--text-color-light);
}

/* Student Table */
.student-list h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--secondary-color);
    display: inline-block;
    padding-bottom: 5px;
}

#studentsTable {
    width: 100%;
    border-collapse: collapse;
}

#studentsTable th,
#studentsTable td {
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

#studentsTable th {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    font-weight: 600;
}

#studentsTable tbody tr:hover {
    background-color: #f5f5f5;
}

.actions .btn-action {
    background: none;
    border: none;
    cursor: pointer;
    margin: 0 5px;
    font-size: 1rem;
    color: var(--primary-color);
    transition: color 0.3s;
}

.actions .btn-action:hover {
    color: var(--accent-color);
}

.view-details-link {
    font-size: 1.2rem;
    color: var(--secondary-color);
    transition: color 0.3s;
}

.view-details-link:hover {
    color: var(--primary-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow);
    position: relative;
    text-align: right;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.close-btn {
    color: #aaa;
    float: left;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-color-dark);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-family: 'Cairo', sans-serif;
}

/* Footer */
footer {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    text-align: center;
}
/* إحصائيات سريعة */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    border-right: 4px solid var(--primary-color);
}

.stat-card:nth-child(2) { border-right-color: var(--accent-color); }
.stat-card:nth-child(3) { border-right-color: var(--secondary-color); }
.stat-card:nth-child(4) { border-right-color: #9c27b0; }

.stat-icon {
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2em;
}

.stat-card:nth-child(2) .stat-icon { background: var(--accent-color); }
.stat-card:nth-child(3) .stat-icon { background: var(--secondary-color); }
.stat-card:nth-child(4) .stat-icon { background: #9c27b0; }

.stat-number {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--text-color-dark);
}

.stat-label {
    color: #666;
    font-size: 0.9em;
}

/* قسم الفلاتر */
.filters-section {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.filter-group {
    display: flex;
    gap: 15px;
    align-items: end;
    flex-wrap: wrap;
}

.filter-item {
    flex: 1;
    min-width: 180px;
}

.filter-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-color-dark);
}

.filter-item select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
}

/* رأس القسم */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    margin: 0;
    color: var(--primary-color);
}

.section-actions {
    display: flex;
    gap: 10px;
}

/* تحسين الجدول */
.table-container {
    background: var(--surface-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#studentsTable {
    width: 100%;
    border-collapse: collapse;
}

#studentsTable th {
    background: var(--primary-color);
    color: white;
    padding: 15px;
    text-align: center;
    font-weight: 600;
}

#studentsTable td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

#studentsTable tbody tr:hover {
    background-color: #f8f9fa;
}

/* صورة الطالب */
.student-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin: 0 auto;
}

/* أزرار الإجراءات */
.actions {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-action {
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.btn-view { background: #2196f3; color: white; }
.btn-grades { background: #4caf50; color: white; }
.btn-attendance { background: #ff9800; color: white; }
.btn-reports { background: #9c27b0; color: white; }
.btn-delete { background: #f44336; color: white; }

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-action:active {
    transform: translateY(0);
}

/* حالات الطلاب */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.status-active { background: #e8f5e8; color: #2e7d32; }
.status-inactive { background: #ffebee; color: #c62828; }
.status-transferred { background: #fff3e0; color: #ef6c00; }
.status-graduated { background: #e3f2fd; color: #1565c0; }

/* حالة التحميل وعدم وجود بيانات */
.loading-state, .empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface-color);
    border-radius: 12px;
    margin: 20px 0;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-icon {
    font-size: 4em;
    color: #bdbdbd;
    margin-bottom: 15px;
}

.empty-state h3 {
    color: #666;
    margin-bottom: 10px;
}

.empty-state p {
    color: #999;
    margin-bottom: 20px;
}

/* الترقيم */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding: 20px;
}

#pageInfo {
    font-weight: 600;
    color: var(--text-color-dark);
}

/* تحسين المودال */
.modal-content {
    max-width: 500px;
    width: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.warning-text {
    color: #f44336;
    font-weight: 600;
    margin-top: 10px;
}

/* تصميم متجاوب */
@media (max-width: 768px) {
    .quick-stats {
        grid-template-columns: 1fr 1fr;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .filter-item {
        min-width: 100%;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .section-actions {
        justify-content: center;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    #studentsTable {
        min-width: 800px;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .btn-action {
        justify-content: center;
    }
    
    .pagination {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .quick-stats {
        grid-template-columns: 1fr;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .student-management-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .search-bar {
        margin-left: 0;
    }
}
/* تنسيقات إضافية لإدخال العلامات */
.mark-input {
    width: 80px;
    padding: 5px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.mark-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
    outline: none;
}

.mark-input.saving {
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.mark-input.saved-success {
    background-color: #d1edff;
    border-color: #007bff;
}

.mark-input.saved-error {
    background-color: #f8d7da;
    border-color: #dc3545;
}

.final-mark {
    font-weight: bold;
    color: #28a745;
    padding: 5px 10px;
}

.subject-header {
    background-color: #f8f9fa;
    font-weight: bold;
    text-align: center;
}

.term-col {
    background-color: #e9ecef;
    font-size: 0.9em;
    text-align: center;
    width: 100px;
}

/* تحسينات للجدول */
.data-table th {
    background-color: #343a40;
    color: white;
    padding: 12px 8px;
    text-align: center;
}

.data-table td {
    padding: 8px;
    text-align: center;
    vertical-align: middle;
}

/* تحسينات للفلاتر */
.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
    margin-bottom: 20px;
}

.filter-item {
    display: flex;
    flex-direction: column;
    min-width: 180px;
}

.filter-item label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #495057;
}