/* ============================================
   BÉ TÔ MÀU HỌC TẬP - Print Styles
   v2: Maximize A4 space, bigger drawing
   ============================================ */

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

  body {
    background: white !important;
    margin: 0 !important; padding: 0 !important;
    font-family: 'Nunito', 'Segoe UI', Arial, sans-serif !important;
    color: black !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #home-screen,
  #preview-screen,
  .preview-toolbar,
  .no-print {
    display: none !important;
  }

  #print-container {
    display: block !important;
  }

  /* === Worksheet === */
  .worksheet {
    background: white !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    width: 100% !important;
    height: 275mm !important; /* STRICT A4 HEIGHT TO PREVENT SPILL */
    max-height: 275mm !important;
    overflow: hidden !important;
    padding: 0 2mm !important;
    page-break-after: always !important;
    page-break-inside: avoid !important;
    font-size: 10.5pt !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .worksheet:last-child { page-break-after: auto !important; }

  /* === Header - compact === */
  .ws-header {
    border-bottom: 2.5px solid black !important;
    padding-bottom: 2px !important;
    margin-bottom: 2px !important;
  }
  .ws-day-badge {
    background: black !important; color: white !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .ws-title { font-size: 16pt !important; margin: 1px 0 !important; }

  /* === Drawing - MAXIMIZE === */
  .ws-drawing {
    flex: 1 !important; /* TAKE REMAINING SPACE ONLY */
    min-height: 0 !important;
    padding: 2mm 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .ws-drawing svg, .ws-drawing img {
    max-height: 100% !important; /* Never exceed flex container */
    max-width: 100% !important;
    object-fit: contain !important;
  }
  .ws-drawing svg path,
  .ws-drawing svg circle,
  .ws-drawing svg ellipse,
  .ws-drawing svg rect,
  .ws-drawing svg polygon,
  .ws-drawing svg polyline,
  .ws-drawing svg line {
    stroke: black !important;
  }
  .ws-drawing svg .colorable,
  .ws-drawing svg [fill="white"] {
    fill: white !important;
  }

  /* === Exercises - 2 columns === */
  .ws-exercises {
    grid-template-columns: 1fr 1fr !important;
    border-top: 2.5px solid black !important;
    border-bottom: 2.5px solid black !important;
    margin: 2px 0 !important;
    padding: 0 !important;
  }
  .ws-exercise {
    padding: 4px 6px !important;
  }
  .ws-exercise:first-child {
    border-right: 1.5px solid #666 !important;
  }
  .ws-exercise h3 {
    font-size: 10pt !important;
    margin-bottom: 3px !important;
    padding-bottom: 2px !important;
  }

  /* Exercise elements */
  .exercise-instruction { font-size: 9.5pt !important; }
  .count-objects { font-size: 18pt !important; }
  .count-option { font-size: 12pt !important; }
  .option-circle { border-color: black !important; width: 20px !important; height: 20px !important; }
  .match-row { font-size: 16pt !important; }
  .pattern-row { font-size: 18pt !important; }
  .pattern-blank { border-color: #666 !important; width: 32px !important; height: 32px !important; }
  .compare-group-big { font-size: 32pt !important; }
  .compare-group-small { font-size: 18pt !important; }
  .math-equation { font-size: 18pt !important; }
  .find-grid { font-size: 18pt !important; }
  .find-item { border-color: #999 !important; width: 38px !important; height: 38px !important; }

  .trace-char {
    color: #c0c0c0 !important; border-color: #bbb !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    font-size: 26pt !important; width: 40px !important; height: 44px !important;
  }
  .trace-blank { border-color: #aaa !important; width: 40px !important; height: 44px !important; }
  .write-line { border-color: #999 !important; }
  .match-dots { border-color: #888 !important; }
  .read-sentence { font-size: 11pt !important; border-color: #aaa !important; }

  .mini-svg {
    display: inline-flex !important; align-items: center !important; justify-content: center !important;
    width: 1.6em !important; height: 1.6em !important; vertical-align: middle !important;
  }
  .mini-svg svg { width: 100% !important; height: 100% !important; }
  .silhouette svg path,
  .silhouette svg circle,
  .silhouette svg ellipse,
  .silhouette svg rect,
  .silhouette svg polygon,
  .silhouette svg polyline,
  .silhouette svg line {
    fill: black !important;
    stroke: black !important;
  }

  /* === Parent section === */
  .ws-parent-section {
    font-size: 8pt !important;
    margin-top: 2px !important;
    border-color: #999 !important;
  }
  .ws-vocab { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ws-tip { background: transparent !important; }

  .ws-footer { font-size: 6.5pt !important; color: #aaa !important; margin-top: 1px !important; }
}
