/* ============================================
   令和8年度がん検診予約システム - 共通スタイル
   スマホ・Web両対応レスポンシブデザイン
   ============================================ */

:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-dark: #154360;
  --secondary: #117a65;
  --secondary-light: #1abc9c;
  --accent: #e74c3c;
  --accent-orange: #e67e22;
  --warning: #f39c12;
  --success: #27ae60;
  --danger: #c0392b;
  --text-dark: #2c3e50;
  --text-mid: #566573;
  --text-light: #aab7b8;
  --bg-light: #f0f3f4;
  --bg-white: #ffffff;
  --border: #d5d8dc;
  --border-light: #eaf2ff;
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.13);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --font: 'Noto Sans JP', 'Hiragino Sans', 'Meiryo', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

/* ===== ページロード時フラッシュ防止 =====
   body.page-loading は visibility:hidden で非表示。
   JSで document.body.classList.remove('page-loading') を呼ぶと表示される。
   ページ切り替え時に管理画面などが一瞬見える問題を防ぐ。
   ================================================ */
body.page-loading {
  visibility: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg-light);
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.7;
}

/* ヘッダー */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: #fff;
  padding: 0;
  box-shadow: 0 3px 12px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
}
.header-logo-icon {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.header-title-group { line-height: 1.3; }
.header-subtitle {
  font-size: 10px;
  opacity: 0.85;
  letter-spacing: 0.05em;
}
.header-main-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.header-nav {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.header-nav a, .header-nav button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font);
  transition: all 0.2s;
  white-space: nowrap;
}
.header-nav a:hover, .header-nav button:hover {
  background: rgba(255,255,255,0.3);
}

/* ハンバーガーボタン（スマホのみ表示） */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.25s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.site-header { position: relative; }

/* メインコンテンツ */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* カード */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-sm { padding: 16px; }
.card-lg { padding: 32px; }

/* セクションタイトル */
.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  border-left: 4px solid var(--primary);
  padding-left: 12px;
  margin-bottom: 16px;
}
.section-subtitle {
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 20px;
}

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--secondary);
  color: #fff;
}
.btn-secondary:hover { background: #0e6655; }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #a93226; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-gray {
  background: #bdc3c7;
  color: #fff;
}
.btn-gray:hover { background: #95a5a6; }
.btn-lg {
  padding: 14px 36px;
  font-size: 16px;
  border-radius: var(--radius);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}
.btn-full { width: 100%; }

/* フォーム */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 6px;
}
.form-label .required {
  color: var(--accent);
  margin-left: 4px;
  font-size: 11px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-dark);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41,128,185,0.12);
}
.form-control:read-only {
  background: #f4f6f7;
  color: var(--text-mid);
}
.form-hint {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}
.form-error {
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
  display: none;
}
.form-error.show { display: block; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23566573' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* バッジ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-available { background: #d5f5e3; color: #1e8449; }
.badge-few { background: #fef9e7; color: #d35400; }
.badge-full { background: #fadbd8; color: #922b21; }
.badge-confirmed { background: #d6eaf8; color: #1a5276; }
.badge-cancelled { background: #f2f3f4; color: #717d7e; }
.badge-done { background: #d5f5e3; color: #1e8449; }
.badge-pending { background: #fef9e7; color: #d35400; }

/* アラート */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-info { background: #eaf4fb; color: #1a5276; border-left: 4px solid var(--primary-light); }
.alert-success { background: #eafaf1; color: #1e8449; border-left: 4px solid var(--success); }
.alert-warning { background: #fef9e7; color: #784212; border-left: 4px solid var(--warning); }
.alert-danger { background: #fdedec; color: #922b21; border-left: 4px solid var(--danger); }

/* ステップインジケーター */
.steps {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 80px;
}
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step.active:not(:last-child)::after,
.step.done:not(:last-child)::after { background: var(--primary-light); }
.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  z-index: 1;
  position: relative;
}
.step.active .step-num { background: var(--primary); }
.step.done .step-num { background: var(--success); }
.step-label {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
}
.step.active .step-label { color: var(--primary); font-weight: 700; }
.step.done .step-label { color: var(--success); }

/* テーブル */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.data-table tr:hover td { background: #f8f9fa; }
.data-table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-mid);
}

/* フッター */
.site-footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,0.75);
  padding: 20px 16px;
  text-align: center;
  font-size: 12px;
  margin-top: 40px;
}
.site-footer a { color: rgba(255,255,255,0.85); }
.footer-callcenter {
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  display: inline-block;
  margin: 8px 0;
  font-size: 13px;
}

/* ローディング */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(26,82,118,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 予約枠カード */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.slot-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.slot-card.available {
  border-color: var(--success);
  background: #eafaf1;
}
.slot-card.available:hover {
  background: #d5f5e3;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.slot-card.few {
  border-color: var(--warning);
  background: #fef9e7;
}
.slot-card.few:hover {
  background: #fdebd0;
  transform: translateY(-2px);
}
.slot-card.full {
  border-color: var(--border);
  background: #f4f6f7;
  cursor: not-allowed;
  opacity: 0.6;
}
.slot-card.selected {
  border-color: var(--primary);
  background: var(--border-light);
  box-shadow: 0 0 0 3px rgba(26,82,118,0.2);
}
.slot-time { font-size: 15px; font-weight: 700; color: var(--text-dark); }
.slot-status { font-size: 12px; margin-top: 4px; }
.slot-icon { font-size: 18px; }

/* カレンダー */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day-header {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 0;
  color: var(--text-mid);
}
.cal-day {
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.cal-day.empty { cursor: default; }
.cal-day.available { background: #eafaf1; color: #1e8449; font-weight: 600; }
.cal-day.available:hover { background: #d5f5e3; }
.cal-day.few { background: #fef9e7; color: #d35400; font-weight: 600; }
.cal-day.few:hover { background: #fdebd0; }
.cal-day.full { background: #f4f6f7; color: #aab7b8; }
.cal-day.disabled { color: #d5d8dc; cursor: default; }
.cal-day.selected { background: var(--primary); color: #fff; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; }
.cal-dot-green { background: #27ae60; }
.cal-dot-orange { background: #e67e22; }
.cal-dot-red { background: #c0392b; }

/* マイページメニュー */
.mypage-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.mypage-menu-item {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.mypage-menu-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  color: var(--primary);
}
.mypage-menu-icon { font-size: 36px; }
.mypage-menu-label { font-size: 14px; font-weight: 700; }
.mypage-menu-desc { font-size: 11px; color: var(--text-light); }

/* ステータス表示 */
.exam-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #f8f9fa;
  margin-bottom: 8px;
}
.exam-status-icon { font-size: 24px; flex-shrink: 0; }
.exam-status-info { flex: 1; }
.exam-status-name { font-weight: 600; font-size: 14px; }
.exam-status-detail { font-size: 12px; color: var(--text-mid); }

/* ============================================
   レスポンシブ（タブレット〜スマホ）
   ============================================ */
@media (max-width: 768px) {
  .header-inner { padding: 8px 12px; }
  .header-main-title { font-size: 12px; }
  .header-subtitle { font-size: 9px; }
  .header-logo-icon { width: 36px; height: 36px; font-size: 18px; }
  .main-content { padding: 16px 12px 32px; }
  .card { padding: 16px; }
  .card-lg { padding: 20px 16px; }
  .section-title { font-size: 16px; }
  .btn-lg { padding: 12px 24px; font-size: 15px; }
  .mypage-menu { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .mypage-menu-item { padding: 18px 12px; }
  .slot-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .modal-box { padding: 20px 16px; }
  .header-nav a, .header-nav button { padding: 4px 10px; font-size: 11px; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 8px; }
}

/* スマホ（600px以下）— タッチ操作最適化 */
@media (max-width: 600px) {
  /* ヘッダー */
  .header-inner { padding: 8px 12px; gap: 8px; }
  .header-logo-icon { width: 36px; height: 36px; font-size: 18px; flex-shrink: 0; }
  .header-main-title { font-size: 13px; white-space: nowrap; }
  .header-subtitle { font-size: 9px; display: block; }
  /* スマホではナビを非表示にしてハンバーガーメニューに切り替え */
  .header-nav { display: none; }
  .header-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px;
    right: 0;
    left: 0;
    background: var(--primary-dark);
    padding: 12px 16px;
    gap: 8px;
    z-index: 999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  }
  .header-nav.open a,
  .header-nav.open button {
    width: 100%;
    text-align: center;
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 8px;
    min-height: 44px;
  }
  /* ハンバーガーボタン表示 */
  .hamburger-btn { display: flex !important; }

  /* メインコンテンツ */
  .main-content { padding: 12px 10px 28px; }
  .card { padding: 14px 12px; border-radius: 8px; }
  .card-lg { padding: 16px 12px; }
  .section-title { font-size: 15px; padding-left: 10px; margin-bottom: 12px; }
  .section-subtitle { font-size: 12px; margin-bottom: 14px; }

  /* ボタン — タッチターゲット最低44px確保 */
  .btn { padding: 11px 18px; font-size: 14px; min-height: 44px; border-radius: 8px; }
  .btn-lg { padding: 14px 22px; font-size: 16px; min-height: 50px; border-radius: 10px; }
  .btn-sm { padding: 9px 14px; font-size: 13px; min-height: 38px; }
  .btn-full { width: 100%; }

  /* フォーム */
  .form-control { padding: 12px 14px; font-size: 16px; } /* iOS zoom防止（16px以上） */
  .form-label { font-size: 13px; }

  /* ステップインジケーター */
  .steps { margin-bottom: 16px; }
  .step { min-width: 52px; }
  .step-num { width: 28px; height: 28px; font-size: 12px; }
  .step-label { font-size: 8px; margin-top: 3px; }

  /* 予約枠グリッド */
  .slot-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .slot-card { padding: 12px 6px; }
  .slot-time { font-size: 14px; }
  .slot-icon { font-size: 20px; }

  /* バッジ */
  .badge { padding: 3px 8px; font-size: 11px; }

  /* アラート */
  .alert { padding: 10px 12px; font-size: 12px; }

  /* モーダル */
  .modal-box { padding: 18px 14px; border-radius: 12px; }
  .modal-title { font-size: 15px; }

  /* フッター */
  .site-footer { padding: 16px 12px; font-size: 11px; }
  .footer-callcenter { font-size: 12px; padding: 8px 12px; }

  /* 受診状況 */
  .exam-status-row { padding: 10px 10px; gap: 8px; }
  .exam-status-icon { font-size: 20px; }
  .exam-status-name { font-size: 13px; }
  .exam-status-detail { font-size: 11px; }
}

/* 極小スマホ（380px以下） */
@media (max-width: 380px) {
  .header-nav { gap: 4px; }
  .header-main-title { font-size: 10px; }
  .main-content { padding: 10px 8px 24px; }
  .card { padding: 12px 10px; }
  .slot-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .step { min-width: 44px; }
  .step-label { font-size: 7px; }
}
