/* أنماط الطباعة (الوصولات + الكشوف) */
#print-receipt-section, #print-list-section, #print-all-receipts-section, #print-phones-section, #print-admin-stats-section, #print-financial-stats-section, #print-attendance-section, #print-names-section { display: none; }
.model-receipt { border: 2.5px solid #000; padding: 15px 20px; background: #fff; position: relative; box-sizing: border-box; page-break-inside: avoid; }
.copy-type-badge { display: inline-block; font-weight: bold; font-size: 0.9em; color: var(--danger-color); border: 1px solid var(--danger-color); padding: 2px 10px; border-radius: 4px; background: #fff5f5; white-space: nowrap; }
.sig-mid { flex-grow: 1; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 2px; }
.receipt-no { font-size: 0.95em; font-weight: bold; margin-top: 4px; }
.receipt-no span { color: var(--danger-color); }
.model-receipt-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; padding-top: 5px; }
.amount-boxes { display: flex; gap: 6px; text-align: center; }
.amount-box-item { display: flex; flex-direction: column; align-items: center; }
.amount-box-item label { font-size: 0.85em; font-weight: bold; margin-bottom: 4px; }
.amount-box-item .box-val { border: 2px solid #000; width: 65px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 1.1em; font-weight: bold; color: var(--danger-color); }
.receipt-main-title { text-align: center; flex-grow: 1; padding-top: 5px; }
.receipt-main-title h1 { margin: 0; font-size: 1.6em; font-weight: 800; text-decoration: underline; letter-spacing: 1px; color: #000; }
.receipt-date-box { font-weight: bold; font-size: 1.05em; padding-top: 5px; }
.receipt-date-box span, .red-var { color: var(--danger-color); }
.receipt-line-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 1em; font-weight: bold; }
.receipt-line-row .ar-label { text-align: right; width: 120px; }
.receipt-line-row .en-label { font-family: Arial, sans-serif; direction: ltr; text-align: left; width: 130px; }
.receipt-line-row .line-fill { flex-grow: 1; border-bottom: 1.5px dotted #000; margin: 0 10px; text-align: center; font-size: 1.1em; color: var(--danger-color); padding-bottom: 2px; }
.receipt-signatures { display: flex; justify-content: space-between; margin-top: 22px; padding: 0 20px; font-weight: bold; font-size: 1.05em; }
.sig-item { text-align: center; width: 180px; }
.sig-line { border-bottom: 1px dotted #000; margin-top: 20px; width: 100%; }
@media print {
    body { background: #fff; padding: 0; margin: 0; }
    #app-content, #login-overlay, .section-bar, .custom-modal, #toast-container, #dialog-modal { display: none !important; }
    #print-receipt-section, #print-all-receipts-section, #print-list-section, #print-phones-section, #print-admin-stats-section, #print-financial-stats-section, #print-attendance-section { display: none !important; }
    body.print-mode-receipt #print-receipt-section { display: block !important; }
    body.print-mode-all #print-all-receipts-section { display: block !important; }
    body.print-mode-list #print-list-section { display: block !important; }
    body.print-mode-phones #print-phones-section { display: block !important; }
    body.print-mode-admin #print-admin-stats-section { display: block !important; }
    body.print-mode-financial #print-financial-stats-section { display: block !important; }
    body.print-mode-attendance #print-attendance-section { display: block !important; }
    #print-names-section { display: none !important; }
    body.print-mode-names #print-names-section { display: block !important; }
    @page { size: A4; margin: 1cm; }
    #print-all-receipts-section { height: 27.7cm; display: flex; flex-direction: column; }
    .receipt-page { height: 27.7cm; display: flex; flex-direction: column; page-break-after: always; }
    .receipt-page:last-child { page-break-after: auto; }
    .receipt-page-container { display: flex; flex-direction: column; height: 100%; justify-content: space-between; }
    .model-receipt { flex: 1; display: flex; flex-direction: column; justify-content: space-between; padding: 10px !important; margin: 0 !important; border: 1.5px solid #000 !important; box-sizing: border-box; }
    .receipt-separator { height: 1cm; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; position: relative; }
    .receipt-separator hr { width: 100%; border: none; border-top: 2px dashed #000; margin: 0; position: absolute; top: 50%; z-index: 1; }
    .receipt-separator span { background: #fff; padding: 0 10px; font-size: 14px; color: #000; z-index: 2; position: relative; }
    .print-class-block { page-break-after: always; page-break-inside: avoid; }
    .print-class-block:last-child { page-break-after: auto; }
}
/* قائمة متابعة الغياب: كل فصل في صفحة A4 واحدة */
@media print {
    .att-page { height: 27.6cm; overflow: hidden; box-sizing: border-box; display: flex; flex-direction: column; page-break-after: always; break-after: page; page-break-inside: avoid; }
    .att-page:last-child { page-break-after: auto; break-after: auto; }
    .att-head { height: 1.9cm; flex: none; display: flex; flex-direction: column; justify-content: center; text-align: center; overflow: hidden; }
    .att-tw { flex: 1; min-height: 0; }
    .att-head h2 { margin: 0 0 2px; font-size: 16px; } .att-head h3 { margin: 0 0 2px; font-size: 13px; } .att-head p { margin: 0; font-size: 12px; }
    .att-print-table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
    .att-print-table col.c-no { width: 1cm; } .att-print-table col.c-name { width: 5.6cm; }
    .att-print-table th, .att-print-table td { border: 1px solid #000; text-align: center; padding: 0; overflow: hidden; line-height: 1.1; color: #000; }
    .att-print-table th small { display: block; font-size: 8px; font-weight: normal; }
    .att-print-table td.nm { text-align: right; padding: 0 4px; white-space: nowrap; }
    .att-foot { height: 0.7cm; flex: none; display: flex; align-items: center; justify-content: center; font-size: 10px; text-align: center; color: #000; }
}

/* كشف أسماء الطلاب فقط: كل فصل في صفحة (أو أكثر إن كثر الطلاب) */
@media print {
    .names-page { page-break-after: always; break-after: page; }
    .names-page:last-child { page-break-after: auto; break-after: auto; }
    .names-head { text-align: center; margin-bottom: 10px; color: #000; }
    .names-head { height: 1.45cm; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; overflow: hidden; margin: 0 !important; } .names-head h2 { margin: 0 0 2px; font-size: 17px; } .names-head h3 { margin: 0 0 2px; font-size: 14px; } .names-head p { margin: 0 0 4px; font-size: 12px; }
    .names-table { width: 100%; border-collapse: collapse; }
    .names-table th, .names-table td { border: 1px solid #000; padding: 0 6px; height: 0.7cm; font-size: 12px; color: #000; text-align: center; line-height: 1; }
    .names-table th { background: #eee; }
    .names-table td.n-no { width: 1.2cm; text-align: center; }
    .names-table td.n-name { text-align: right; font-weight: 700; width: 5.5cm; }
    .names-table tr { page-break-inside: avoid; }
}

/* القوائم المطبوعة: 35 طالباً في الورقة الواحدة */
@media print {
    .pg-head { height: 1.45cm; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; overflow: hidden; margin: 0 !important; }
    .pg-head h2 { margin: 0 0 2px !important; font-size: 17px; } .pg-head h3 { margin: 0 0 2px !important; font-size: 14px; } .pg-head p { margin: 0 !important; font-size: 12px; }
    .pg-table th, .pg-table td { padding: 0 5px !important; height: 0.7cm !important; font-size: 11.5px !important; line-height: 1 !important; }
    .pg-table tr { page-break-inside: avoid; }
    .pg-more { page-break-after: always; break-after: page; }
}

/* متابعة الغياب بالطباعة الأفقية (A4 أفقي: المساحة 27.7 × 19سم) */
@media print {
    .att-page.att-land { height: 18.9cm; }
    .att-land .att-head { height: 1.5cm; }
    .att-land .att-foot { height: 0.6cm; }
    .att-land .att-print-table col.c-name { width: 4.4cm; }
    .att-land .att-print-table td.nm { font-weight: 800; padding: 0 5px; vertical-align: middle; }
    .att-land .att-print-table td { font-size: inherit; }
}
@media print {
    .names-table th, .pg-table th { white-space: nowrap; font-size: 11px !important; }
}
@media print { .pg-table { margin: 0 !important; } }

.receipt-note { text-align: center; font-weight: 800; font-size: 0.85em; margin-top: 8px; color: #000; }

/* الطباعة الجماعية (3 وصولات في الورقة): ضغط بسيط للمسافات ليتسع سطر "لا يعتد بهذا الوصل" دون ورقة إضافية */
@media print {
    #print-all-receipts-section .model-receipt-top { margin-bottom: 8px; }
    #print-all-receipts-section .receipt-line-row { margin-bottom: 7px; }
    #print-all-receipts-section .receipt-signatures { margin-top: 12px; }
    #print-all-receipts-section .sig-line { margin-top: 14px; }
    #print-all-receipts-section .receipt-note { margin-top: 5px; }
}

/* الطباعة الجماعية: هامش أمان في الارتفاع حتى لا يُقصّ الوصل الثالث إذا كانت مساحة الطباعة الفعلية أقل قليلاً من A4 */
@media print {
    #print-all-receipts-section, #print-all-receipts-section .receipt-page { height: 26cm; }
    #print-all-receipts-section .receipt-separator { height: 0.7cm; }
    #print-all-receipts-section .model-receipt { padding: 8px 10px !important; }
    #print-all-receipts-section .model-receipt-top { margin-bottom: 4px; padding-top: 2px; }
    #print-all-receipts-section .receipt-line-row { margin-bottom: 4px; line-height: 1.3; }
    #print-all-receipts-section .receipt-signatures { margin-top: 8px; }
    #print-all-receipts-section .sig-line { margin-top: 10px; }
    #print-all-receipts-section .receipt-note { margin-top: 4px; }
}

/* وصولات فارغة لإكمال الورقة إلى 3 (تحفظ الحجم ولا تُطبع) */
@media print { .receipt-spacer { visibility: hidden !important; border-color: transparent !important; } }
