/* =========================================================
   WORKOUT PRINT — PDF-READY OUTPUT
   - Print only the preview panel
   - Strong, dark checkbox boxes
   - Prevent long URL from creating extra page
   - Clean margins + readable hierarchy
   - Avoid bad page breaks
========================================================= */

@page {
  size: landscape;
  margin: 0.5in;
}

@media print {

  /* ---- Hide everything except the printable panel ---- */
  .site-header,
  .site-footer,
  .module-hero,
  .wb-accordion,
  #wbPrintBtn,
  #wbClearBtn,
  #wbOpenLogBtn,
  .wb-card:not(#wbPrintable),
  .wb-grid > :not(#wbPrintable) {
    display: none !important;
  }

  body, html {
    background: #fff !important;
  }

  /* If your global CSS adds padding/margins, force clean print */
  .page-wrapper,
  .module-main,
  .module-section,
  .module-section-inner {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* ---- Printable panel becomes a true worksheet ---- */
  #wbPrintable {
    position: static !important;
    top: auto !important;
    background: #fff !important;
    color: #000 !important;
    border: 2px solid #000 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0.55in !important; /* internal worksheet margin */
  }

  #wbPrintable * {
    color: #000 !important;
    text-shadow: none !important;
    box-shadow: none !important;
  }

  /* ---- Inputs should look like fields, not dark UI boxes ---- */
  .wb-input,
  .wb-textarea {
    border: 1.6px solid #000 !important;
    background: #fff !important;
    color: #000 !important;
  }

  /* ---- Divider ---- */
  .wb-divider {
    border-top: 2px solid #000 !important;
    opacity: 1 !important;
  }

  /* ---- Time summary block (bold + clean) ---- */
  .wb-timebox {
    border: 2px solid #000 !important;
    background: #fff !important;
  }

  .wb-time-label {
    font-weight: 900 !important;
    letter-spacing: 0.02em !important;
  }

  .wb-time-value {
    font-weight: 900 !important;
    font-size: 14pt !important;
  }

  /* ---- Checklist items: avoid splitting across pages ---- */
  .wb-list,
  .wb-list li,
  .wb-preview-item {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .wb-preview-item {
    margin: 0 0 10px 0 !important;
  }

  /* Strong, dark checkbox box for paper */
  .wb-box {
    width: 22px !important;
    height: 22px !important;
    border: 3px solid #000 !important;
    border-radius: 4px !important;
    margin-top: 1px !important;
  }

  .wb-preview-label {
    font-weight: 800 !important;
    font-size: 11.5pt !important;
    line-height: 1.25 !important;
  }

  .wb-preview-details {
    font-size: 10pt !important;
    line-height: 1.35 !important;
    opacity: 1 !important;
  }

  /* ---- Phone logging callout: keep it simple ---- */
  .wb-callout,
  .callout {
    border: 2px solid #000 !important;
    background: #fff !important;
  }

  /* Big, tappable link button stays a link in PDF */
  .wb-log-btn {
    border: 3px solid #000 !important;
    background: #fff !important;
    color: #000 !important;
    font-weight: 900 !important;
    letter-spacing: 0.06em !important;
    padding: 14px 12px !important;
    border-radius: 10px !important;
    text-decoration: none !important;
  }

  /* ---- CRITICAL: hide the long URL line so it doesn't force page 2 ---- */
  #wbLogUrlText,
  .wb-url {
    display: none !important;
  }

  /* Keep the log button with its instructions (avoid orphaning) */
  .wb-print-actions {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-top: 14px !important;
  }

  /* Stop Chrome adding weird scaling artifacts */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ---- Weekly planner print polish ---- */
  .wb-daytabs,
  #wbDayTabs,
  #wbExtras {
    display: none !important; /* tabs + live inputs are not needed in the PDF */
  }

  /* Ensure daily worksheets print fully */
  .wb-daydetails {
    border: 1px solid #000 !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    margin: 0 0 12px !important;
    break-inside: avoid;
  }
  .wb-daydetails-summary {
    list-style: none !important;
    cursor: default !important;
  }
  .wb-daydetails summary::-webkit-details-marker { display: none !important; }

  /* Clickable links should look like links on paper */
  #wbPrintable a,
  #wbPrintable a:visited {
    color: #000 !important;
    text-decoration: underline !important;
    word-break: break-all !important;
  }

  /* Make the URL line readable */
  .wb-preview-link {
    font-size: 11pt !important;
    margin-top: 4px !important;
  }

  /* Slightly tighter for landscape */
  #wbPrintable h3 { margin-top: 0 !important; }

}

/* =========================================================
   STEP 2A — PRINT: landscape + branded header + weekly summary
========================================================= */
@media print {
  @page { size: landscape; margin: 0.5in; }

  html, body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Print-only header */
  .wb-print-header{
    display:flex !important;
    justify-content: space-between;
    align-items:flex-end;
    gap: 18px;
    padding: 10px 0 14px 0;
    border-bottom: 2px solid #000;
    margin-bottom: 12px;
  }
  .wb-print-brand .wb-print-mark{
    font-weight: 900;
    font-size: 14pt;
    letter-spacing: .06em;
    text-transform: uppercase;
  }
  .wb-print-brand .wb-print-sub{
    font-size: 10pt;
    margin-top: 2px;
  }
  .wb-print-meta{
    text-align:right;
    font-size: 9pt;
    line-height: 1.35;
  }

  /* Weekly summary grid prints clean */
  .wb-weekly-grid{
    display:grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .wb-week-daycard{
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Hide the UI-only help text and controls that shouldn't print */
  .wb-preview-controls,
  .wb-daytabs,
  .wb-hero-actions,
  .wb-hero-toggles,
  .wb-tier-row,
  #wbAccordion,
  .wb-modal,
  .wb-modal-backdrop{
    display:none !important;
  }

  /* Inputs -> look like text */
  input, textarea, select {
    border: 1px solid #000 !important;
    color: #000 !important;
    background: #fff !important;
  }
}


/* ================================
   STEP 2B — PRINT / PDF LAYOUT
   Goal: Page 1 = weekly summary
         Next pages = one day per page
         Header with logo
================================ */

.wb-print-only{ display:none; }

@media print{
  /* Prefer landscape + consistent margins */
  @page { size: landscape; margin: 0.5in; }

  /* Show print-only blocks; hide interactive preview blocks */
  .wb-print-only{ display:block !important; }
  #wbSelectedGrouped,
  #wbTimeSummary,
  .wb-phone,
  .wb-preview-controls,
  .wb-daytabs,
  .wb-meta,
  .wb-extras,
  .wb-divider{ display:none !important; }

  /* Header */
  .wb-print-header{
    display:block !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 0 8px;
    border-bottom: 1px solid #bbb;
    background: #fff;
  }
  .wb-print-brand{ display:flex; align-items:center; gap:12px; }
  .wb-print-logo{ width: 38px; height: 38px; object-fit: contain; }
  .wb-print-title{ font-weight: 900; font-size: 14px; }
  .wb-print-sub{ font-size: 12px; }

  /* Make room for fixed header */
  #wbPrintable{ padding-top: 64px !important; }

  /* Weekly summary grid */
  .wb-weekgrid{ display:grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
  .wb-weekcol{ border:1px solid #ddd; border-radius:10px; padding:10px; }
  .wb-weekcol-head{ display:flex; justify-content:space-between; align-items:baseline; margin-bottom:8px; }
  .wb-weekday{ font-weight:900; }
  .wb-weekcat{ display:flex; justify-content:space-between; gap:10px; font-size:12px; padding:2px 0; }
  .wb-weekempty{ font-size:12px; color:#666; }

  /* Day pages */
  .wb-print-daypage{ page-break-before: always; }
  .wb-print-dayhead{ display:flex; justify-content:space-between; align-items:baseline; margin: 8px 0 10px; }
  .wb-print-daytitle{ font-weight: 900; font-size: 16px; }
  .wb-print-sechead{ display:flex; justify-content:space-between; margin-top:10px; padding:6px 8px; background:#f2f2f2; border:1px solid #e0e0e0; border-radius:8px; }
  .wb-print-sectitle{ font-weight:900; }
  .wb-print-item{ border-bottom:1px solid #eee; padding:6px 0; }
  .wb-print-itemline{ display:flex; align-items:center; gap:8px; }
  .wb-print-box{ width:14px; height:14px; border:2px solid #333; border-radius:3px; }
  .wb-print-itemlabel{ flex:1; }
  .wb-print-itemmins{ white-space:nowrap; font-size:12px; }
  .wb-print-ico{ font-size:12px; }
  .wb-print-ico-muted{ opacity:.35; }
  .wb-print-link a{ font-size:10px; word-break:break-all; }
  .wb-print-details{ font-size:11px; margin-left:22px; margin-top:2px; white-space:pre-wrap; }
}


/* =========================================================
   PATCH (2026-02-01)
   - Prevent rotated/odd PDF layout by letting print run portrait
   - Ensure ONLY one print header renders
   - Page 1: Weekly Summary, then one day per page
========================================================= */
@media print {
  /* Prefer portrait so Chrome/Edge doesn't rotate/shrink content unexpectedly */
  @page { size: portrait; margin: 0.5in; }

  /* Hide the earlier meta-only header (keep the branded logo header) */
  #wbPrintHeader { display: none !important; }

  /* Do NOT use a fixed header (it was causing spacing/cutoff issues) */
  .wb-print-header {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    border-bottom: 2px solid #000 !important;
  }

  /* Remove the "make room for fixed header" hack */
  #wbPrintable { padding-top: 0.55in !important; }

  /* Weekly Summary is page 1, then daily pages */
  #wbPrintWeekSummary { page-break-after: always; break-after: page; }
  .wb-print-daypage { page-break-before: always; break-before: page; }

  /* Weekly summary grid: wrap into rows (7 columns is too wide on paper) */
  .wb-weekgrid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
