/* ============================================================
   Print stylesheet — نسخه‌ی چاپی گزارش
   ------------------------------------------------------------
   هدف: مدیر «چاپ» بزند و یک گزارش A4 مرتب بگیرد؛ همه‌ی تب‌ها پشت
   سر هم، بدون نوار ابزار و دکمه.

   نمودارهای HTML-محور (bullet، waterfall، slope، heatmap) در چاپ
   برداری و خوانا می‌مانند — یکی از دلایلی که به‌جای canvas ساخته شدند.
   ============================================================ */
@media print {
  @page { size: A4; margin: 12mm 10mm; }

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

  /* پنهان کردن اجزای تعاملی */
  .header, .tabs, .footer, .toasts, .backdrop,
  .chart-tools, .hbtn, .btn, .menu, .drop, .prog, .kpi-spark, .sp {
    display: none !important;
  }

  /* همه‌ی تب‌ها در چاپ دیده شوند */
  .panel { display: block !important; page-break-before: always; }
  .panel:first-of-type { page-break-before: avoid; }

  .print-header { display: block !important; }

  /* کارت‌ها و نمودارها نباید بین دو صفحه بشکنند */
  .card, .kpi, .chart, .group, .insight, .health {
    border: 1px solid #b8b8b8 !important;
    box-shadow: none !important;
    background: #fff !important;
    break-inside: avoid;
  }

  .kpi::before { background: #666 !important; height: 2px !important; }
  .kpi-num, .kpi-name, .insight .v, .sec-head h3, .chart-head h4 { color: #000 !important; }
  .kpi-name, .insight .t { color: #444 !important; }

  /* گیج سلامت: پس‌زمینه‌ی تیره در چاپ سیاه می‌شود — سفیدش می‌کنیم */
  .health { background: #fff !important; color: #000 !important; }
  .health-src { background: #eee !important; color: #333 !important; }
  .gauge-score, .gauge-label, .ring-row { color: #000 !important; }
  .ring-row .bar { background: #e4e4e4 !important; }

  /* گرید بنتو در چاپ به شبکه‌ی ثابت تبدیل می‌شود */
  .bento {
    grid-template-columns: repeat(4, 1fr) !important;
    grid-auto-rows: auto !important;
  }
  .bento > .tier-hero,
  .bento > .tier-medium,
  .bento > .tier-compact { grid-column: span 1 !important; grid-row: span 1 !important; }
  .tier-hero .kpi-num { font-size: 17pt !important; }
  .tier-medium .kpi-num { font-size: 15pt !important; }
  .tier-compact .kpi-num { font-size: 13pt !important; }

  .hero { grid-template-columns: 200px 1fr !important; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .smalls { grid-template-columns: repeat(5, 1fr) !important; }

  .cwrap, .cwrap.sm, .cwrap.xs, .cwrap.lg, .cwrap.xl {
    height: 190px !important;
    break-inside: avoid;
  }

  /* نمودارهای HTML — مرکب‌ها را با چاپ سازگار می‌کنیم */
  .bullet .track, .wf-track, .minibar .tr { background: #eaeaea !important; }
  .bullet .band { background: #f2f2f2 !important; }
  .bullet .marker { background: #000 !important; }
  .slope-line .axis { background: #d5d5d5 !important; }
  .slope-line .pt { border-color: #fff !important; }
  table.heat td { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

  /* جدول‌ها */
  table.dt { break-inside: auto; }
  table.dt th {
    background: #ececec !important; color: #000 !important;
    position: static !important;
  }
  table.dt th, table.dt td { border-bottom: 1px solid #ccc !important; }
  table.dt tbody tr:hover td { background: transparent !important; }

  .sec-head { border-bottom: 1.5px solid #333 !important; }
  .chip { border-color: #bbb !important; background: #f6f6f6 !important; color: #333 !important; }
  .badge { border: 1px solid #bbb !important; }
  .empty { border-color: #ccc !important; background: #fafafa !important; }

  a { color: #000 !important; text-decoration: none !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 7.5pt; color: #666; }

  /* رنگ‌های وضعیت باید در چاپ بمانند تا معنا از دست نرود */
  .delta, .badge, .kpi::before, .bullet .fill, .wf-bar, .minibar .fl, table.heat td {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* سربرگ چاپی فقط در چاپ دیده می‌شود */
.print-header { display: none; }
.print-header .ph-title { font-size: 14pt; font-weight: 800; }
.print-header .ph-sub { font-size: 9pt; color: #444; margin-top: 3px; }
.print-header hr { border: none; border-top: 2px solid #333; margin: 8px 0 14px; }
