/* ========== نظام الوضع الليلي/النهاري ========== */

/* الوضع الليلي للـ body - تدرج محسّن */
body.dark-mode {
    background: linear-gradient(135deg, #0a0e1a 0%, #1a1f2e 50%, #1e293b 100%);
    background-attachment: fixed;
    color: #e2e8f0;
}

/* البطاقات والعناصر - تدرج محسّن */
body.dark-mode .card,
body.dark-mode .menu-item,
body.dark-mode .card-link .card {
    background: linear-gradient(145deg, #1a2332 0%, #1e293b 50%, #2d3748 100%) !important;
    border: 1px solid #3d4a5c !important;
    color: #e2e8f0 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .card:hover,
body.dark-mode .menu-item:hover,
body.dark-mode .card-link:hover .card {
    background: linear-gradient(145deg, #2d3748 0%, #374151 50%, #475569 100%) !important;
    border-color: #3b82f6 !important;
    color: #f1f5f9 !important;
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.2) !important;
}

/* الروابط داخل البطاقات */
body.dark-mode .card-link,
body.dark-mode a.menu-item,
body.dark-mode a.card {
    color: inherit !important;
    text-decoration: none !important;
}

/* grid menu items */
body.dark-mode .menu-grid .menu-item {
    background: linear-gradient(145deg, #1e293b 0%, #334155 100%) !important;
    border: 1px solid #334155 !important;
}

body.dark-mode .menu-grid .menu-item:hover {
    background: linear-gradient(145deg, #334155 0%, #475569 100%) !important;
    border-color: #3b82f6 !important;
    transform: translateY(-10px) scale(1.03);
}

/* العناوين */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6,
body.dark-mode .title {
    color: #f1f5f9;
}

body.dark-mode .menu-item:hover .title {
    color: #ffffff;
}

/* الأوصاف والنصوص الثانوية */
body.dark-mode .description,
body.dark-mode .text-muted,
body.dark-mode small {
    color: #94a3b8;
}

body.dark-mode .menu-item:hover .description {
    color: #cbd5e1;
}

/* التنبيهات */
body.dark-mode .alert {
    background: linear-gradient(145deg, #1e293b 0%, #334155 100%);
    border-color: #3b82f6;
    color: #e2e8f0;
}

body.dark-mode .alert-info {
    background: linear-gradient(145deg, #1e3a5f 0%, #2d4a6f 100%);
    border-color: #3b82f6;
    color: #bfdbfe;
}

body.dark-mode .alert-warning {
    background: linear-gradient(145deg, #451a03 0%, #78350f 100%);
    border-color: #f59e0b;
    color: #fef3c7;
}

body.dark-mode .alert-success {
    background: linear-gradient(145deg, #064e3b 0%, #065f46 100%);
    border-color: #10b981;
    color: #d1fae5;
}

body.dark-mode .alert-danger {
    background: linear-gradient(145deg, #7f1d1d 0%, #991b1b 100%);
    border-color: #ef4444;
    color: #fecaca;
}

/* الجداول - قواعد قوية جداً */
body.dark-mode table,
body.dark-mode .table,
body.dark-mode table.table,
body.dark-mode table.table-bordered,
body.dark-mode table.table-striped {
    color: #e2e8f0 !important;
    background: #1e293b !important;
    background-color: #1e293b !important;
}

body.dark-mode table thead,
body.dark-mode .table thead,
body.dark-mode table thead th,
body.dark-mode .table thead th,
body.dark-mode table thead tr,
body.dark-mode .table thead tr {
    background: linear-gradient(145deg, #1a2332 0%, #1e293b 50%, #2d3748 100%) !important;
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #3d4a5c !important;
    font-weight: 600 !important;
}

body.dark-mode table tbody,
body.dark-mode .table tbody,
body.dark-mode table.table tbody {
    background: #1e293b !important;
    background-color: #1e293b !important;
}

body.dark-mode table tbody tr,
body.dark-mode .table tbody tr,
body.dark-mode table.table tbody tr,
body.dark-mode table tbody tr td,
body.dark-mode .table tbody tr td {
    background: #1e293b !important;
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

body.dark-mode table tbody tr:hover,
body.dark-mode .table tbody tr:hover,
body.dark-mode table tbody tr:hover td,
body.dark-mode table tbody tr:nth-child(even):hover,
body.dark-mode .table tbody tr:nth-child(even):hover {
    background: #334155 !important;
    background-color: #334155 !important;
}

body.dark-mode table tbody tr:nth-child(even),
body.dark-mode .table tbody tr:nth-child(even),
body.dark-mode table tbody tr:nth-child(even) td,
body.dark-mode .table-striped tbody tr:nth-child(even),
body.dark-mode .table-striped tbody tr:nth-child(even) td {
    background: #0f172a !important;
    background-color: #0f172a !important;
}

body.dark-mode table td,
body.dark-mode table th,
body.dark-mode .table td,
body.dark-mode .table th {
    border-color: #334155 !important;
    color: #e2e8f0 !important;
    background-color: transparent !important;
}

/* جداول Bootstrap */
body.dark-mode .table-bordered,
body.dark-mode .table-bordered td,
body.dark-mode .table-bordered th,
body.dark-mode table.table-bordered,
body.dark-mode table.table-bordered td,
body.dark-mode table.table-bordered th {
    border-color: #334155 !important;
}

body.dark-mode .table-hover tbody tr:hover,
body.dark-mode table.table-hover tbody tr:hover {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-mode .table-striped tbody tr:nth-of-type(odd),
body.dark-mode table.table-striped tbody tr:nth-of-type(odd) {
    background-color: #1e293b !important;
}

body.dark-mode .table-striped tbody tr:nth-of-type(even),
body.dark-mode table.table-striped tbody tr:nth-of-type(even) {
    background-color: #0f172a !important;
}

/* إزالة أي خلفية بيضاء من الجداول */
body.dark-mode table[style*="background"],
body.dark-mode .table[style*="background"],
body.dark-mode tbody[style*="background"],
body.dark-mode tr[style*="background"],
body.dark-mode td[style*="background"],
body.dark-mode th[style*="background"] {
    background: #1e293b !important;
    background-color: #1e293b !important;
}

/* إزالة bg-white من الجداول */
body.dark-mode table.bg-white,
body.dark-mode .table.bg-white,
body.dark-mode tbody.bg-white,
body.dark-mode tr.bg-white,
body.dark-mode td.bg-white,
body.dark-mode th.bg-white {
    background: #1e293b !important;
    background-color: #1e293b !important;
}

/* النماذج */
body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus,
body.dark-mode input:focus,
body.dark-mode textarea:focus {
    background-color: #334155;
    border-color: #3b82f6;
    color: #f1f5f9;
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
}

body.dark-mode .form-label {
    color: #cbd5e1;
}

/* الأزرار */
body.dark-mode .btn-primary {
    background: linear-gradient(145deg, #3b82f6, #2563eb) !important;
    border-color: #2563eb !important;
    color: #ffffff !important;
}

body.dark-mode .btn-primary:hover {
    background: linear-gradient(145deg, #2563eb, #1d4ed8) !important;
}

body.dark-mode .btn-secondary,
body.dark-mode .btn-outline-secondary {
    background: linear-gradient(145deg, #475569, #334155) !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

body.dark-mode .btn-outline-primary {
    background: transparent !important;
    border-color: #3b82f6 !important;
    color: #3b82f6 !important;
}

body.dark-mode .btn-outline-primary:hover {
    background: #3b82f6 !important;
    color: #ffffff !important;
}

body.dark-mode .btn-outline-info {
    background: transparent !important;
    border-color: #06b6d4 !important;
    color: #06b6d4 !important;
}

body.dark-mode .btn-outline-info:hover {
    background: #06b6d4 !important;
    color: #ffffff !important;
}

body.dark-mode .btn-success {
    background: linear-gradient(145deg, #10b981, #059669) !important;
    border-color: #059669 !important;
    color: #ffffff !important;
}

body.dark-mode .btn-danger {
    background: linear-gradient(145deg, #ef4444, #dc2626) !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
}

/* ========== الهيدر والنافبار - تدرج محسّن ========== */
body.dark-mode .navbar,
body.dark-mode nav,
body.dark-mode header,
body.dark-mode .navbar-light,
body.dark-mode .navbar-expand-lg,
body.dark-mode nav.navbar,
body.dark-mode nav[class*="navbar"] {
    background: linear-gradient(145deg, #0f1419 0%, #1a2332 50%, #1e293b 100%) !important;
    background-color: #1e293b !important;
    border-color: #3d4a5c !important;
    color: #e2e8f0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}

/* إلغاء أي bg-white في navbar */
body.dark-mode .navbar.bg-white,
body.dark-mode nav.bg-white {
    background: linear-gradient(145deg, #1e293b, #334155) !important;
    background-color: #1e293b !important;
}

/* إلغاء أي style inline - قواعد قوية جداً */
body.dark-mode .navbar[style],
body.dark-mode nav[style],
body.dark-mode .navbar[style*="background"],
body.dark-mode nav[style*="background"],
body.dark-mode .navbar[style*="#f8f9fa"],
body.dark-mode nav[style*="#f8f9fa"] {
    background: linear-gradient(145deg, #1e293b, #334155) !important;
    background-color: #1e293b !important;
}

/* shadow في navbar */
body.dark-mode .navbar.shadow-sm,
body.dark-mode nav.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.5) !important;
}

/* قاعدة عدوانية للغاية - تطبق على كل navbar */
body.dark-mode nav[class*="navbar"] * {
    border-color: #334155 !important;
}

body.dark-mode .navbar * {
    border-color: #334155 !important;
}

body.dark-mode .navbar-brand {
    color: #f1f5f9 !important;
}

body.dark-mode .navbar-brand:hover {
    color: #ffffff !important;
}

/* روابط النافبار */
body.dark-mode .nav-link {
    color: #cbd5e1 !important;
}

body.dark-mode .nav-link:hover,
body.dark-mode .nav-link:focus,
body.dark-mode .nav-link.active {
    color: #f1f5f9 !important;
    background: rgba(59, 130, 246, 0.2) !important;
}

/* القوائم المنسدلة */
body.dark-mode .dropdown-menu {
    background: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-mode .dropdown-item {
    color: #cbd5e1 !important;
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:focus {
    background: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-mode .dropdown-divider {
    border-color: #334155 !important;
}

/* زر الـ toggler */
body.dark-mode .navbar-toggler {
    border-color: #475569 !important;
}

body.dark-mode .navbar-toggler-icon {
    filter: invert(1) brightness(1.5);
}

/* نصوص وأيقونات النافبار */
body.dark-mode .navbar .text-dark,
body.dark-mode .navbar span,
body.dark-mode .navbar .fw-bold {
    color: #e2e8f0 !important;
}

body.dark-mode .navbar i,
body.dark-mode .navbar .fas,
body.dark-mode .navbar .far {
    color: #93c5fd !important;
}

/* container في navbar */
body.dark-mode .navbar .container {
    background: transparent !important;
}

/* ========== الفوتر - تدرج محسّن ========== */
body.dark-mode footer,
body.dark-mode .footer,
body.dark-mode .login-footer,
body.dark-mode .admin-footer {
    background: linear-gradient(180deg, #0a0e1a 0%, #0f1419 100%) !important;
    border-top: 1px solid #3d4a5c !important;
    color: #94a3b8 !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode footer a,
body.dark-mode .footer a {
    color: #3b82f6 !important;
}

body.dark-mode footer a:hover,
body.dark-mode .footer a:hover {
    color: #60a5fa !important;
}

/* Modal والنوافذ المنبثقة */
body.dark-mode .modal-content {
    background: linear-gradient(145deg, #1e293b 0%, #334155 100%);
    color: #e2e8f0;
    border-color: #334155;
}

body.dark-mode .modal-header {
    border-bottom-color: #334155;
}

body.dark-mode .modal-footer {
    border-top-color: #334155;
}

/* Breadcrumb */
body.dark-mode .breadcrumb {
    background: #1e293b;
}

body.dark-mode .breadcrumb-item {
    color: #94a3b8;
}

body.dark-mode .breadcrumb-item.active {
    color: #e2e8f0;
}

/* Badges */
body.dark-mode .badge {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

body.dark-mode .menu-item .badge {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #93c5fd !important;
    border: 1px solid #3b82f6;
}

/* الأيقونات */
body.dark-mode .menu-item i,
body.dark-mode .card i {
    /* الأيقونات تبقى بألوانها للتمييز */
    filter: brightness(1.2);
}

/* الخلفية البيضاء */
body.dark-mode .bg-white,
body.dark-mode .bg-light {
    background: #1e293b !important;
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

/* بطاقات الإحصائيات - تدرج محسّن */
body.dark-mode .text-center.py-3.bg-light,
body.dark-mode .bg-light.rounded {
    background: linear-gradient(145deg, #1a2332 0%, #1e293b 50%, #2d3748 100%) !important;
    background-color: #1e293b !important;
    border: 1px solid #3d4a5c !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .text-center.py-3.bg-light .text-dark,
body.dark-mode .bg-light .text-dark {
    color: #e2e8f0 !important;
}

body.dark-mode .text-center.py-3.bg-light .fw-bold,
body.dark-mode .bg-light .fw-bold {
    color: #f1f5f9 !important;
}

/* الأيقونات الملونة في البطاقات - تبقى بألوانها */
body.dark-mode span[style*="background:#"],
body.dark-mode span[style*="background: #"] {
    /* الأيقونات الملونة تبقى كما هي للتمييز */
    filter: brightness(1.3) !important;
}

/* النصوص - إصلاح شامل */
body.dark-mode .text-dark,
body.dark-mode .text-muted,
body.dark-mode .text-secondary {
    color: #cbd5e1 !important;
}

body.dark-mode .text-white {
    color: #1e293b !important;
}

body.dark-mode .fs-5.text-dark {
    color: #f1f5f9 !important;
}

/* إصلاح النصوص البيضاء inline */
body.dark-mode *[style*="color: white"],
body.dark-mode *[style*="color: #fff"],
body.dark-mode *[style*="color:#fff"],
body.dark-mode *[style*="color: #ffffff"],
body.dark-mode *[style*="color:white"],
body.dark-mode *[style*="color:#ffffff"] {
    color: #e2e8f0 !important;
}

/* النصوص في الخلفيات الفاتحة */
body.dark-mode .bg-light *,
body.dark-mode .bg-white * {
    color: #e2e8f0 !important;
}

/* النصوص في البطاقات */
body.dark-mode .card *,
body.dark-mode .menu-item * {
    color: inherit;
}

body.dark-mode .card .text-white,
body.dark-mode .menu-item .text-white {
    color: #e2e8f0 !important;
}

/* تأكد من عدم وجود خلفية بيضاء في أي مكان */
body.dark-mode *[style*="background: white"],
body.dark-mode *[style*="background: #fff"],
body.dark-mode *[style*="background-color: white"],
body.dark-mode *[style*="background-color: #fff"],
body.dark-mode *[style*="background-color:#fff"],
body.dark-mode *[style*="background-color: #ffffff"] {
    background-color: #1e293b !important;
    background: #1e293b !important;
}

/* الحدود */
body.dark-mode .border,
body.dark-mode .border-top,
body.dark-mode .border-bottom,
body.dark-mode .border-start,
body.dark-mode .border-end {
    border-color: #334155 !important;
}

/* زر تبديل الوضع */
.theme-toggle {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 1000;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 30px rgba(59, 130, 246, 0.6);
}

.theme-toggle i {
    font-size: 1.5rem;
    color: #ffffff;
    transition: all 0.3s ease;
}

body.dark-mode .theme-toggle {
    background: linear-gradient(145deg, #f59e0b, #d97706);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

body.dark-mode .theme-toggle:hover {
    box-shadow: 0 6px 30px rgba(245, 158, 11, 0.6);
}

/* ========== قواعد خاصة لصفحة الطلاب - النمط النهاري والليلي ========== */

/* الأزرار في main-header - تأثير زجاجي */
.main-header .btn {
    font-weight: 600 !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 
                inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    transition: all 0.3s ease !important;
    color: #ffffff !important;
}

.main-header .btn i,
.main-header .btn .fas,
.main-header .btn .far {
    color: #ffffff !important;
}

.main-header .btn-secondary {
    background: rgba(52, 58, 64, 0.7) !important;
    color: #ffffff !important;
}

.main-header .btn-secondary:hover {
    background: rgba(52, 58, 64, 0.85) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), 
                inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

.main-header .btn-info {
    background: rgba(23, 162, 184, 0.7) !important;
    color: #ffffff !important;
}

.main-header .btn-info:hover {
    background: rgba(23, 162, 184, 0.85) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), 
                inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

.main-header .btn-outline-success {
    background: rgba(40, 167, 69, 0.7) !important;
    color: #ffffff !important;
}

.main-header .btn-outline-success:hover {
    background: rgba(40, 167, 69, 0.85) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), 
                inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

/* النمط الليلي - خلفية غامقة متناسقة */
body.dark-mode .main-header {
    background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #1e293b 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .main-header h1 {
    color: #f1f5f9 !important;
    font-weight: 700 !important;
}

body.dark-mode .main-header p {
    color: #cbd5e1 !important;
}

body.dark-mode .main-header i {
    color: #60a5fa !important;
}

/* صندوق البحث في صفحة الطلاب */
body.dark-mode .search-filters {
    background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #1e293b 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode .search-filters .form-label {
    color: #cbd5e1 !important;
}

body.dark-mode .search-filters .form-control,
body.dark-mode .search-filters .form-select {
    background: rgba(30, 41, 59, 0.6) !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

body.dark-mode .search-filters .form-control:focus,
body.dark-mode .search-filters .form-select:focus {
    background: rgba(51, 65, 85, 0.8) !important;
    border-color: #3b82f6 !important;
}

/* ========== قواعد خاصة لصفحة تسجيل الدخول ========== */
body.dark-mode .login-box {
    background: linear-gradient(145deg, #1e293b 0%, #334155 100%) !important;
    color: #e2e8f0 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .login-header {
    background: #1e293b !important;
    color: #3b82f6 !important;
    border-bottom: 2px solid #334155 !important;
}

body.dark-mode .login-title {
    color: #3b82f6 !important;
}

body.dark-mode .login-subtitle {
    color: #94a3b8 !important;
}

body.dark-mode .login-body {
    background: #1e293b !important;
}

body.dark-mode .login-footer {
    background: #0f172a !important;
    border-top: 1px solid #334155 !important;
    color: #94a3b8 !important;
}

body.dark-mode .input-group-text {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #94a3b8 !important;
}

body.dark-mode .btn-login {
    background: linear-gradient(145deg, #3b82f6, #2563eb) !important;
    border: none !important;
}

body.dark-mode .btn-login:hover {
    background: linear-gradient(145deg, #2563eb, #1d4ed8) !important;
}

/* تأثيرات الانتقال */
body,
.card,
.menu-item,
.alert,
.btn,
.form-control,
.navbar,
.login-box,
.login-header,
.login-footer {
    transition: all 0.3s ease;
}
