/* =============================================
   نظام إدارة المدرسة - التنسيقات
   School Management System Styles
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
    --primary: #1a56db;
    --primary-dark: #1244b0;
    --primary-light: #e8effc;
    --secondary: #0f766e;
    --secondary-light: #e6f7f5;
    --accent: #f59e0b;
    --accent-light: #fef3cd;
    --danger: #dc2626;
    --danger-light: #fde8e8;
    --success: #16a34a;
    --success-light: #e6f9ed;
    --warning: #ea580c;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    direction: rtl;
    font-size: 15px;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* =============================================
   الشريط الجانبي
   ============================================= */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: white;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-header .school-icon {
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-size: 24px;
}

.sidebar-nav { padding: 15px 0; }

.nav-section {
    padding: 8px 20px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gray-400);
    letter-spacing: 1px;
    font-weight: 700;
    margin-top: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--gray-300);
    transition: all 0.2s;
    border-right: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.nav-item.active {
    background: rgba(26, 86, 219, 0.2);
    color: white;
    border-right-color: var(--primary);
}

.nav-item .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.nav-item .badge {
    margin-right: auto;
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

/* =============================================
   المحتوى الرئيسي
   ============================================= */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
}

.top-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.top-header .page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.top-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-header .user-avatar {
    width: 38px;
    height: 38px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.content-area {
    padding: 25px 30px;
}

/* =============================================
   البطاقات الإحصائية
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--gray-100);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-card .stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.green { background: var(--secondary-light); color: var(--secondary); }
.stat-card .stat-icon.yellow { background: var(--accent-light); color: var(--accent); }
.stat-card .stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-card .stat-info h3 {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--gray-900);
}

.stat-card .stat-info p {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* =============================================
   الجداول
   ============================================= */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    border: 1px solid var(--gray-100);
    overflow: hidden;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-50);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
}

.card-body { padding: 22px; }
.card-body.no-padding { padding: 0; }

.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: right;
    font-weight: 700;
    font-size: 13px;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
    color: var(--gray-700);
}

table tr:hover td {
    background: var(--gray-50);
}

table tr:last-child td {
    border-bottom: none;
}

/* =============================================
   النماذج
   ============================================= */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%236b7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
    padding-left: 35px;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
}

.form-row .form-group {
    margin-bottom: 0;
}

/* =============================================
   الأزرار
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }

.btn-warning { background: var(--accent); color: white; }
.btn-warning:hover { background: #d97706; color: white; }

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-300);
}
.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-700);
}

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }

/* =============================================
   الشارات والحالات
   ============================================= */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--accent-light); color: var(--warning); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* =============================================
   التنبيهات
   ============================================= */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--accent-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* =============================================
   صفحة تسجيل الدخول
   ============================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #0f172a;
    padding: 20px;
}

.login-background,
.login-vignette,
.login-slide {
    position: absolute;
    inset: 0;
}

.login-background {
    z-index: 0;
    background: #0f172a;
}

.login-slide {
    background-position: center;
    background-size: cover;
    opacity: 0;
    transform: scale(1.05);
    animation: loginSlideShow 28s infinite;
    will-change: opacity, transform;
}

.login-slide-1 {
    background-image: url('login/login-bg-1.jpg');
    animation-delay: 0s;
}

.login-slide-2 {
    background-image: url('login/login-bg-2.jpg');
    animation-delay: 7s;
}

.login-slide-3 {
    background-image: url('login/login-bg-3.jpg');
    background-position: center 38%;
    animation-delay: 14s;
}

.login-slide-4 {
    background-image: url('login/login-bg-4.jpg');
    animation-delay: 21s;
}

.login-vignette {
    z-index: 1;
    background:
        radial-gradient(circle at 78% 22%, rgba(14, 165, 233, 0.22), transparent 32%),
        linear-gradient(90deg, rgba(15, 23, 42, 0.76) 0%, rgba(15, 23, 42, 0.52) 44%, rgba(15, 23, 42, 0.76) 100%),
        linear-gradient(180deg, rgba(15, 23, 42, 0.22), rgba(15, 23, 42, 0.72));
    backdrop-filter: saturate(1.08);
}

.login-card {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 18px;
    padding: 34px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(16px);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 26px;
}

.login-card .logo .icon {
    display: none;
}

.login-school-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    padding: 0;
    background: white;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
    margin: 0 auto 8px;
}

.login-school-name {
    font-size: 20px;
    color: var(--gray-900);
    font-weight: 900;
    line-height: 1.35;
    margin-bottom: 3px;
}

.login-card .form-group label {
    color: var(--gray-700);
    font-weight: 800;
}

.login-card .form-control {
    min-height: 46px;
    border-color: rgba(148, 163, 184, 0.68);
    background: rgba(255, 255, 255, 0.88);
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.login-card .btn-primary {
    min-height: 48px;
    border-radius: 10px;
    font-weight: 900;
    box-shadow: 0 12px 26px rgba(26, 86, 219, 0.24);
}

@keyframes loginSlideShow {
    0%,
    24% {
        opacity: 1;
        transform: scale(1.05);
    }
    32%,
    100% {
        opacity: 0;
        transform: scale(1.13);
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-slide {
        animation: none;
        opacity: 0;
    }
    .login-slide-1 {
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .login-page {
        padding: 16px;
        align-items: flex-end;
    }

    .login-card {
        padding: 26px 22px;
        border-radius: 16px;
    }

    .login-school-logo {
        width: 32px;
        height: 32px;
    }

    .login-school-name {
        font-size: 18px;
    }
}

.login-card .logo h1 {
    font-size: 22px;
    color: var(--gray-900);
    font-weight: 800;
}

.login-card .logo p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

/* =============================================
   المرفقات والتحميل
   ============================================= */
.file-upload {
    border: 2px dashed var(--gray-300);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* =============================================
   المودال
   ============================================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
    background: white;
    border-radius: 14px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body { padding: 22px; }
.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

/* =============================================
   البحث والفلاتر
   ============================================= */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-bar .form-control {
    max-width: 300px;
}

/* =============================================
   طباعة
   ============================================= */
@media print {
    .sidebar, .top-header, .btn, .search-bar { display: none !important; }
    .main-content { margin-right: 0 !important; }
    .content-area { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* =============================================
   الاستجابة للشاشات الصغيرة
   ============================================= */
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .content-area { padding: 15px; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .top-header { padding: 0 15px; }
}

/* =============================================
   صندوق الرسائل
   ============================================= */
.message-item {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    gap: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.message-item:hover { background: var(--gray-50); }
.message-item.unread { background: var(--primary-light); }
.message-item.unread:hover { background: #dce6f8; }

.message-item .sender-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.message-item .message-content { flex: 1; min-width: 0; }
.message-item .message-subject {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-item .message-preview {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-item .message-time {
    font-size: 12px;
    color: var(--gray-400);
    white-space: nowrap;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 5px;
    justify-content: center;
    padding: 20px;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.pagination a:hover { background: var(--gray-100); }
.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--gray-400);
}

.empty-state .icon { font-size: 48px; margin-bottom: 15px; }
.empty-state h3 { font-size: 18px; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }
