/* =========================================================
   print.css — تنسيق الطباعة لكل النظام (Ctrl+P أو "طباعة" من المتصفح)
   =========================================================
   قبل الملف ده كانت طباعة أي صفحة بتطلع القائمة الجانبية بس (متكررة
   في كل ورقة) والمحتوى نفسه مش ظاهر، والجداول العريضة بتتقص، والنصوص
   الطويلة (زي "بيان البند") مش بتتطبع كاملة.
   دلوقتي:
   - بيتطبع محتوى الصفحة بس (من غير القائمة الجانبية والأزرار).
   - كل الجداول بتتطبع بعرض الورقة كاملة، والنص الطويل بينزل سطر جديد.
   - عناوين الجدول بتتكرر في أول كل ورقة، والصف الواحد مش بيتقسم.
   - لو فيه نافذة (تفاصيل) مفتوحة وقت الطباعة، بتتطبع النافذة دي بس.
   ========================================================= */

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

  html, body {
    background: #fff !important; color: #000 !important;
    overflow: visible !important; height: auto !important;
    font-size: 11pt;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  body.scroll-locked { overflow: visible !important; }

  /* إيقاف كل الحركات (بعضها بيبدأ من opacity:0 فالمحتوى بيختفي في الطباعة) */
  *, *::before, *::after { animation: none !important; transition: none !important; }

  /* عناصر الواجهة اللي مالهاش لازمة في الورق */
  .sidebar, .sidebar-overlay, #sidebarToggle, .topbar-actions,
  .toast-host, #splash, .login-screen,
  button, .btn-primary, .btn-ghost, .file-upload-btn, .cam-actions,
  .camera-box, video, .modal-close, .no-print { display: none !important; }

  /* الهيكل: صفحة واحدة بعرض الورقة */
  .app-shell { display: block !important; min-height: 0 !important; background: #fff !important; }
  .main-area { margin: 0 !important; min-height: 0 !important; display: block !important; }
  .topbar {
    position: static !important; box-shadow: none !important; background: #fff !important;
    border-bottom: 2px solid #000 !important; padding: 0 0 6px !important; margin-bottom: 10px;
  }
  .topbar-title { font-size: 15pt !important; color: #000 !important; }
  .content { padding: 0 !important; }

  /* الكروت تحت بعض بعرض الورقة (بدل الأعمدة) */
  .section-grid, .dashboard-grid { display: block !important; }
  .card {
    box-shadow: none !important; background: #fff !important;
    border: 1px solid #bbb !important; border-radius: 6px !important;
    padding: 8px 10px !important; margin: 0 0 10px !important;
    break-inside: auto; page-break-inside: auto;
  }
  .card-head { margin-bottom: 6px !important; }
  .card-head h3 { font-size: 12pt !important; color: #000 !important; }
  .hint-text { color: #444 !important; font-size: 9pt !important; }

  /* حقول الفلتر بتتطبع كقيم (عشان الفترة المطبوعة تبان) من غير شكل الحقل */
  .field input, .field select, .form-grid select {
    border: none !important; background: transparent !important; padding: 0 !important;
    color: #000 !important; font-weight: bold; -webkit-appearance: none; appearance: none;
  }
  .form-grid { gap: 6px !important; }

  /* الجداول: عرض الورقة كله + لفّ النص الطويل + تكرار العناوين */
  .table-wrap { overflow: visible !important; border: none !important; }
  .data-table, .roster-table {
    min-width: 0 !important; width: 100% !important; font-size: 9.5pt !important;
    border-collapse: collapse !important;
  }
  .data-table thead { display: table-header-group; }
  .data-table tr, .roster-table tr { break-inside: avoid; page-break-inside: avoid; }
  .data-table th, .data-table td, .roster-table th, .roster-table td {
    border: 1px solid #999 !important; padding: 4px 6px !important;
    white-space: normal !important; word-break: normal; overflow-wrap: break-word;
    color: #000 !important; background: #fff !important;
  }
  .data-table th { background: #eef2f8 !important; font-weight: bold; }
  .row-overdue td { background: #fdecee !important; }

  /* إحصائيات صغيرة جنب بعض */
  .mini-stats { display: flex !important; flex-wrap: wrap; gap: 6px !important; }
  .mini-stat { border: 1px solid #ccc !important; background: #fff !important; padding: 6px !important; min-width: 0 !important; flex: 1 1 22% !important; }
  .mini-stat .mini-num { color: #000 !important; font-size: 12pt !important; }

  /* الشرائح/الشارات تفضل مقروءة */
  .test-chip, .badge, .cb-status, .overdue-tag, .late-tag {
    border: 1px solid #888 !important; background: #fff !important; color: #000 !important;
    box-shadow: none !important; animation: none !important;
  }
  .test-stack { gap: 3px !important; }
  canvas { max-width: 100% !important; height: auto !important; }

  /* الأكورديون: بيتطبع زي ما هو ظاهر (المقفول يفضل مقفول) */
  .admin-accordion-head { background: #fff !important; padding: 6px 8px !important; }

  /* ===== لو فيه نافذة مفتوحة وقت الطباعة: نطبع النافذة بس ===== */
  body:has(#genericModal:not(.hidden)) #appShell { display: none !important; }
  .modal:not(.hidden) {
    position: static !important; inset: auto !important; display: block !important;
    background: #fff !important; padding: 0 !important; overflow: visible !important;
  }
  .modal-box {
    max-width: none !important; max-height: none !important; width: 100% !important;
    margin: 0 !important; box-shadow: none !important; overflow: visible !important; border-radius: 0 !important;
  }
  .modal-box h3 { position: static !important; border-bottom: 2px solid #000 !important; }
  .print-preview-area { max-height: none !important; overflow: visible !important; border: none !important; padding: 0 !important; }
}
