/* ==========================================================================
   OFFICIAL RECORDS STYLING v2.0 - EXACT MATCH TO IRAQI MINISTRY FORMATS
   ========================================================================== */

/* 1. Global Print & Sheet Settings */
@media print {
    body { 
        margin: 0; 
        padding: 0; 
        display: flex; 
        flex-direction: column; 
        align-items: center; 
        background: white !important;
    }
    .official-record-sheet {
        position: relative !important;
        margin: 10mm auto !important;
        padding: 20px !important;
        border: 4px double #000 !important;
        page-break-after: always !important;
        width: 205mm !important; /* الهامش لضمان السنترة في معظم الطابعات */
        min-height: 290mm !important;
        box-shadow: none !important;
        visibility: visible !important;
    }
    .official-record-sheet.landscape-mode {
        width: 290mm !important;
        min-height: 205mm !important;
    }
    /* فرض طباعة الألوان والخلفيات */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    .action-btn-group, .navbar, .header, #monthly-mode-options { display: none !important; }
}

.official-record-sheet {
    background: white;
    padding: 20px;
    margin: 20px auto;
    font-family: 'Times New Roman', serif;
    border: 3px double #000;
    width: 210mm; /* Standard A4 Portrait */
    min-height: 297mm;
    max-width: 100%; 
    box-sizing: border-box;
    position: relative;
    overflow: hidden; /* Prevent internal content from stretching without scroll */
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    transition: width 0.3s ease-in-out;
}

.official-record-sheet.landscape-mode {
    width: 297mm;
    min-height: 210mm;
}

.official-record-sheet table {
    width: 100% !important;
    border-collapse: collapse;
}

/* ==========================================================================
   2. Staff Attendance Record (سجل الملاك - التصميم الذهبي)
   ========================================================================== */
.staff-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #b8860b;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.staff-title-banner {
    background: linear-gradient(to bottom, #fdfbf7, #fffbe6);
    border: 2px solid #daa520;
    padding: 10px 40px;
    border-radius: 15px 0 15px 0;
    color: #b22222;
    font-weight: 900;
    font-size: 1.5rem;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    text-shadow: 1px 1px 0 #fff;
}

.staff-table {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid #000;
}

.staff-table th {
    background-color: #fcfcfc;
    color: #000;
    font-weight: bold;
    border: 1px solid #000;
    padding: 8px 2px;
    font-size: 14px;
}

.staff-table td {
    border: 1px solid #000;
    height: 35px;
    padding: 0 5px;
    text-align: center;
}

/* ==========================================================================
   3. Student Absence Record (سجل الغيابات - التصميم الشبكي العمودي)
   ========================================================================== */
.absence-sheet-border {
    border: 4px solid #1a237e; /* الإطار الأزرق الخارجي */
    padding: 5px;
}

.absence-inner-border {
    border: 1px solid #000;
    padding: 5px;
}

.absence-table {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid #000;
    table-layout: fixed; /* لتثبيت العرض */
}

/* النصوص العمودية للأيام (1-31) */
.vertical-day-header {
    height: 120px;
    vertical-align: bottom;
    padding-bottom: 5px;
    background-color: #f9f9f9;
    width: 2.2%; /* لتناسب 31 يوم + الاسم */
    border: 1px solid #000;
    font-size: 12px;
}

.rotate-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.absence-cell {
    border: 1px solid #000;
    padding: 0;
    height: 25px;
    text-align: center;
    background: #fff;
}

.absence-input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    background: transparent;
    font-weight: bold;
    color: red; /* الغياب يكتب بالأحمر عادة */
}

/* ==========================================================================
   4. Student Guidance Form (استمارة الإرشاد - المربعات الدقيقة)
   ========================================================================== */
.guidance-title {
    background-color: #ffff00;
    text-align: center;
    font-weight: 900;
    font-size: 1.2rem;
    padding: 8px;
    border: 2px solid #000;
    margin-bottom: 20px;
}

/* نظام الشبكة للحقول (Label Box + Input Box) */
.guidance-row {
    display: flex;
    border: 1px solid #000; /* الإطار الخارجي للسطر */
    border-bottom: none; /* لتجنب تكرار الحدود */
    height: 40px; /* ارتفاع موحد للسطر */
}
.guidance-row:last-child { border-bottom: 1px solid #000; }

.g-cell {
    display: flex;
    border-left: 1px solid #000; /* فاصل بين الحقول */
}
.g-cell:last-child { border-left: none; }

.g-label {
    background-color: #f2f2f2; /* رمادي فاتح للعنوان */
    padding: 5px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-left: 1px solid #000;
    font-size: 13px;
    white-space: nowrap;
}

.g-input-box {
    flex-grow: 1;
    display: flex;
    align-items: center;
    padding: 0 5px;
    background: white;
}

.g-input-box input {
    width: 100%;
    border: none;
    outline: none;
    font-weight: bold;
    font-size: 14px;
}

/* مربعات الاختيار (نعم/لا - مربعات صغيرة) */
.checkbox-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
}
.check-item {
    border: 1px solid #000;
    padding: 2px 10px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

/* ==========================================================================
   5. Grading Records (الامتحانات - الثيمات المتعددة حسب الصورة)
   ========================================================================== */
.grading-table-container {
    width: 100%;
    border: 2px solid #000;
    margin-top: 5px;
}

.grading-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

/* الرؤوس المشتركة */
.grading-table th {
    border: 1px solid #000;
    padding: 4px;
    text-align: center;
    font-weight: bold;
    line-height: 1.2;
}

/* الثيم البنفسجي (إنجليزي) */
.theme-purple th.main-header { background-color: #e1bee7; } /* بنفسجي فاتح للرأس */
.theme-purple th.sub-header { background-color: #f3e5f5; } 
.theme-purple td.active-col { background-color: #fdf2ff; } /* تلوين أعمدة الدرجات */

/* الثيم الأخضر (علوم/إسلامية) */
.theme-green th.main-header { background-color: #c8e6c9; }
.theme-green th.sub-header { background-color: #e8f5e9; }
.theme-green td.active-col { background-color: #f1f8e9; }

/* الثيم الأصفر (عام) */
.theme-yellow th.main-header { background-color: #fff9c4; }
.theme-yellow th.sub-header { background-color: #fffde7; }

/* الثيم البرتقالي/بيج (صور الدرجات الكبيرة) */
.theme-beige th.main-header { background-color: #ffe0b2; } /* برتقالي فاتح */
.theme-beige th.sub-header { background-color: #fff3e0; }

/* المدخلات */
.grading-table input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    background: transparent;
    font-family: Arial;
    font-weight: bold;
    font-size: 13px;
}

.cell-gray { background-color: #eee; } /* للخلايا المحسوبة */

/* ترويسة الجدول المنحنية (قائمة الدرجات - الشكل الجمالي) */
.curved-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #fdfdfd;
}

.curved-title-box {
    background-color: #e6e6fa; /* لوني ليلكي خفيف للصورة البنفسجية */
    border: 2px solid #8e24aa;
    padding: 5px 30px;
    border-radius: 20px;
    text-align: center;
    color: #4a148c;
    font-weight: bold;
}

.theme-purple .curved-title-box { border-color: #8e24aa; color: #4a148c; }