/* =========================================================
   会社カレンダー作成ツール 専用スタイル
   （styles.css の配色トークンを共有）
   ========================================================= */

.cal-section { background: var(--bg-alt); padding-top: clamp(32px,5vw,56px); }

.cal-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 28px;
  align-items: start;
}

/* ===================== 入力パネル ===================== */
.cal-panel {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 20px 26px; position: sticky; top: calc(var(--header-h) + 14px);
  max-height: calc(100vh - var(--header-h) - 28px); overflow-y: auto;
}
.cal-panel .tool-step {
  font-size: 12px; font-weight: 700; color: var(--yellow-dark); letter-spacing: .06em;
  margin: 20px 0 12px; padding-bottom: 7px; border-bottom: 2px solid var(--yellow-tint);
}
.cal-panel .tool-step:first-child { margin-top: 0; }
.cal-panel .field { margin-bottom: 13px; }
.cal-panel label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: #3a3f45; }
.cal-panel .hint { font-weight: 400; color: var(--text-soft); font-size: 11px; letter-spacing: 0; }
.cal-panel input[type="text"], .cal-panel input[type="number"], .cal-panel select {
  width: 100%; padding: 9px 10px; font-size: 14px; font-family: var(--font-jp);
  border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text);
}
.cal-panel input:focus, .cal-panel select:focus { outline: 2px solid var(--yellow); border-color: var(--yellow); }
.cal-panel .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cal-panel .row3 { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 8px; }
.row-hm { display: flex; align-items: center; gap: 6px; }
.row-hm select { width: auto; flex: 1; }
.row-hm .u { font-size: 12px; color: var(--text-soft); }

.c-dow-wrap { display: flex; gap: 5px; }
.c-dow-chip {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 0;
  position: relative; font-size: 13px; font-weight: 700; padding: 7px 0; margin: 0 !important;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; user-select: none;
  color: #3a3f45; background: #fff;
}
.c-dow-chip.sun { color: #c0392b; }
.c-dow-chip.sat { color: #2563a8; }
.c-dow-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.c-dow-chip:has(input:checked) { background: var(--yellow); border-color: var(--yellow); color: #fff; }

.c-check {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500 !important;
  color: #3a3f45; margin-bottom: 9px; cursor: pointer;
}
.c-check input { width: auto !important; accent-color: var(--yellow); }

.c-radio { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.c-radio label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer; margin: 0; }
.c-radio input { width: auto !important; accent-color: var(--yellow); }

.c-edit-time {
  display: none; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--yellow-tint); border-radius: 9px; padding: 9px 11px; margin-bottom: 10px; font-size: 12.5px;
}
.c-edit-time.show { display: flex; }
.c-edit-time select { width: auto !important; flex: 0 0 auto; padding: 5px 8px !important; }
.c-edit-time .u { color: var(--text-soft); }

.cal-panel .btn-tool { margin-top: 8px; }
.cal-panel .tool-note {
  margin-top: 14px; font-size: 11.5px; color: var(--text-soft); line-height: 1.7;
  background: var(--bg-alt); border-radius: 9px; padding: 10px 12px;
}

/* ===================== チェックボックス（要件） ===================== */
.cal-check-box { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.cal-check-head { font-size: 12.5px; font-weight: 700; border-radius: 9px; padding: 10px 12px; line-height: 1.6; }
.cal-check-head.ok { background: #e8f4ec; color: #1f7a44; }
.cal-check-head.ng { background: #fdecec; color: #b3261e; }
.cal-check-list { margin: 12px 0 0; display: flex; flex-direction: column; gap: 7px; }
.cal-check-list li { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; align-items: center; font-size: 12px; }
.cal-check-list .mk { font-weight: 700; text-align: center; }
.cal-check-list li.ok .mk { color: #1f7a44; }
.cal-check-list li.ng .mk { color: #b3261e; }
.cal-check-list li.ng .lb { font-weight: 700; }
.cal-check-list .dt { color: var(--text-soft); font-size: 11px; white-space: nowrap; }
.cal-check-note { margin-top: 12px; font-size: 10.5px; color: var(--text-soft); line-height: 1.7; }

/* ===================== カレンダー本体 ===================== */
.cal-main { min-width: 0; }
.cal-toolbar {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 16px; font-size: 12.5px; color: var(--text-soft);
}

.cal-print {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: clamp(18px,3vw,32px);
  display: flex; flex-direction: column;
  /* テーマ色（既定＝ワインレッド）。テーマクラスで上書き */
  --cal-accent: #5c0119; --cal-accent-d: #7a1226; --cal-tint: #f9eef0; --cal-on: #fff;
}
/* 画面の表示順：見出し→サマリー→月→集計（DOMは 見出し→月→サマリー→集計） */
.cal-doc-head  { order: 0; }
.cal-summary   { order: 1; }
.cal-months    { order: 2; }
.cal-agg       { order: 3; }
.cal-foot-note { order: 4; }

/* テーマ（色） */
.cal-print.theme-apply { --cal-accent:#3a3f45; --cal-accent-d:#000;     --cal-tint:#f0f1f2; --cal-on:#fff; }
.cal-print.theme-wine  { --cal-accent:#5c0119; --cal-accent-d:#7a1226; --cal-tint:#f9eef0; --cal-on:#fff; }
.cal-print.theme-blue  { --cal-accent:#1f5b8f; --cal-accent-d:#163f63; --cal-tint:#eaf1f8; --cal-on:#fff; }
.cal-print.theme-green { --cal-accent:#1f7a44; --cal-accent-d:#155c32; --cal-tint:#e9f5ee; --cal-on:#fff; }

.cal-doc-head { text-align: center; margin-bottom: 20px; }
.cal-doc-company { font-size: clamp(18px,2.6vw,24px); font-weight: 700; letter-spacing: .04em; color: var(--cal-accent); }
.cal-doc-title { font-size: 13px; color: var(--text-soft); margin-top: 4px; letter-spacing: .05em; }
.cal-doc-meta { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: #3a3f45; }

/* サマリーカード */
.cal-summary { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 22px; }
.cal-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 12px; text-align: center; background: #fff;
}
.cal-card .k { display: block; font-size: 11px; color: var(--text-soft); }
.cal-card .v { display: block; font-size: 22px; font-weight: 700; margin: 4px 0 2px; color: var(--cal-accent); letter-spacing: .02em; }
.cal-card .sub { display: block; font-size: 10.5px; color: var(--text-soft); }
.cal-card.bad { border-color: #e7a3a0; background: #fdf3f3; }
.cal-card.bad .v { color: #b3261e; }

/* 月グリッド */
.cal-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cal-month { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal-month-h {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--cal-accent); padding: 8px 12px;
}
.cal-month-h .mt { font-weight: 700; font-size: 14px; color: var(--cal-on); }
.cal-month-h .ms { font-size: 10.5px; color: rgba(255,255,255,.82); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-wd { text-align: center; font-size: 10.5px; font-weight: 700; padding: 5px 0; color: var(--text-soft); background: var(--cal-tint); border-bottom: 1px solid var(--line); }
.cal-wd.sun { color: #c0392b; }
.cal-wd.sat { color: #2563a8; }

.cal-day {
  min-height: 46px; padding: 3px 4px 4px; border-right: 1px solid #eef0f1; border-bottom: 1px solid #eef0f1;
  display: flex; flex-direction: column; align-items: flex-start; cursor: pointer; position: relative;
  transition: background .12s ease;
}
.cal-day:nth-child(7n+7) { border-right: none; }
.cal-day .dn { font-size: 11.5px; font-weight: 700; line-height: 1.2; }
.cal-day .hh { font-size: 9px; color: var(--text-soft); margin-top: auto; line-height: 1.1; }
.cal-day.out { background: #fafbfb; cursor: default; color: #c7ccd0; }
.cal-day.out .dn { color: #cdd2d6; font-weight: 500; }
.cal-day.sun .dn { color: #c0392b; }
.cal-day.sat .dn { color: #2563a8; }
.cal-day.work:hover { background: var(--cal-tint); }
.cal-day.holi { background: var(--cal-tint); }
.cal-day.holi .hh { color: var(--cal-accent-d); font-weight: 700; }
.cal-day.holi:hover { filter: brightness(.97); }
.cal-day.jhol::after { content: ""; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--cal-accent-d); }
body.mode-time .cal-day.work:hover { background: #eaf2fb; }

/* 集計表 */
.cal-agg { margin-top: 26px; }
.cal-agg-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; padding-left: 12px; border-left: 4px solid var(--cal-accent); }
.cal-agg-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cal-agg-table th, .cal-agg-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: center; }
.cal-agg-table thead th { background: var(--cal-accent); color: var(--cal-on); }
.cal-agg-table td:first-child, .cal-agg-table th:first-child { text-align: left; }
.cal-agg-table tfoot th { background: var(--bg-alt); font-weight: 700; }

.cal-foot-note { margin-top: 18px; font-size: 10.5px; color: var(--text-soft); text-align: center; }

/* ===================== 申請用（モノクロ）テーマの上書き ===================== */
.theme-apply .cal-month-h { background: #ececed; }
.theme-apply .cal-month-h .mt { color: #000; }
.theme-apply .cal-month-h .ms { color: #444; }
.theme-apply .cal-doc-company { color: #000; }
.theme-apply .cal-card .v { color: #000; }
.theme-apply .cal-wd { background: #f5f5f5; }
.theme-apply .cal-day.holi { background: #f3f3f3; }
.theme-apply .cal-day.holi .hh { color: #000; }
.theme-apply .cal-day.jhol::after { background: #000; }
.theme-apply .cal-agg-title { border-left-color: #000; }
.theme-apply .cal-agg-table thead th { background: #ececed; color: #000; }

/* テーマの色見本（ラジオ横の丸） */
.c-theme label { gap: 6px; }
.c-theme .sw { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.15); flex: 0 0 auto; }
.sw-apply { background: linear-gradient(135deg,#fff 50%,#888 50%); }
.sw-wine  { background: #5c0119; }
.sw-blue  { background: #1f5b8f; }
.sw-green { background: #1f7a44; }

/* ===================== レスポンシブ ===================== */
@media (max-width: 920px) {
  .cal-layout { grid-template-columns: 1fr; }
  .cal-panel { position: static; max-height: none; }
  .cal-summary { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 460px) {
  .cal-day { min-height: 40px; }
  .cal-day .hh { font-size: 8px; }
}

/* ===================== 印刷（1枚目＝カレンダー / 2枚目＝集計） ===================== */
@media print {
  @page { size: A4 portrait; margin: 8mm; }
  body { background: #fff; }
  .site-header, .site-footer, .page-head, .cal-panel, .cal-toolbar, .no-print, .float-banner { display: none !important; }
  .cal-section { padding: 0 !important; background: #fff !important; }
  .cal-section .container { max-width: none; padding: 0; }
  .cal-layout { display: block; gap: 0; }
  /* flex を解除し、DOM順（見出し→月→サマリー→集計）で改ページ制御 */
  .cal-print { display: block; border: none; border-radius: 0; padding: 0; }
  .cal-doc-head, .cal-summary, .cal-months, .cal-agg, .cal-foot-note { order: 0 !important; }
  /* 背景色をそのまま印刷 */
  .cal-month-h, .cal-wd, .cal-day.holi, .cal-card, .cal-card.bad,
  .cal-agg-table thead th, .cal-agg-table tfoot th, .cal-day.jhol::after {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .cal-day.work:hover, .cal-day.holi:hover { background: var(--cal-tint); filter: none; }

  /* === 1枚目：見出し ＋ カレンダー（3列×4段で大きく） === */
  .cal-doc-head { margin-bottom: 4mm; }
  .cal-doc-company { font-size: 16pt; }
  .cal-doc-title { font-size: 8.5pt; margin-top: 3px; }
  .cal-doc-meta { font-size: 9pt; gap: 18px; margin-top: 4px; }

  .cal-months { gap: 4px; grid-template-columns: repeat(3, 1fr); margin: 0; }
  .cal-month { break-inside: avoid; border-radius: 0; border-color: #c2c7cb; }
  .cal-month-h { padding: 2px 6px; }
  .cal-month-h .mt { font-size: 9.5pt; }
  .cal-month-h .ms { font-size: 6pt; }
  .cal-wd { font-size: 6.5pt; padding: 1.5px 0; }
  .cal-day { min-height: 0; height: 7.4mm; padding: 1px 4px; border-color: #dfe2e4; }
  .cal-day .dn { font-size: 8.5pt; }
  .cal-day .hh { font-size: 6pt; margin-top: auto; line-height: 1.05; }
  .cal-day.jhol::after { width: 4px; height: 4px; top: 3px; right: 3px; }

  /* === 2枚目：サマリー ＋ 月別集計 === */
  .cal-summary { break-before: page; page-break-before: always; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 9mm; }
  .cal-card { padding: 12px 10px; border-radius: 8px; }
  .cal-card .k { font-size: 9.5pt; }
  .cal-card .v { font-size: 19pt; margin: 4px 0 2px; }
  .cal-card .sub { font-size: 8.5pt; }

  .cal-agg { margin-top: 0; break-inside: avoid; }
  .cal-agg-title { font-size: 13pt; margin-bottom: 8px; }
  .cal-agg-table { font-size: 9.5pt; }
  .cal-agg-table th, .cal-agg-table td { padding: 5px 10px; }
  .cal-foot-note { margin-top: 6mm; font-size: 8pt; }
}
