/* ======================================================================
   PRINT STYLES — Wycena PDF
   Loaded via <link media="print"> — does NOT block rendering.
   ====================================================================== */
@media print {
  @page {
    margin: 1cm 1.2cm;
    size: A4;
  }

  /* ── Reset: hide everything except estimate ── */
  body > * {
    display: none !important;
  }

  body > main,
  body > div:has(#estimate-pdf) {
    display: block !important;
  }

  main > *:not(:has(#estimate-pdf)) {
    display: none !important;
  }

  header, footer, nav,
  [class*="FloatingPhoneCTA"],
  [class*="FloatingCTA"] {
    display: none !important;
  }

  .print\:hidden {
    display: none !important;
  }

  section:has(#estimate-pdf) {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: white !important;
    min-height: auto !important;
  }

  section:has(#estimate-pdf) > div {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  body {
    background: white !important;
    color: black !important;
    font-size: 10pt;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ── Document container ── */
  #estimate-pdf {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    font-size: 9pt !important;
    line-height: 1.4 !important;
  }

  #estimate-pdf * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ── PAGE 1: Header + Client + Wstep + Total + Config ──
     These sections stay together on page 1, never break inside */

  /* Company header */
  #estimate-pdf [class*="bg-background-dark"] {
    padding: 16px 22px !important;
    break-inside: avoid !important;
  }

  #estimate-pdf [class*="bg-background-dark"] h1 {
    font-size: 15pt !important;
  }

  #estimate-pdf [class*="bg-background-dark"] p {
    font-size: 8pt !important;
  }

  /* Client info bar */
  .print-client-bar {
    padding: 8px 22px !important;
    break-inside: avoid !important;
  }

  /* Wstep */
  .print-wstep {
    padding: 10px 22px !important;
    break-inside: avoid !important;
  }

  .print-wstep p {
    font-size: 8.5pt !important;
  }

  /* Total hero */
  #estimate-pdf .print-total {
    padding: 14px 22px !important;
    break-inside: avoid !important;
  }

  #estimate-pdf .print-total-price {
    font-size: 24pt !important;
    line-height: 1.2 !important;
  }

  #estimate-pdf .print-total-unit {
    font-size: 9pt !important;
  }

  /* Config grid */
  #estimate-pdf .print-config {
    padding: 10px 22px !important;
    break-inside: avoid !important;
  }

  #estimate-pdf .print-config span {
    font-size: 8pt !important;
  }

  /* ── PAGE 2+: Stages ──
     Force stages section to start on a new page.
     Each stage card cannot be split across pages. */

  #estimate-pdf .print-stages {
    padding: 14px 22px 16px !important;
    break-before: page !important;
  }

  #estimate-pdf .print-stages h3 {
    font-size: 9pt !important;
    margin-bottom: 10px !important;
  }

  /* Each stage card: NEVER split across pages */
  #estimate-pdf .print-stage-card {
    margin-bottom: 8px !important;
    border-width: 1px !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  #estimate-pdf .print-stage-header {
    padding: 6px 14px !important;
  }

  #estimate-pdf .print-stage-header span {
    font-size: 9pt !important;
  }

  #estimate-pdf .print-stage-body {
    padding: 5px 14px 8px !important;
  }

  #estimate-pdf .print-stage-body p {
    font-size: 7.5pt !important;
    margin-bottom: 3px !important;
  }

  /* Included items list */
  #estimate-pdf .print-stage-body ul {
    margin: 0 !important;
    padding: 0 !important;
  }

  #estimate-pdf .print-stage-body li {
    font-size: 8pt !important;
    padding-top: 1px !important;
    padding-bottom: 1px !important;
    line-height: 1.35 !important;
  }

  /* Total row: keep together, never split */
  #estimate-pdf .print-total-row {
    padding-top: 10px !important;
    margin-top: 8px !important;
    font-size: 10pt !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* ── Gwarancja + Disclaimers + Footer: keep together ── */

  .print-gwarancja {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    padding: 8px 22px !important;
  }

  .print-gwarancja p {
    font-size: 8pt !important;
  }

  #estimate-pdf .print-disclaimers {
    padding: 10px 22px !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  #estimate-pdf .print-disclaimers p {
    font-size: 7.5pt !important;
    line-height: 1.3 !important;
    margin-bottom: 3px !important;
  }

  #estimate-pdf .print-footer {
    padding: 8px 22px !important;
    font-size: 7.5pt !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* ── Disclaimers + Footer: keep together as a block ── */
  .print-ending-block {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
}
