/* =============================================================================
   print-popup.css — ورقة الطباعة المشتركة لكل ما يُطبع من نافذة المتصفّح.
   -----------------------------------------------------------------------------
   لماذا ملفٌّ واحد: دالّة `Popup()` مكرّرة في **70 موضعًا** في المشروع، ولا
   واحدة منها تضبط مقاس الورقة — فكل جدول حضور وجدول حصص وتقرير سلوك وكشف
   حافلات يخرج على ما في الطابعة، وعلى Letter الأمريكيّ في معاينة المتصفّح.
   ومصر تطبع على A4.                                                (2026-09-13)
   ========================================================================== */

@page { size: A4; margin: 12mm 10mm; }

@media print {
    /* الألوان تُطبع كما تُعرض: بدونها تخرج رؤوس الجداول بيضاء بلا حدّ فتضيع
       بنية الجدول على الورق. */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    html, body { background: #fff !important; }
    body { font-family: Cairo, Tahoma, Arial, sans-serif; font-size: 11pt; color: #1d2430; }

    /* عناصر الشاشة لا مكان لها على الورق. */
    .no-print, .noprint, .btn, button, nav, .navbar, .sidebar, .main-sidebar,
    .main-header, .main-footer, .dataTables_filter, .dataTables_length,
    .dataTables_paginate, .dataTables_info, .paging_simple_numbers,
    .dt-buttons, .box-tools, .pagination { display: none !important; }

    /* الجداول: لا تُقصّ صفوفها بين صفحتين، ويتكرّر رأسها في كل صفحة. */
    table { width: 100% !important; border-collapse: collapse !important;
            page-break-inside: auto; }
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }
    tr    { page-break-inside: avoid; page-break-after: auto; }
    th, td { border: 1px solid #b9c0cb !important; padding: 4px 6px !important;
             font-size: 9.5pt !important; }
    th { background: #f1f3f6 !important; font-weight: 700; }

    /* الأرقام والمبالغ لا تُكسر عبر سطرين ولا تنقلب اتجاهًا وسط نصّ عربيّ. */
    td.num, th.num, .amount, .money, .text-right { white-space: nowrap; }

    a[href]:after { content: "" !important; }   /* لا يُطبع الرابط بين قوسين */
    img { max-width: 100% !important; }
}

/* nmPrintOnly (print-window.js, 2026-10-22): جزءٌ واحد من الصفحة يُطبع بتنسيقها نفسه — يُخفى كل ما خارج فرعه
   (الترويسة، الشريط السفلي، القوائم)، وتُصفَّر حواشي آبائه التي تحجز مكان الترويسة الثابتة. */
@media print {
    html.nm-printing body > :not(.nm-pp),
    html.nm-printing .nm-pp:not(.nm-pp-root) > :not(.nm-pp) { display: none !important; }
    html.nm-printing .nm-pp:not(.nm-pp-root) {
        margin: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important;
        min-height: 0 !important; max-width: none !important; width: auto !important;
        position: static !important; transform: none !important; background: #fff !important;
    }
    html.nm-printing .nm-pp-root { margin: 0 !important; box-shadow: none !important; filter: none !important; }
    /* ما يُطلب من الشاشة لا يُطبع: أزرار الشهادتين والمشاركة، ونموذج التظلّم. */
    html.nm-printing .no_print, html.nm-printing .nmx-ap-form, html.nm-printing .nmx-docs { display: none !important; }
    /* سطور للورق وحده (اسم الطالب): مخفيّة على الشاشة بـ .hide */
    html.nm-printing .nm-print-show.hide { display: block !important; }
    html.nm-printing .nmx-print-name { font-size: 14pt; font-weight: 700; margin: 0 0 8px; color: #1d2430; }
    html.nm-printing tr.nm-print-show.hide { display: table-row !important; }
    /* الطباعة من نافذةٍ منبثقة (جدول الامتحان): الصفحة تحت النافذة مقفولة التمرير (modal-open)، وأيّ صندوق تمريرٍ
       داخل الجزء يقصّ ما تحته — كلاهما يُفتح على الورق فلا تقف الطباعة عند أوّل صفحة. */
    html.nm-printing, html.nm-printing body { overflow: visible !important; height: auto !important; }
    html.nm-printing .nm-pp { overflow: visible !important; max-height: none !important; height: auto !important; }
    html.nm-printing .nm-pp-root .scroll-area, html.nm-printing .nm-pp-root .scroll-full, html.nm-printing .nm-pp-root .scroll-full-70,
    html.nm-printing .nm-pp-root .table-responsive, html.nm-printing .nm-pp-root .modal-body { overflow: visible !important; max-height: none !important; height: auto !important; }
    html.nm-printing .modal-footer, html.nm-printing .modal-header .close { display: none !important; }
    /* نافذةٌ على الفرع المطبوع تُعرض وإن أخفت الصفحة .modal في الطباعة (جدول الامتحانات كان يُخفيها لطريقته القديمة). */
    html.nm-printing .modal.nm-pp { display: block !important; opacity: 1 !important; }
    /* البطاقة لا تُقصّ بين صفحتين ما أمكن */
    html.nm-printing .nmx-exam { break-inside: avoid; }
    /* bootstrap 3 يمحو في الطباعة كل خلفية ولون ({*{background:0 0!important;color:#000!important}}) فتخرج حلقة النسبة
       وأشرطة الموادّ فارغة. تُعاد هنا داخل البطاقة وحدها بألوان الشاشة (portal-shell.css). */
    html.nm-printing .nmx-ring { background: conic-gradient(var(--nmx-c, #1f8a4c) calc(var(--nmx-pc, 0) * 1%), #eef2f6 0) !important; }
    html.nm-printing .nmx-exam[data-state="fail"] .nmx-ring { background: conic-gradient(#c0392b calc(var(--nmx-pc, 0) * 1%), #f7e9e7 0) !important; }
    html.nm-printing .nmx-ring-in { background: #fff !important; }
    html.nm-printing .nmx-sub-bar { background: #eef2f6 !important; }
    html.nm-printing .nmx-sub-bar > i { background: #1f8a4c !important; }
    html.nm-printing .nmx-sub.is-fail .nmx-sub-bar { background: #f7e9e7 !important; }
    html.nm-printing .nmx-sub.is-fail .nmx-sub-bar > i { background: #c0392b !important; }
    html.nm-printing .nmx-sub-m b { color: #1f8a4c !important; }
    html.nm-printing .nmx-sub.is-fail .nmx-sub-m b { color: #c0392b !important; }
    html.nm-printing .nmx-chip { color: #fff !important; background: #1f8a4c !important; }
    html.nm-printing .nmx-exam[data-state="fail"] .nmx-chip { background: #c0392b !important; }
}

/* =============================================================================
   nm-paper — زرّ «طباعة» في صفحات التقارير والقوائم (admin/_partials/print_button + nmPaperPrint في print-window.js).
   -----------------------------------------------------------------------------
   الصفحة نفسها تُطبع على A4: ترويسة المدرسة المعتمدة (صورة «ترويسة الطباعة» العامّة) وعنوان التقرير وسطر الفترة
   والجهة في أوّل ورقة، ثم المحتوى بلا الهيدر والقائمة والفلاتر والأزرار، وتوقيعات «أعدّه/راجعه/اعتمده» حين تطلبها
   الصفحة. رقم الصفحة ووقت الطباعة في هامش كل ورقة (@page في nmPaperPrint).  المالك 2026-10-30: «فين أزرار الطباعة؟»
   ========================================================================== */
@media print {
    html.nm-paper, html.nm-paper body, html.nm-paper .wrapper, html.nm-paper .content-wrapper { background: #fff !important; }
    html.nm-paper body { font-size: 10pt; color: #1d2430; }
    html.nm-paper .content-wrapper { padding: 0 !important; min-height: 0 !important; }
    html.nm-paper .content-wrapper > .content, html.nm-paper .content-wrapper > section { padding: 0 !important; margin: 0 !important; max-width: none !important; }
    /* رأس الشاشة (العنوان والفلاتر والأزرار) تحلّ محلّه الترويسة. */
    html.nm-paper .nm-pagehead, html.nm-paper .cr-head, html.nm-paper .content-header, html.nm-paper .nm-screen-h,
    html.nm-paper .nm-es-note, html.nm-paper .nm-print-btn, html.nm-paper .no_print, html.nm-paper .no-print,
    html.nm-paper .modal, html.nm-paper .tooltip, html.nm-paper .popover,
    html.nm-paper .dt-search, html.nm-paper .dt-length, html.nm-paper .dt-paging, html.nm-paper .dt-buttons,
    html.nm-paper form.cr-card, html.nm-paper .cr-tabs, html.nm-paper a.cr-note { display: none !important; }
    /* قواعد :has() منفصلة: متصفّحٌ لا يعرفها يُسقط قاعدتها وحدها لا كل ما سبق (المراجعة الهندسية).
       نماذج الإجراءات (فلترة، تسليم، تقديم إقرار، إضافة…) بلا جدولٍ ولا قائمة، وصندوق «إضافة …» الذي نموذجه كل محتواه، والقسم المطويّ
       الذي فيه نموذج — لا مكان لها على الورق؛ وصندوقٌ فيه بياناتٌ ونموذج (قفل الدفاتر وسجلّه) يبقى ويختفي نموذجه وحده — إلا صفحةً
       نماذجها هي المحتوى (بيانات الشركة: nm-pp-forms). */
    html.nm-paper form[method="get" i]:not(:has(table)) { display: none !important; }
    html.nm-paper:not(.nm-pp-forms) form:not(:has(table)):not(:has(ul, ol)) { display: none !important; }
    html.nm-paper:not(.nm-pp-forms) .box:has(> .box-body > form:only-child) { display: none !important; }
    html.nm-paper:not(.nm-pp-forms) details:has(form):not(:has(table)):not(:has(ul, ol)) { display: none !important; }
    html.nm-paper input[type="date"]:not([value]), html.nm-paper input[type="date"][value=""] { visibility: hidden !important; }
    html.nm-paper .nm-pp-n { white-space: nowrap !important; direction: ltr; unicode-bidi: isolate; }
    html.nm-paper .dt-info, html.nm-paper .nm-pp-x, html.nm-paper a[data-confirm], html.nm-paper .nm-confirm { display: none !important; }
    /* «المطبوع: الصفوف 1–50 من 23,512» فوق جدولٍ يُحمَّل من الخادم صفحةً صفحة. */
    html.nm-paper .nm-pp-note { display: block !important; font-size: 8.5pt; color: #4b5563; margin: 0 0 2mm; }
    /* هامش bootstrap السالب يُخرج الصفوف عن حافّة الورقة (يُقصّ أوّل حرف). */
    html.nm-paper .row { margin-inline: 0 !important; }
    html.nm-paper .box, html.nm-paper .cr-card, html.nm-paper .panel, html.nm-paper .nav-tabs-custom, html.nm-paper .info-box, html.nm-paper .small-box {
        box-shadow: none !important; border: 0 !important; border-radius: 0 !important; background: #fff !important; margin: 0 0 5mm !important; }
    html.nm-paper .box-header { padding: 0 0 1.6mm !important; border: 0 !important; background: none !important; }
    html.nm-paper .box-title, html.nm-paper .cr-card h2, html.nm-paper .cr-card h3 { font-size: 11pt !important; font-weight: 700 !important; color: var(--nm-maroon, #5F060C) !important; }
    html.nm-paper .box-body, html.nm-paper .panel-body { padding: 0 !important; }
    html.nm-paper .table-responsive, html.nm-paper .dt-container, html.nm-paper .dataTables_wrapper, html.nm-paper .dt-layout-table,
    html.nm-paper .dt-scroll, html.nm-paper .dt-scroll-body { overflow: visible !important; max-height: none !important; height: auto !important; border: 0 !important; }
    html.nm-paper table { width: 100% !important; margin: 0 0 3mm !important; border-collapse: collapse !important; }
    html.nm-paper table th, html.nm-paper table td { border: 0.2mm solid #c9cfd8 !important; padding: 1.1mm 1.8mm !important; font-size: 9pt !important;
        line-height: 1.45 !important; vertical-align: middle !important; }
    html.nm-paper table th { background: #f6f2ef !important; color: var(--nm-maroon, #5F060C) !important; font-weight: 700 !important; }
    /* الإجماليّ مرّةً واحدة في آخر الجدول — tfoot المتكرّر يطبع «إجمالي الأصول» أسفل كل ورقة كأنه رقمها. */
    html.nm-paper tfoot { display: table-row-group !important; }
    html.nm-paper tfoot td, html.nm-paper tfoot th { font-weight: 700 !important; background: #faf7f4 !important; }
    html.nm-paper a { color: inherit !important; text-decoration: none !important; }
    html.nm-paper .label, html.nm-paper .badge { background: none !important; color: #374151 !important; border: 0.2mm solid #c9cfd8 !important;
        font-weight: 600 !important; padding: 0 1.2mm !important; }
    html.nm-paper .alert { border-radius: 0 !important; padding: 1.6mm 2.4mm !important; font-size: 8.5pt !important; margin: 0 0 4mm !important; }
    html.nm-paper input, html.nm-paper select, html.nm-paper textarea { border: 0 !important; box-shadow: none !important; background: none !important; padding: 0 !important; }
    html.nm-paper h1, html.nm-paper h2, html.nm-paper h3, html.nm-paper h4 { break-after: avoid; }
    html.nm-paper canvas, html.nm-paper svg, html.nm-paper img { break-inside: avoid; }

    /* الترويسة: تُدرَج مخفيّة (hidden) فلا تظهر على الشاشة بعد الطباعة. */
    html.nm-paper .nm-paper-head[hidden] { display: block !important; margin: 0 0 4.5mm; }
    html.nm-paper .nm-ph-img { display: block; width: 100%; height: auto; }
    html.nm-paper .nm-ph-brand { display: flex; direction: ltr; align-items: center; gap: 4mm; padding-bottom: 2.4mm; border-bottom: 0.6mm solid var(--nm-maroon, #5F060C); }
    html.nm-paper .nm-ph-brand img { flex: 0 0 15mm; width: 15mm; height: 15mm; object-fit: contain; }
    html.nm-paper .nm-ph-brand > div { flex: 1 1 auto; direction: rtl; text-align: start; }
    html.nm-paper .nm-ph-brand b { display: block; font-size: 15pt; color: var(--nm-maroon, #5F060C); line-height: 1.3; }
    html.nm-paper .nm-ph-brand small { display: block; font-size: 8pt; color: var(--nm-gold, #C6A570); font-weight: 700; letter-spacing: .06em; }
    html.nm-paper .nm-ph-title { text-align: center; margin-top: 3.6mm; }
    html.nm-paper .nm-ph-title h1 { display: inline-block; margin: 0; padding: 0 5mm 1.2mm; font-size: 14pt; font-weight: 700; color: var(--nm-maroon, #5F060C);
        border-bottom: 0.4mm solid var(--nm-gold, #C6A570); }
    html.nm-paper .nm-ph-sub { font-size: 9.5pt; color: #4b5563; margin-top: 1.4mm; }
    html.nm-paper .nm-ph-sub bdi, html.nm-paper .nm-ph-sub .n { unicode-bidi: isolate; direction: ltr; white-space: nowrap; }

    html.nm-paper .nm-paper-sign[hidden] { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 8mm; margin-top: 9mm;
        break-inside: avoid; page-break-inside: avoid; break-before: avoid; page-break-before: avoid; }
    html.nm-paper .nm-paper-sign > div { text-align: center; font-size: 9.5pt; font-weight: 600; color: #1d2430; }
    /* خطّ التوقيع حدٌّ لا خلفيّة: bootstrap يمحو كل خلفيّة في الطباعة. */
    html.nm-paper .nm-paper-sign .rl { height: 0; border-top: 0.3mm solid #6b7280; margin: 13mm 0 1.6mm; }
    html.nm-paper .nm-paper-sign small { display: block; font-weight: 400; color: #6b7280; font-size: 8.5pt; }
    /* توقيعان أو أربعة بدل ثلاثة (أدوارٌ خاصّة بالمستند) */
    html.nm-paper .nm-paper-sign:has(> div:nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 60mm)); justify-content: space-around; }
    html.nm-paper .nm-paper-sign:has(> div:nth-child(4)) { grid-template-columns: repeat(4, 1fr); }
}
