/* ================================
   スケジュールセクション
================================ */
.schedule-section {
  padding: 110px 0 60px;
  text-align: center;
}
.inner{
  max-width: 900px;
  margin: 0 auto;
}
/* ===== 月ナビゲーション ===== */
.month-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  gap: 100px;                 /* ボタン間の適度な余白 */
}

.month-nav button {
  background-color: #ffffff;
  color: #444;
  border: 0.5px solid #444;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.month-nav button:hover {
  background-color: #555;
  color: #fff;
}
#current-month {
  display: none !important;
}
/* ================================
   スケジュールテーブル
================================ */
.schedule-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  table-layout: fixed;
  border: 0.5px solid #b3b3b3; /* 他ページのカード枠と同じトーン */
}
.schedule-table th,
.schedule-table td {
  border: 0.5px solid #b3b3b3;
}
.schedule-table th {
  background-color: #ffffff;
  height: 30px;
  font-weight: bold;
}

/* ===== 時間列 ===== */
/* 左の時間列の幅を縮める（TH） */
.schedule-table th.time-col {
  width: 40px !important;
}

/* AM/PM の左列も同じ幅にする（TD） */
.time-label {
  width: 45px !important;
  background: #ffffff;
  font-weight: bold;
}

/* ===== 空セル ===== */
.empty {
  background: #f9f9f9;
}

/* ================================
   午前セル・午後セル
================================ */
.am-cell, .pm-cell {
  position: relative;
  height: 65px;
  box-sizing: border-box;
  overflow: hidden;
}

/* 午前は日付があるので doctor-row を下げる */
.am-cell doctor-row {
  padding-top: 50px;
}
/* AM の下線だけ薄くする */
.am-cell {
  border-bottom: 0.5px solid #ededed !important; /* 午前→午後の区切りを薄めに */
}

/* PM の上線も薄くする（AMとの境目） */
.pm-cell {
  border-top: 0.5px solid #ededed !important; /* 午前→午後の区切りを薄めに */
}
/* 固定休診（水曜午後・土曜午後） */
.fixed-off {
  position: relative;
  background: #e0e0e0 !important;
  overflow: hidden;
}

/* 1本の対角線（セルの角→角） */
.fixed-off::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(
      to bottom right,
      transparent calc(50% - 1px),
      #999 calc(50%),
      transparent calc(50% + 1px)
    );
  pointer-events: none;
  z-index: 2;
}

.fixed-off * {
  opacity: 0;  /* 文字を消す */
}

/* ================================
   日付（左上固定）
================================ */
.date {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 4px;
  font-size: 13px;
  font-weight: bold;
  color: #444;
  background: #fff;
  z-index: 2;
}

/* ================================
   医師（略称バッジのみ）
================================ */
.doctor-row {
  display: flex;
  /*flex-direction: column; *//* ← 一番正しい（縦積み） */
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.doctor-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

/* ==== 担当医 色 ==== */
.bg-doctor1 { background-color: #4e4e4e !important; }
.bg-doctor2 { background-color: #00aa6e !important; } /* tel予約アイコン系ピンク */
.bg-doctor3 { background-color: #2761f2 !important; } /* Web予約アイコン系ブルー */

/* ================================
   休診（全塗り）
================================ */
.half-closed {
  font-size: 15px;
  position: absolute;
  inset: 0;
  background-color: #e0e0e0 !important;
  color: #333;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1 !important;
}
.doctor-legend {
  font-size: 15px;
  color: #333;
  text-align: left;
}
.legend-wrap {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 12px 0;
  overflow-x: auto;
}
.holiday-duty {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid #b3b3b3;
  border-radius: 6px;
  padding: 4px 6px;
  background: #fff;
  color: #333;
  line-height: 1.4;
  font-size: 13px;
  min-width: 0;
  width: fit-content;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  text-align: center;
}
.holiday-duty-title {
  font-weight: 700;
  color: #c00;
}
.holiday-duty-date,
.holiday-duty-doctor {
  margin-top: 2px;
}
.holiday-duty .doctor-badge,
.holiday-duty-single .doctor-badge {
  vertical-align: middle;
  margin-left: 4px;
}
.holiday-duty-single {
  display: inline-block;
  color: #333;
  font-weight: 700;
  border: 1px solid #b3b3b3;
  border-radius: 6px;
  padding: 3px 6px;
  background: #fff;
  text-align: center;
}
.holiday-duty-print-only {
  display: none;
}
.doctorcopy-page #holiday-duty-single {
  display: inline-block;
  margin: 12px 0 6px;
}
.doctorcopy-page .legend-wrap .holiday-duty {
  display: none !important;
}
.doctorcopy-page .holiday-duty {
  display: block;
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1.6;
  min-width: 160px;
  width: auto;
}
.doctorcopy-page .holiday-duty .doctor-badge,
.doctorcopy-page .holiday-duty-single .doctor-badge {
  margin-left: 6px;
}
.doctorcopy-page .holiday-duty-single {
  padding: 5px 8px;
  font-size: 16px;
  margin-bottom: 4px;
}
.holiday-duty-title-inline {
  margin-right: 6px;
  color: #c00;
}
.holiday-doctor-plain {
  color: #333;
  font-weight: 700;
}
.holiday-doctor-badge {
  background: #c00;
  color: #fff;
}
.holiday-duty {
  font-size: 13px;
  color: #333;
  text-align: center;
  line-height: 1.4;
  min-width: 0;
}
.holiday-duty-title {
  font-weight: 700;
  color: #c00;
}
.holiday-duty-single {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
  color: #333;
}
.doctor-legend-list {
  margin-bottom: 12px;
}
.doctor-toggle-group {
  display: flex;
  gap: 15px;
  margin-top: 6px;
  justify-content: center;
}
.doctor-toggle {
  padding: 10px 12px;
  border-radius: 8px;
  border: 0.5px solid #333;
  background: #fff;
  color: #333;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}
.doctor-toggle.active {
  background: #fff;
  color: #333;
}
.doctor-toggle:hover {
  background: #333;
  color: #fff;
  opacity: 0.85;
}
.double-print-wrapper {
  display: none;
}
  .doctor-badge.badge-off {
    filter: grayscale(1);
    opacity: 0.35;
    background-color: #ededed !important;
    color: #444 !important;
    border: 1px solid #ccc;
  }

/* 印刷時は非選択でも色付きで出す */
@media print {
  .doctor-badge.badge-off {
    filter: none !important;
    opacity: 1 !important;
    background-color: transparent !important;
    color: #000 !important;
    border: 0.5px solid #000 !important;
    font-size: 16px !important;
    font-weight: 400 !important;
  }
}

/* ================================
   スマホ対応
================================ */
@media screen and (max-width: 768px) {

  .legend-wrap {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 16px;
    margin-top: 10px;
    overflow-x: auto;
    justify-content: space-between;
    align-items: stretch;
  }

  /* 全体のフォント縮小 */
  .schedule-table th,
  .schedule-table td,
  .time-label,
  .date {
    font-size: 12px !important;
  }

  /* =========================
       午前（AM）
     ========================= */
  .am-cell {
    height: 80px !important;       /* ←重要：日付＋2名 doctor を収める */
    position: relative;
    padding-top: 22px !important;  /* ←日付の高さ + 余裕 */
    overflow: hidden;
  }

  /* doctor を AM は中央寄せ（下→上のバランス良し） */
  .am-cell .doctor-row {
    position: absolute;
    top: 32px;                     /* ←日付の下にちょうど来る位置 */
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3px !important;
    transform: none !important;
    justify-content: flex-start;
    align-items: center;
  }


  /* =========================
       午後（PM）
     ========================= */
  .pm-cell {
    height: 70px !important;
    position: relative;
    padding-top: 6px !important;
    overflow: hidden;
  }

  /* PM は上寄せで配置 */
  .pm-cell .doctor-row {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3px !important;
    transform: none !important;
    justify-content: flex-start;
    align-items: center;
  }


  /* =========================
       doctor バッジ
     ========================= */
  .doctor-badge {
    font-size: 12px !important;
    padding: 2px 5px !important;
    line-height: 1.1 !important;
  }


  /* =========================
       日付
     ========================= */
  .date {
    background: rgba(255,255,255,0.95) !important;
    padding: 2px 4px !important;
    top: 2px !important;
    z-index: 5 !important;
  }

/* ============================
   休診セル 完全塗りつぶし（スマホ）
============================ */

/* 午前・午後セルに対して背景を直接塗る */
.am-cell .half-closed,
.pm-cell .half-closed {
  position: absolute;
  inset: 0;
  background-color: #e0e0e0 !important;
  color: #333;
  font-weight: bold;
  font-size: 13px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3;
}

/* doctor があれば非表示（休診なので） */
.am-cell .half-closed ~ .doctor-row,
.pm-cell .half-closed ~ .doctor-row {
  display: none !important;
}

/* 日付は上に */
.am-cell .half-closed ~ .date,
.pm-cell .half-closed ~ .date {
  position: absolute;
  top: 2px;
  left: 2px;
  background: rgba(255,255,255,0.85);
  padding: 1px 3px;
  border-radius: 2px;
  z-index: 4;
}
}
/* ================================
   印刷ボタン
================================ */
.print-buttons button {
  background-color: #ffffff;
  color: #444;
  border: 0.5px solid #444;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.print-buttons button:hover {
  background-color: #555;
  color: #fff;
}

/* ================================
   2面印刷レイアウト（A4にA5×2）
================================ */
@media print {
  body[data-print="double"] #schedule-container,
  body[data-print="double"] .doctor-toggle-group,
  body[data-print="double"] .month-nav,
  body[data-print="double"] .print-buttons,
  body[data-print="double"] #doctor-legend-print 
  {
    display: none !important;
  }
  body[data-print="double"] .double-print-wrapper {
    width: 100% !important;
    display: flex !important;
    gap: 0mm;
    justify-content: space-between;
    align-items: flex-start;
    transform-origin: top left;
  }
  body[data-print="double"] .double-print-wrapper .print-card {
    width: 50%;
    max-width: none; /* 幅制限を外して広く使う */
    box-sizing: border-box;
    padding: 1.5mm 1.5mm;
    page-break-inside: avoid;
  }
  body[data-print="double"] .double-print-wrapper .print-title {
    margin: 0 0 1mm;
    font-size: 22px;
    text-align: center;
    display: block !important; /* 2枚ともに小見出しを表示 */
  }
  body[data-print="double"] .double-print-wrapper .schedule-table {
    margin-top: 0 !important;
    font-size: 11px;
  }
  body[data-print="double"] .double-print-wrapper .print-legend {
    margin-top: 1mm;
    font-size: 10px;
    color: #333;
  }

  /* 2面印刷用の罫線を濃く細く */
  body[data-print="double"] .double-print-wrapper .schedule-table,
  body[data-print="double"] .double-print-wrapper .schedule-table th,
  body[data-print="double"] .double-print-wrapper .schedule-table td {
    border-color: #666 !important;
    border-width: 0.6px !important;
    font-size: 10px;
    padding: 1.5px 1.5px;
  }
  body[data-print="double"] .double-print-wrapper .schedule-table td {
    height: 55px !important;
  }
  body[data-print="double"] .inner,
  body[data-print="double"] .schedule-section,
  body[data-print="double"] .section {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}

/* ================================
   印刷用レイアウト
================================ */
@media print {

  header, footer, h6,.month-nav, .print-buttons ,.doctor-toggle-group{
    display: none !important;
  }
  h2 {
    margin-top: 0 !important;
    font-size: 45px !important;
  }
  html, body {
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
    /* まず上の位置では非表示 */
  #doctor-legend {
    display: none !important;
  }

  /* 印刷専用の略称一覧（下に表示する） */
  #doctor-legend-print {
    display: block !important;
    margin-top: 10mm;
    font-size: 14px;
  font-size: 20px;
  color: #333;
  }
.doctor-legend h5{
  font-size: 20px;
  color: #333;
}

  .schedule-table td {
    height: 81px !important;
    padding: 4px !important;
  }

  body[data-print="color"] .schedule-table,
  body[data-print="color"] .schedule-table th,
  body[data-print="color"] .schedule-table td {
    border: 1px solid #000 !important;
    color: #000 !important;
    background: #fff !important;
  }
  body[data-print="color"] .time-label,
  body[data-print="color"] .date,
  body[data-print="color"] .half-closed {
    color: #000 !important;
  }

  .doctor-badge {
    font-size: 20px !important;
    padding: 4px 10px !important;
  }

  body[data-print="mono"] .doctor-badge {
    background-color: #fff !important;
    color: #000 !important;
    border: 0.5px solid #000 !important;
  }
  body[data-print="mono"] .schedule-table,
  body[data-print="mono"] .schedule-table th,
  body[data-print="mono"] .schedule-table td {
    border: 1px solid #000 !important;
    color: #000 !important;
    background: #fff !important;
  }
  body[data-print="mono"] .doctor-legend,
  body[data-print="mono"] .doctor-badge {
  font-size: 25px;
  color: #333;
  }

  /* ブラウザ余白を限界までゼロに寄せる */
  html, body {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* セクションの余白をゼロにする */
  .schedule-section {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  /* タイトルの上下余白もゼロに */
  #schedule-title,
  .schedule-title,
  h2 {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  /* テーブルをページ上にぴったり寄せる */
  .schedule-table {
    margin-top: 0 !important;
  }

  /* 印刷時の罫線を明瞭に */
  .schedule-table,
  .schedule-table th,
  .schedule-table td {
    border-color: #666 !important;
    border-width: 0.6px !important;
  }

  /* 2面印刷時は上部の大きいタイトルを隠す */
  body[data-print="double"] #schedule-title {
    display: none !important;
  }
}

/* 休診は日付の後ろへ */
.half-closed {
  z-index: 1 !important;
}

/* ================================
   2面印刷 最終調整（高さ優先）
================================ */
@media print {
  body[data-print="double"] .double-print-wrapper .print-card {
    padding: 2mm 1.5mm !important;
  }
  body[data-print="double"] .double-print-wrapper .print-title {
    font-size: 16px !important;
    margin-bottom: 1mm !important;
  }
  body[data-print="double"] .double-print-wrapper .schedule-table,
  body[data-print="double"] .double-print-wrapper .schedule-table th,
  body[data-print="double"] .double-print-wrapper .schedule-table td {
    font-size: 9px !important;
    border-color: #666 !important;
    border-width: 0.6px !important;
  }
  body[data-print="double"] .double-print-wrapper .schedule-table td {
    height: 45px !important;
    padding: 1.5px 1.5px !important;
  }
  body[data-print="double"] .double-print-wrapper .print-legend {
    font-size: 8px !important;
    margin-top: 1mm !important;
  }
  /* A5×2：画面上の休日当番医枠は隠し、カード内の1行だけを表示 */
  body[data-print="double"] #holiday-duty,
  body[data-print="double"] #holiday-duty-single {
    display: none !important;
  }
  /* カード内に差し込んだ1行用 (#holiday-duty-single) は表示 */
  body[data-print="double"] .double-print-wrapper #holiday-duty-single {
    display: inline-block !important;
    margin: 4px 0;
  }

  /* doctorcopy: 印刷時のみ休日当番医を1行表示し、通常枠は非表示 */
  .doctorcopy-page .legend-wrap .holiday-duty {
    display: none !important;
  }
  .doctorcopy-page .holiday-duty-print-only {
    display: inline-block !important;
    margin: 8px 0 4px;
  }
  .doctorcopy-page #holiday-duty-single {
    display: inline-block !important;
  }
  .doctorcopy-page #doctor-legend-print {
    display: block !important;
  }
  /* 当番医なしの場合は1行枠も出さない */
  .doctorcopy-page:not([data-holiday-duty]) #holiday-duty-single,
  .doctorcopy-page:not([data-holiday-duty]) .holiday-duty-print-only {
    display: none !important;
  }
}
