/* Custom Styles for Student Management System */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

/* متغيرات الألوان للوضع الفاتح والداكن */
:root {
    /* الوضع الفاتح (افتراضي) */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #868e96;
    --border-color: #dee2e6;
    --navbar-bg: #ffffff;
    --navbar-text: #212529;
    --card-bg: #ffffff;
    --card-border: #dee2e6;
    --input-bg: #ffffff;
    --input-border: #ced4da;
    --button-primary: #007bff;
    --button-success: #28a745;
    --button-danger: #dc3545;
    --button-warning: #ffc107;
    --button-info: #17a2b8;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);

    /* متغيرات بطاقات الإحصائيات (Blue Card) */
    --stat-card-bg-gradient: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    --stat-card-text: #ffffff;
    --stat-card-icon-opacity: 0.2;
}

body {
    font-family: 'Cairo', sans-serif !important;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* السماح بمؤشر الكتابة فقط في حقول الإدخال */
input, textarea, select, [contenteditable="true"] {
    cursor: text !important;
    font-family: 'Cairo', sans-serif !important;
}

/* السماح بمؤشر اليد على الأزرار والروابط */
button, a, .btn, [role="button"], .clickable {
    cursor: pointer !important;
}

/* السماح بمؤشر اليد على العناصر القابلة للنقر */
.nav-link, .dropdown-toggle, .close, .modal-header .btn-close {
    cursor: pointer !important;
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.3rem;
}

.page-content {
    animation: fadeIn 0.3s ease-in;
    display: none; /* إخفاء جميع الصفحات افتراضياً */
}

/* إظهار الصفحة الرئيسية افتراضياً */
#homePage {
    display: block;
}

/* إخفاء لوحة التحكم افتراضياً ليتم التحكم بها عبر JS */
#dashboardPage {
    display: none;
}

/* إخفاء شريط التمرير في صفحة لوحة تحكم المعلم فقط */
body.hide-scrollbar {
    -ms-overflow-style: none; /* IE و Edge */
    scrollbar-width: none;   /* Firefox */
}
body.hide-scrollbar::-webkit-scrollbar {
    display: none;           /* Chrome و Safari و Opera */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 0.5rem;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    }
.card-header {
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
}

/* Mobile Responsive Tweaks */
@media (max-width: 768px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .card-header h5 {
        font-size: 1.1rem;
    }

    /* Stack nav tabs on very small screens or let them scroll */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tabs .nav-link {
        font-size: 0.9rem;
        padding: 0.5rem 0.8rem;
    }

    .table-responsive {
        border: 0;
    }
    
    /* Improve modal display on mobile */
    .grade-input-modal {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

.btn {
    border-radius: 0.375rem;
    font-weight: 500;
}

.table th {
    background-color: var(--bg-tertiary);
    border-top: none;
    font-weight: 600;
    color: var(--text-primary);
}

.table td {
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Mobile Table Cards View */
@media (max-width: 768px) {
    #studentRecordDisplay .table thead {
        display: none;
    }

    #studentRecordDisplay .table tbody tr {
        display: block;
        margin-bottom: 1rem;
        background: #fff;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.05);
        padding: 0.5rem;
    }

    #studentRecordDisplay .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        padding: 0.75rem 0.5rem;
        text-align: right !important;
        flex-wrap: wrap;
    }

    #studentRecordDisplay .table td:last-child {
        border-bottom: none;
    }

    #studentRecordDisplay .table td[data-label]::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-secondary);
        margin-left: 1rem;
        font-size: 0.9rem;
        display: inline-block;
        min-width: 80px;
    }
}


.bulk-sticky-thead th {
    position: static;
}

@media (min-width: 768px) {
    .bulk-sticky-thead th {
        position: sticky;
        top: 115px;
        z-index: 1010;
    }
}

/* === بداية كود CSS المخصص للبطايق === */ 
 
         /* === بداية كود البطايق (Info Cards) === */ 
         
         .info-card { 
             border: none; 
             border-radius: 16px; 
             color: white; 
             overflow: hidden; 
             position: relative; 
             transition: transform 0.3s ease, box-shadow 0.3s ease; 
             box-shadow: 0 4px 15px rgba(0,0,0,0.1); 
             height: 100%; /* لضمان تساوي الارتفاع */ 
         } 
 
         .info-card:hover { 
             transform: translateY(-5px); 
             box-shadow: 0 12px 24px rgba(0,0,0,0.2); 
         } 
 
        .info-card .card-body { 
            padding: 25px; 
            display: flex; 
            flex-direction: column; 
            align-items: flex-start; 
            justify-content: center; 
            text-align: right; 
            z-index: 2; 
            position: relative; 
            min-height: 60px; 
        } 

        .info-card .card-title { 
            font-size: 0.9rem; 
            font-weight: 600; 
            opacity: 0.95; 
            margin-bottom: 0.3rem; 
            color: white !important; 
        } 

        .info-card .number { 
            font-size: 1.5rem; /* تصغير حجم الرقم */
            font-weight: 800; 
            color: white !important; 
            line-height: 1.1; 
        } 
 
         /* === ألوان الخلفيات (Gradients) === */ 
         
         /* الأزرق المتدرج (الافتراضي) */ 
         .info-card.blue-gradient { 
             background: linear-gradient(135deg, #005bea 0%, #00c6fb 100%); 
         } 
         
         /* الأخضر (واتساب) */ 
         .info-card.whatsapp-stats { 
             background: linear-gradient(135deg, #25D366 0%, #128C7E 100%); 
         } 
         
         /* الأسود المتدرج (للوقت) */ 
         .info-card.dark-gradient { 
             background: linear-gradient(135deg, #005bea 0%, #000000 100%); 
         } 

         /* Purple Gradient */
         .info-card.purple-gradient {
             background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
         }

         /* Orange Gradient */
         .info-card.orange-gradient {
             background: linear-gradient(135deg, #fc6076 0%, #ff9a44 100%);
         }

         /* Teal/Cyan Gradient */
         .info-card.teal-gradient {
             background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
         }
 
         /* === الأيقونات الخلفية الشفافة (Decoration) === */ 
         .info-card .icon-decoration { 
             position: absolute; 
             color: rgba(255, 255, 255, 0.15); 
             z-index: 1; 
             transition: all 0.3s ease; 
         } 
 
         /* أيقونة كبيرة في الزاوية اليسرى السفلية */ 
         .info-card .icon-1 { 
             bottom: -10px; 
             left: -10px; 
             font-size: 4rem; 
             transform: rotate(15deg); 
         } 

         /* أيقونة دائرية في الزاوية اليمنى العلوية */ 
         .info-card .icon-2 { 
             top: -15px; 
             right: -15px; 
             font-size: 5rem; 
             opacity: 0.1; 
         } 
 
         .info-card:hover .icon-1 { 
             transform: rotate(0deg) scale(1.1); 
         } 

.menu-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    margin-right: 0.5rem;
    vertical-align: middle;
    font-weight: bold;
}

.badge-new {
    background-color: rgba(25, 135, 84, 0.1);
    color: #198754;
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.badge-beta {
    background-color: rgba(255, 193, 7, 0.1);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.2);
}

.badge-hot {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

/* Scrollable Student List Container */
.student-list-container {
    max-height: 400px;
    overflow-y: auto;
}

/* Mega Menu Icons Styling */
.icon-circle-sm {
    width: 35px;
    height: 35px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1rem;
    flex-shrink: 0;
}

#topViolationsChart {
    height: 250px !important;
}

/* === Print Styles === */
@media print {
    /* Hide non-printable elements */
    .d-print-none,
    .navbar,
    .btn,
    .form-control,
    .form-select,
    .alert,
    #loadingIndicator,
    #noDataMessage,
    footer {
        display: none !important;
    }

    /* Layout Adjustments */
    body, .container-fluid, .row, .col-12 {
        background-color: white !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        min-width: 100% !important;
    }

    /* Ensure the main container doesn't constrain us */
    .container, .container-fluid {
        max-width: none !important;
    }

    /* Cards */
    .card {
        border: none !important;
        box-shadow: none !important;
    }
    
    .card-header {
        background-color: transparent !important;
        border-bottom: 2px solid #000 !important;
        padding: 5px !important;
    }

    /* Info Cards (Top Section) */
    .info-card {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        border: 1px solid #ddd !important;
        margin-bottom: 10px !important;
        page-break-inside: avoid;
        height: auto !important; /* Allow height to adjust */
        min-height: 0 !important;
    }

    .info-card .card-body {
        padding: 0.5rem !important; /* Reduce padding */
    }

    .info-card .card-title {
        font-size: 0.9rem !important;
        margin-bottom: 0.25rem !important;
    }

    .info-card .number {
        font-size: 1.25rem !important;
        margin-bottom: 0 !important;
    }

    .info-card .icon-decoration {
        font-size: 2rem !important; /* Smaller icons */
        bottom: -5px !important;
        right: -5px !important;
    }

    /* Force page break before the tools grid to ensure they are on their own page */
    #perToolAnalysis {
        page-break-before: always;
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
        margin-top: 20px !important;
    }

    #perToolAnalysis > div {
        width: auto !important;
        max-width: none !important;
        flex: none !important;
        margin-bottom: 0 !important;
        page-break-inside: avoid !important;
    }

    #perToolAnalysis .card, 
    #totalScoreCardContainer .card {
        border: 1px solid #000 !important;
        height: 100% !important;
    }

    #perToolAnalysis .card-header h6,
    #totalScoreCardContainer .card-header h6 {
        font-size: 12pt !important;
        text-align: center;
    }

    #perToolAnalysis .card-body,
    #totalScoreCardContainer .card-body {
        padding: 5px !important;
    }

    /* Adjust Total Score Card Container Width */
    #totalScoreCardContainer {
        width: 44% !important;
        max-width: 44% !important;
        flex: 0 0 44% !important;
        margin-right: auto !important;
        margin-left: auto !important;
        margin-bottom: 50px !important;
    }

    /* Tables */
    .table-responsive {
        overflow: visible !important;
        display: block !important;
        width: 100% !important;
    }

    .table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 9pt !important;
        margin-bottom: 0 !important;
    }

    .table th, .table td {
        border: 1px solid #000 !important;
        padding: 3px !important;
        color: black !important;
        background-color: transparent !important;
    }

    .table thead th {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Prevent page breaks inside rows */
    tr {
        page-break-inside: avoid;
    }

    /* Typography */
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
    }
    
    a {
        text-decoration: none !important;
        color: black !important;
    }

    /* === Dashboard Charts Print Styles === */
    #chartsSectionHeader {
        page-break-before: always !important;
        margin-top: 20px !important;
    }

    #chartsSectionHeader button {
        display: none !important;
    }

    #chartsCollapse {
        display: block !important;
        visibility: visible !important;
    }

    #chartsCollapse .row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 10px !important;
    }

    #chartsCollapse .col-lg-4, 
    #chartsCollapse .col-md-12, 
    #chartsCollapse .col-md-6 {
        width: 33% !important;
        max-width: 33% !important;
        flex: 0 0 33% !important;
        margin-bottom: 0 !important;
        page-break-inside: avoid !important;
        padding: 0 5px !important;
    }

    #chartsCollapse .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        height: 100% !important;
    }

    #chartsCollapse .card-header {
        padding: 5px 10px !important;
        font-size: 0.8rem !important;
    }

    #chartsCollapse canvas {
        max-height: 150px !important; /* Reduced height to ensure fit */
        width: 100% !important;
    }

    /* Student Record Specific Print Styles */
    .tab-content > .tab-pane {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        margin-bottom: 20px !important;
        page-break-inside: avoid !important;
    }

.nav-tabs {
    display: none !important;
}

    #topViolationsChart {
        transform: none !important;
    }
}
