/* ==========================================================================
   print.css — طباعة أي صفحة في التطبيق.

   النسخة القديمة كان لديها كتلة @media print واحدة مكتوبة لصفحة الإحصائيات
   فقط، وبها ثلاث مشكلات: (1) أرقام الإحصاء كانت بيضاء على خلفية بيضاء
   فتختفي تماماً، (2) قائمة السجل لم يُلغَ عنها overflow فتُطبع الشاشة
   الأولى فقط ويُقتطع الباقي، (3) لا print-color-adjust فتضيع ألوان التصنيف.
   ========================================================================== */

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

  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    box-shadow: none !important;
    text-shadow: none !important;
    animation: none !important;
    transition: none !important;
  }

  html, body {
    background: #fff !important;
    background-image: none !important;
    color: #000 !important;
    font-size: 11pt;
  }

  /* إلغاء كل قصّ التمرير حتى لا يُقتطع المحتوى */
  .app, .main, .container, .card, .table-wrap, .log-list, .modal__body {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
    padding-block-end: 0 !important;
  }
  .app { padding-block-end: 0 !important; }
  .container { max-width: none !important; padding-inline: 0 !important; }

  /* إخفاء العناصر التفاعلية */
  .dock, .toast-stack, .topbar__actions, .icon-btn, .btn, .chip-row,
  .skip-link, .boot, .input-group__clear, .suggest, .no-print,
  .page-head__actions, .theme-toggle, .conn, .dropzone, .switch,
  .field, .toolbar, .tabs { display: none !important; }

  .print-only { display: revert !important; }

  /* الترويسة تتحوّل لترويسة مستند رسمي */
  .topbar {
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    border-block-end: 2px solid #000 !important;
    padding-block: 0 0 8pt !important;
  }
  .topbar__inner { min-height: auto !important; }
  .brand__logo { border: none !important; background: none !important; }

  /* الألوان → أسود على أبيض، مع إبقاء دلالات التصنيف */
  h1, h2, h3, h4, p, span, div, td, th, li, strong, b {
    color: #000 !important;
  }
  .text-muted, .text-subtle, .stat__desc, .stat__label,
  .log-entry__meta, .log-entry__clock { color: #444 !important; }

  .tone-danger, .badge--danger, .log-entry--danger .log-entry__duration { color: #b00020 !important; }
  .tone-warning, .badge--warning, .log-entry--warning .log-entry__duration { color: #8a5300 !important; }
  .tone-ok, .badge--ok, .log-entry--ok .log-entry__duration { color: #06612f !important; }

  /* البطاقات تصير إطارات بسيطة */
  .card, .stat, .log-entry, .hero-card, .banner, .contact-row {
    background: #fff !important;
    border: 1px solid #999 !important;
    border-radius: 4px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .log-entry { border-inline-start-width: 3px !important; border-inline-start-color: #000 !important; }
  .log-entry--danger  { border-inline-start-color: #b00020 !important; }
  .log-entry--warning { border-inline-start-color: #8a5300 !important; }
  .log-entry--caution { border-inline-start-color: #8a6d00 !important; }
  .log-entry--ok      { border-inline-start-color: #06612f !important; }
  .log-entry__actions { display: none !important; }

  .stat::before { background: #000 !important; height: 2px !important; }
  .stat__value { color: #000 !important; }

  .stat-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 6pt !important; }
  .log-list { grid-template-columns: repeat(2, 1fr) !important; gap: 6pt !important; }
  .grid-2 { grid-template-columns: 1fr !important; }

  .badge {
    border: 1px solid #666 !important;
    background: #f2f2f2 !important;
    color: #000 !important;
  }

  .meter { border: 1px solid #999 !important; background: #eee !important; height: 8pt !important; }
  .meter__fill { background: #555 !important; }

  .table { font-size: 9.5pt !important; }
  .table thead th {
    background: #eee !important; color: #000 !important;
    border-block-end: 1px solid #000 !important; position: static !important;
  }
  .table th, .table td { border: 1px solid #999 !important; }
  .table tbody tr { page-break-inside: avoid; }
  thead { display: table-header-group; }

  canvas { max-height: 250pt !important; page-break-inside: avoid; }

  .section, .card__head { page-break-after: avoid; }
  h1, h2, h3 { page-break-after: avoid; break-after: avoid; }

  a[href^='http']::after {
    content: ' (' attr(href) ')';
    font-size: 8pt; color: #555;
  }
  a[href^='#']::after, a[href^='javascript']::after { content: ''; }

  .credit { border-block-start: 1px solid #ccc; padding-block-start: 6pt; color: #666 !important; }
}

/* يظهر فقط عند الطباعة */
.print-only { display: none; }
