/* ==========================================
   印刷用スタイル（A4縦・最適化）
   ========================================== */
@media print {
  
  /* ページ全体の基本設定（A4縦） */
  @page {
    size: A4 landscape; /* A4・縦向き指定 (横なら landscape) */
    margin: 15mm;      /* プリンタの印字可能領域を考慮した余白 */
  }

  /* 不要なWeb要素の非表示 */
  header, footer, nav, sidebar, .no-print, .buttons, #search-form {
    display: none !important;
  }

  /* 印刷エリアを横幅いっぱいに */
  body, main, #content, .container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    position: static !important;
    overflow: visible !important; /* スクロールバーの印刷を防ぐ */
  }

  /* 文字と色の最適化 */
  body {
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Segoe UI", sans-serif;
    font-size: 11pt;     /* 印刷物に適した単位（pt） */
    line-height: 1.6;
    color: #000000 !important;
    background: transparent !important;
    -webkit-print-color-adjust: exact; /* 背景色・画像を強制表示(ブラウザ対応) */
    print-color-adjust: exact;
  }

  /* リンクの処理（URLの可視化） */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555555;
  }
  
  /* 画像・表の最適化（はみ出し防止） */
  img, table, svg, canvas {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid; /* 要素の途中での改ページを防止 */
    break-inside: avoid;
  }

  /* 明示的な改ページ制御 */
  .page-break {
    page-break-before: always; /* この要素の直前で強制改ページ */
    break-before: always;
  }
  
  /* 見出しの直後での不自然な改ページを防止 */
  h1, h2, h3 {
    page-break-after: avoid;
    break-after: avoid;
  }
}
