/* =============================================
   語音検査アプリ - 印刷用スタイル
   3ページ構成:
     1ページ目: 良い耳の了解閾値検査＋弁別検査
     2ページ目: 悪い耳の了解閾値検査＋弁別検査
     3ページ目: スピーチオージオグラム
   ============================================= */

@media print {
  /* 画面用要素を全て非表示 */
  body > * { display: none !important; }

  /* 印刷コンテナだけ表示 */
  #print-container { display: block !important; }

  /* ページ設定 */
  @page {
    size: A4 portrait;
    margin: 12mm 15mm;
  }

  #print-container { font-family: 'MS Mincho', 'Yu Mincho', 'Hiragino Mincho ProN', serif; }

  /* ページ区切り */
  .print-page {
    page-break-after: always;
    page-break-inside: avoid;
  }
  .print-page:last-child { page-break-after: auto; }

  /* ---- ヘッダー部分（各ページ共通） ---- */
  .pr-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #000;
    padding-bottom: 6px;
    margin-bottom: 10px;
  }
  .pr-title    { font-size: 13pt; font-weight: bold; }
  .pr-meta     { font-size: 9pt; }
  .pr-meta table { border-collapse: collapse; }
  .pr-meta td  { padding: 1px 8px; white-space: nowrap; }
  .pr-meta .lbl { font-weight: bold; color: #444; }

  /* ---- 検査表共通 ---- */
  .pr-section-title {
    font-size: 10pt;
    font-weight: bold;
    background: #e0e0e0;
    padding: 3px 8px;
    margin: 8px 0 4px;
    border-left: 4px solid #333;
  }

  /* ---- 了解閾値検査表（臨床フォーム形式） ---- */
  .pr-srt-form { margin-bottom: 8px; }
  .pr-srt-meta {
    display: flex; gap: 24px; align-items: center;
    font-size: 9pt; margin-bottom: 4px;
  }
  .pr-srt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
    margin-bottom: 4px;
  }
  .pr-srt-table th, .pr-srt-table td {
    border: 1px solid #555;
    text-align: center;
    padding: 4px 2px;
    min-width: 24px;
  }
  .pr-srt-table thead th { background: #c8c8c8; font-weight: bold; font-size: 8pt; }
  .pr-srt-row-lbl { background: #e0e0e0; font-size: 8pt; text-align: left; padding: 4px 6px; white-space: nowrap; }
  .pr-srt-score-row td { font-weight: bold; background: #d8d8d8; }
  .pr-srt-score-row .pr-srt-row-lbl { background: #c8c8c8; }
  .pr-cell-correct { background: #e8f8ee; }
  .pr-cell-wrong   { color: #999; text-decoration: line-through; background: #fff0f0; }

  /* ---- 弁別検査表（臨床フォーム形式） ---- */
  .pr-wrs-block { margin-bottom: 10px; }
  .pr-wrs-header {
    display: flex; gap: 16px; align-items: center;
    font-size: 8.5pt; margin-bottom: 3px;
    border-left: 3px solid #555; padding-left: 6px;
  }
  .pr-wrs-header b { font-size: 9pt; }
  .pr-wrs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
  }
  .pr-wrs-table th, .pr-wrs-table td {
    border: 1px solid #888;
    text-align: center;
    padding: 3px 2px;
    min-width: 20px;
  }
  .pr-wrs-num  { background: #d8d8d8; font-size: 7.5pt; }
  .pr-wrs-char { background: #ececec; font-size: 9pt; font-weight: bold; }
  .pr-wrs-table tbody + tbody tr:first-child th,
  .pr-wrs-table tbody + tbody tr:first-child td { border-top: 2px solid #555; }

  /* ---- スピーチオージオグラム（3ページ目） ---- */
  .pr-audiogram-page .pr-title { font-size: 14pt; }
  .pr-audiogram-wrap {
    margin-top: 16px;
    display: flex;
    justify-content: center;
  }
  #audiogram-svg-print {
    width: 160mm;
    height: auto;
  }

  .pr-legend {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 10px;
    font-size: 9pt;
  }
  .pr-legend-item { display: flex; align-items: center; gap: 6px; }
  .pr-legend-line-dashed { width: 30px; height: 0; border-top: 2px dashed #000; }
  .pr-legend-line-solid  { width: 30px; height: 0; border-top: 2px solid  #000; }
  .pr-legend-sym-o  { font-size: 12pt; }
  .pr-legend-sym-x  { font-size: 12pt; }

  /* ---- フッター ---- */
  .pr-footer {
    position: fixed; bottom: 8mm; left: 15mm; right: 15mm;
    font-size: 7pt; color: #666; text-align: right;
    border-top: 1px solid #ccc; padding-top: 3px;
  }
}

/* 通常表示時は印刷コンテナを隠す */
@media screen {
  #print-container { display: none; }
}
