/* 会議室予約システムのスタイル定義 */

:root {
  /* 配色をまとめて管理するためのカラー変数 */
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-free: #ffffff;
  --color-free-hover: #eff6ff;
  --color-reserved: #fca5a5;
  --color-reserved-dark: #ef4444;
  --color-border: #d1d5db;
  --color-text: #1f2937;
  --color-muted: #6b7280;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  color: var(--color-text);
  background: #f3f4f6;
}

/* ヘッダー */
.app-header {
  background: var(--color-primary);
  color: #fff;
  padding: 20px 24px;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.subtitle {
  margin: 6px 0 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* メインコンテナ（.container はサイト共通ヘッダー等と衝突するため予約画面は .app-container を使用） */
.app-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ===== カレンダー画面 ===== */

/* 管理者ボタンを置く上部バー（右寄せ） */
.calendar-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* 無効化されたボタン（前の月など）の共通スタイル */
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 月移動のヘッダー */
.calendar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-controls h2 {
  margin: 0;
  font-size: 1.3rem;
}

.nav-btn {
  background: #e5e7eb;
  color: var(--color-text);
}

.nav-btn:hover {
  background: #d1d5db;
}

/* カレンダー本体 */
.calendar-wrapper {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

#calendar {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

#calendar th {
  background: #f9fafb;
  padding: 10px 0;
  font-size: 0.9rem;
  border: 1px solid var(--color-border);
}

#calendar th.sun { color: #dc2626; }
#calendar th.sat { color: #2563eb; }

#calendar td {
  border: 1px solid var(--color-border);
  height: 76px;
  vertical-align: top;
  padding: 4px;
}

/* 日付マス（クリック可能） */
#calendar td.day {
  cursor: pointer;
  transition: background 0.15s;
}

#calendar td.day:hover {
  background: var(--color-free-hover);
}

/* 月外の空きマス */
#calendar td.empty-day {
  background: #f9fafb;
}

/* 選択できない過去の日（一般利用者向け） */
#calendar td.disabled-day {
  background: #f9fafb;
  cursor: default;
}

#calendar td.disabled-day:hover {
  background: #f9fafb;
}

#calendar td.disabled-day .day-num {
  color: #cbd5e1;
}

/* 日付の数字 */
.day-num {
  font-size: 0.95rem;
  font-weight: bold;
}

.day-num.sun { color: #dc2626; }
.day-num.sat { color: #2563eb; }

/* 本日のマス */
#calendar td.today {
  background: #fef3c7;
}

#calendar td.today:hover {
  background: #fde68a;
}

/* 予約済み会議室の表示（例:「1・3・5会議室 予約あり」） */
.res-badge {
  display: block;
  margin-top: 5px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.68rem;
  line-height: 1.3;
  padding: 2px 5px;
  border-radius: 4px;
  /* セル幅を超える場合は折り返して表示する */
  word-break: break-all;
}

/* カレンダー下部のヒント文 */
.calendar-hint {
  margin-top: 14px;
  color: var(--color-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* 汎用の非表示クラス */
.hidden {
  display: none;
}

/* ===== 利用集計（管理者向け） ===== */
.admin-summary {
  margin-top: 28px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 18px 20px 20px;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.summary-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.summary-table-wrapper {
  overflow-x: auto;
}

#summary-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 420px;
}

#summary-table th,
#summary-table td {
  border: 1px solid var(--color-border);
  padding: 10px 12px;
  text-align: right;
  font-size: 0.9rem;
}

#summary-table thead th {
  background: #f9fafb;
  text-align: center;
}

/* 会議室名の列は左寄せ */
#summary-table .s-room {
  text-align: left;
  font-weight: bold;
}

/* 合計行は強調する */
#summary-table .summary-total td {
  background: #eff6ff;
  font-weight: bold;
}

.summary-note {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--color-muted);
}

/* ===== 予約表画面 ===== */

/* 操作エリア（戻るボタン・日付表示） */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* カレンダーへ戻るリンク */
.back-link {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 6px;
  background: #e5e7eb;
}

.back-link:hover {
  background: #d1d5db;
}

/* 選択中の日付ラベル */
.date-label {
  margin: 0;
  font-size: 1.2rem;
}

/* 管理者ログインボタン（右端に配置） */
.admin-btn {
  margin-left: auto;
  background: #e5e7eb;
  color: var(--color-text);
  font-size: 0.85rem;
}

.admin-btn:hover {
  background: #d1d5db;
}

/* 管理者モード中のボタン（有効状態を色で示す） */
.admin-btn.active {
  background: #15803d;
  color: #fff;
}

.admin-btn.active:hover {
  background: #166534;
}

/* 凡例 */
.legend {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--color-muted);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cell-sample {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
}

.cell-sample.free { background: var(--color-free); }
.cell-sample.reserved { background: var(--color-reserved); }

/* 予約表 */
.grid-wrapper {
  overflow-x: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#reserve-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 640px;
}

#reserve-table th,
#reserve-table td {
  border: 1px solid var(--color-border);
  text-align: center;
  padding: 0;
}

#reserve-table thead th {
  background: #f9fafb;
  padding: 12px 8px;
  font-size: 0.9rem;
}

.time-col {
  width: 110px;
  background: #f9fafb;
  font-size: 0.85rem !important;
  white-space: nowrap;
}

/* 時間帯セル（行見出し） */
.time-label {
  padding: 10px 8px;
  font-size: 0.85rem;
  color: var(--color-muted);
  background: #f9fafb;
  white-space: nowrap;
}

/* 予約セル（30分刻みで行数が多いため高さは控えめにする） */
.slot {
  height: 38px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.slot.free {
  background: var(--color-free);
}

.slot.free:hover {
  background: var(--color-free-hover);
}

.slot.reserved {
  background: var(--color-reserved);
  /* 通常（一般利用者）は取消できないため、クリック可能に見せない */
  cursor: default;
}

/* 管理者モードのときだけ、予約済みセルを取消操作できる見た目にする */
.admin-mode .slot.reserved {
  cursor: pointer;
}

.admin-mode .slot.reserved:hover {
  background: var(--color-reserved-dark);
}

/* 予約セル内の予約者名表示 */
.slot .reserver {
  font-size: 0.75rem;
  color: #7f1d1d;
  padding: 2px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 90%;
  max-width: 460px;
  /* 入力項目が多いため、画面に収まらない場合はモーダル内をスクロールさせる */
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close-btn {
  background: var(--color-primary);
  border: none;
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  line-height: 1;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: var(--color-primary-dark);
}

/* 予約枠の確定情報（予約日・予約時間・会議室） */
.slot-summary {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0 0 16px;
}

.slot-summary > div {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}

.slot-summary dt {
  margin: 0;
  width: 72px;
  font-size: 0.85rem;
  color: var(--color-muted);
  flex-shrink: 0;
}

.slot-summary dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: bold;
}

.modal label {
  display: block;
  font-size: 0.85rem;
  font-weight: bold;
  margin: 12px 0 4px;
}

/* ※ 電話・FAXの type="tel" を忘れずに入れること。
   1 つ抜けるとその欄だけブラウザ既定の幅になり、
   他の入力欄と揃わなくなる（2026-10-22 に実際に起きた）。 */
.modal input[type="text"],
.modal input[type="email"],
.modal input[type="tel"],
.modal input[type="number"],
.modal select {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
}

/* 会議室・時間の入力枠 */
.slot-fieldset {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px 14px 14px;
  margin: 0 0 8px;
}

.slot-fieldset legend {
  font-size: 0.9rem;
  font-weight: bold;
  padding: 0 6px;
}

.field-hint {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: var(--color-muted);
  line-height: 1.4;
}

/* 会議室・時間の1行（会議室／開始〜終了／削除） */
.slot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.slot-row select {
  width: auto;
  flex: 1;
  padding: 8px 6px;
  min-width: 0;
}

.slot-row .row-remove {
  background: #f3f4f6;
  color: var(--color-reserved-dark);
  padding: 8px 10px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.slot-row .row-remove:hover {
  background: #fee2e2;
}

/* 行追加ボタン */
.add-btn {
  background: #eff6ff;
  color: var(--color-primary);
  border: 1px dashed var(--color-primary);
  font-size: 0.85rem;
  padding: 8px 12px;
  width: 100%;
}

.add-btn:hover {
  background: #dbeafe;
}

/* 料金表示 */
.price-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 12px 0 4px;
}

.price-box span {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.price-box strong {
  font-size: 1rem;
  color: #15803d;
  text-align: right;
}

/* 必須項目を示すラベル */
.req {
  display: inline-block;
  background: var(--color-reserved-dark);
  color: #fff;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
}

/* 利用区分・支払方法（ラジオボタン） */
.radio-group {
  display: flex;
  gap: 20px;
  margin-top: 4px;
}

/* 割増料・備品（チェックボックスグループ） */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 4px;
}

/* 割増料は説明文が長いため縦並び */
.surcharge-group {
  flex-direction: column;
  gap: 6px;
}

.radio-inline,
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  font-size: 0.95rem;
  cursor: pointer;
  margin: 0;
}

/* 使用予定者数（数値入力＋「人」） */
.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-field input[type="number"] {
  width: 100px;
}

/* 案内ボード掲示（チェックボックス） */
.checkbox-field {
  margin-top: 14px;
}

/* 案内ボード掲示を希望したときだけ開く入力欄 */
.board-detail {
  margin-top: 10px;
  padding: 12px 14px 14px;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.board-detail label {
  margin-top: 0;
}

/* 入力欄の下に添える補足説明 */
.field-note {
  margin: 6px 0 0;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--color-muted);
}

.modal-error {
  color: var(--color-reserved-dark);
  font-size: 0.85rem;
  margin: 10px 0 0;
}

.modal-error.hidden {
  display: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ボタン（サイト共通ヘッダーのボタンに影響しないよう範囲を限定） */
.app-container button,
.app-header button,
.modal-overlay button {
  cursor: pointer;
  font-size: 0.95rem;
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--color-text);
}

.btn-secondary:hover {
  background: #d1d5db;
}

#today-btn {
  background: #e5e7eb;
  color: var(--color-text);
}

#today-btn:hover {
  background: #d1d5db;
}

/* ===== 料金表 ===== */
.fee-section {
  margin-top: 32px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 20px 20px 24px;
}

.fee-title {
  margin: 0 0 16px;
  font-size: 1.1rem;
  padding-left: 12px;
  border-left: 4px solid var(--color-primary);
}

.fee-subtitle {
  margin: 20px 0 6px;
  font-size: 0.88rem;
  font-weight: bold;
  color: var(--color-muted);
}

.fee-subtitle:first-of-type {
  margin-top: 0;
}

.fee-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

.fee-table--wide {
  min-width: 480px;
}

.fee-table th,
.fee-table td {
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: middle;
}

.fee-table thead th {
  background: #f9fafb;
  font-weight: bold;
  white-space: nowrap;
}

.fee-table td:last-child,
.fee-table thead th:last-child {
  text-align: right;
  white-space: nowrap;
}

.fee-nowrap {
  white-space: nowrap;
}

/* ===== サーバー版での追加分 ===== */

/* 管理者からのお知らせ */
.notice-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* 読み込み中・読み込み失敗の表示 */
.calendar-loading {
  margin: 0;
  padding: 14px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-muted);
  background: #fff;
  border-top: 1px solid var(--color-border);
}

.calendar-loading.hidden {
  display: none;
}

/* 休館日のバッジ（カレンダー） */
.closed-badge {
  display: inline-block;
  margin-top: 6px;
  background: #6b7280;
  color: #fff;
  font-size: 0.72rem;
  font-weight: bold;
  padding: 2px 7px;
  border-radius: 10px;
}

/* 休館日のマス */
#calendar td.closed-cell {
  cursor: default;
  background: #f3f4f6;
}

#calendar td.closed-cell:hover {
  background: #f3f4f6;
}

/* 申込できない日のマス（休館日・過去日・受付期間外） */
.slot.slot-disabled {
  cursor: default;
  background: #f9fafb;
}

.slot.slot-disabled:hover {
  background: #f9fafb;
}

/* 休館日などの案内メッセージ */
.full-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.full-message.hidden {
  display: none;
}

/* 予約表上部のレイアウト調整（管理者ボタンを外したため） */
.controls-spacer {
  display: inline-block;
  min-width: 1px;
}

/* 料金表の注記 */
.fee-note {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--color-muted);
  line-height: 1.6;
}

/* フッター（管理者ログインへのリンク） */
.app-footer {
  margin-top: 28px;
  text-align: center;
}

.admin-link {
  font-size: 0.8rem;
  color: var(--color-muted);
  text-decoration: none;
}

.admin-link:hover {
  text-decoration: underline;
}

/* 申込完了の表示 */
.done-box {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 16px 18px;
}

.done-box.hidden {
  display: none;
}

.done-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: bold;
  color: #047857;
}

.done-detail {
  margin: 0;
}

.done-detail > div {
  display: flex;
  gap: 8px;
  padding: 3px 0;
}

.done-detail dt {
  margin: 0;
  width: 76px;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.done-detail dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: bold;
  word-break: break-word;
}

.done-note {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--color-muted);
  line-height: 1.6;
}

/* ボット対策（Cloudflare Turnstile）の確認欄 */
.turnstile-box {
  margin: 16px 0 4px;
  min-height: 65px;
}

.turnstile-box:empty {
  min-height: 0;
}

/* サイト共通ヘッダー内に組み込んだ際の予約エリア背景 */
.reserve-app {
  background: #f3f4f6;
}
