/* =====================================================================
   トレーニングセンター 予約システム — スマホファースト CSS
   ===================================================================== */

/* ---- リセット & 基本 ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Hiragino Kaku Gothic ProN", "メイリオ", sans-serif;
  margin: 0; padding: 0;
  background: #F1F3F4; color: #202124;
  font-size: 15px; line-height: 1.55;
  /* iOS スクロール慣性 */
  -webkit-overflow-scrolling: touch;
}

/* ---- レイアウト ---- */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0;          /* スマホはゼロにして card が全幅 */
}
@media (min-width: 600px) {
  .container { margin: 20px auto; padding: 0 12px; }
}

.card {
  background: #FFF;
  border-radius: 0;
  box-shadow: none;
  padding: 14px 12px;
}
@media (min-width: 600px) {
  .card { border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 18px; }
}

/* ---- ヘッダタイトル ---- */
h1.title {
  font-size: 16px;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #1A73E8 0%, #4285F4 100%);
  color: #FFF; border-radius: 8px; text-align: center;
  letter-spacing: 0.02em;
}
@media (min-width: 600px) { h1.title { font-size: 18px; } }

/* ---- タブ ---- */
.tabs {
  display: flex;
  margin: 0 0 14px;
  border-bottom: 2px solid #DADCE0;
  overflow-x: auto;                /* 横スクロール対応 */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1;                         /* 均等分割 */
  min-width: 80px;
  padding: 12px 8px;
  background: transparent; border: none;
  color: #5F6368; font-weight: 600; font-size: 13px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover  { color: #1A73E8; }
.tab.active { color: #1A73E8; border-bottom-color: #1A73E8; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- フォーム部品 ---- */
.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: #5F6368; margin-bottom: 4px;
}
.field select,
.field input[type="text"],
.field input[type="number"],
.field input[type="date"] {
  width: 100%;
  /* スマホでタップしやすい高さ 48px */
  padding: 12px 14px;
  border: 1.5px solid #DADCE0; border-radius: 8px;
  font-size: 16px;          /* iOS zoom 防止 */
  background: #FFF;
  font-family: inherit;
  appearance: none; -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
  touch-action: manipulation;
}
.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%235F6368' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.field select:disabled,
.field input:disabled {
  background: #F1F3F4; color: #9AA0A6; cursor: not-allowed;
}
.field select:focus,
.field input:focus {
  outline: none; border-color: #1A73E8;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.14);
}
.row { display: flex; gap: 10px; }
.row .field { flex: 1; }

/* ---- ボタン ---- */
.btn-primary {
  display: block; width: 100%;
  /* タップ領域 48px */
  padding: 14px 0; margin-top: 8px;
  background: #1A73E8; color: #FFF;
  border: none; border-radius: 8px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-primary:active  { transform: scale(0.98); background: #1558B0; }
.btn-primary:hover   { background: #1558B0; }
.btn-primary:disabled { background: #9AA0A6; cursor: not-allowed; }

.btn-secondary {
  display: inline-block;
  padding: 10px 18px; margin-top: 8px;
  background: #FFF; color: #1A73E8;
  border: 1.5px solid #DADCE0; border-radius: 8px;
  font-size: 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-secondary:active { background: #E8F0FE; }
.btn-secondary:hover  { background: #F1F3F4; }

.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-row .btn-primary { flex: 1; margin-top: 0; }

/* ---- ステータスメッセージ ---- */
.status {
  margin-top: 12px; padding: 12px 14px;
  border-radius: 8px; font-size: 14px;
  display: none; white-space: pre-line;
}
.status.ok    { background:#E6F4EA; color:#137333; display:block; border-left:4px solid #137333; }
.status.error { background:#FCE8E6; color:#C5221F; display:block; border-left:4px solid #C5221F; }

/* ---- セクション見出し ---- */
.section-title {
  font-size: 13px; font-weight: 700;
  color: #1A73E8; margin: 0 0 8px;
  padding-left: 10px;
  border-left: 3px solid #1A73E8;
}
.section-title.muted { color: #5F6368; border-left-color: #DADCE0; }

/* ---- 直近予約リスト（カード型） ---- */
.upcoming-list,
.my-list {
  display: flex; flex-direction: column; gap: 8px; margin-top: 8px;
}

/* スマホ: カード型 */
.up-row,
.my-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: #F8F9FA;
  border-left: 4px solid var(--accent, #1A73E8);
  border-radius: 8px;
  font-size: 14px;
  position: relative;
}
.row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.row-date  { font-weight: 700; white-space: nowrap; }
.row-time  { color: #5F6368; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-count { color: #1A73E8; font-weight: 600; white-space: nowrap; margin-left: auto; }
.row-group { font-size: 13px; color: #202124; }
.row-sup   { font-size: 12px; color: #9AA0A6; }
.row-actions { margin-top: 6px; }

.my-row.past { opacity: 0.6; }

/* デスクトップ: 横並び（元の見た目を維持） */
@media (min-width: 600px) {
  .up-row,
  .my-row {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .row-top    { flex: 1; flex-wrap: nowrap; }
  .row-group  { flex: 1; font-size: 14px; }
  .row-count  { margin-left: 0; }
  .row-actions { margin-top: 0; }
}

/* ---- アイコンボタン ---- */
.icon-btn {
  background: #FFF; border: 1.5px solid #DADCE0;
  border-radius: 6px; padding: 6px 14px;
  font-size: 13px; font-weight: 600;
  color: #1A73E8; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.icon-btn:active { background: #E8F0FE; }
.icon-btn:hover  { background: #F1F3F4; }
.icon-btn.danger { color: #C5221F; border-color: #FADCD9; }
.empty-note { padding: 20px; color: #9AA0A6; font-size: 13px; text-align: center; }

/* ---- 本人識別カード ---- */
.identity-card {
  background: #E8F0FE; border: 1px solid #C6DAFC;
  border-radius: 8px; padding: 12px 14px;
  font-size: 13px; color: #174EA6;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.identity-card b    { color: #174EA6; }
.identity-card .who { flex: 1; min-width: 120px; }
.identity-card button {
  background: #FFF; color: #1A73E8;
  border: 1px solid #C6DAFC; border-radius: 6px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}

/* ---- 本人ピッカー ---- */
.identity-picker {
  display: none;
  background: #FAFBFC; border: 1px dashed #C6DAFC;
  border-radius: 8px; padding: 14px;
  margin-bottom: 12px;
}
.identity-picker.open { display: block; }

/* ---- 編集パネル ---- */
.edit-panel {
  background: #FFF7E6; border: 1px solid #FBE9A7;
  border-radius: 8px; padding: 14px;
  margin: 10px 0 4px; display: none;
}
.edit-panel.active { display: block; }
.edit-panel-title { font-size: 13px; font-weight: 700; color: #B06000; margin-bottom: 12px; }
.edit-meta {
  background: #FFF; border: 1px dashed #DADCE0;
  border-radius: 6px; padding: 8px 12px;
  font-size: 12px; color: #5F6368; margin-bottom: 12px;
}
.edit-meta b { color: #202124; }

/* ---- 週表示コントロール ---- */
.week-controls {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
  flex-wrap: wrap;
}
.week-title {
  flex: 1; text-align: center;
  font-weight: 700; font-size: 14px;
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.week-btn {
  padding: 8px 12px; background: #FFF; color: #5F6368;
  border: 1.5px solid #DADCE0; border-radius: 6px;
  font-size: 13px; cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.week-btn:active { background: #E8F0FE; color: #1A73E8; }
.week-btn:hover  { background: #F1F3F4; color: #1A73E8; }

/* ---- 週グリッド ---- */
/* スマホ: 横スクロール + 3日表示 */
.week-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #DADCE0;
  border-radius: 8px;
}
.week-grid {
  display: grid;
  /* JS で列数を動的に変える */
  grid-template-rows: 52px 1fr;
  background: #FFF;
  font-size: 11px;
  min-width: 0;
}
.wg-corner {
  border-bottom: 1px solid #DADCE0;
  border-right: 1px solid #E8EAED;
  background: #FAFBFC;
}
.wg-day-header {
  text-align: center; padding: 6px 2px;
  border-bottom: 1px solid #DADCE0;
  border-right: 1px solid #F1F3F4;
  background: #FAFBFC;
}
.wg-day-header:last-child { border-right: none; }
.wg-day-header.today      { background: #E8F0FE; color: #1A73E8; }
.wg-day-name { font-size: 11px; }
.wg-day-num  { font-size: 15px; font-weight: 700; }
.wg-day-header.sun .wg-day-name { color: #C5221F; }
.wg-day-header.sat .wg-day-name { color: #1A73E8; }
.wg-time-axis {
  position: relative; border-right: 1px solid #E8EAED; background: #FFF;
}
.wg-time-label {
  position: absolute; left: 0; right: 3px;
  text-align: right; font-size: 9px; color: #5F6368;
  transform: translateY(-50%); font-variant-numeric: tabular-nums;
}
.wg-day-col {
  position: relative; border-right: 1px solid #F1F3F4; overflow: visible;
}
.wg-day-col:last-child { border-right: none; }
.wg-day-col.today { background: #FAFCFF; }
.wg-hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid #F1F3F4; }
.wg-half-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #F8F9FA; }
.wg-now-line  { position: absolute; left: 0; right: 0; border-top: 2px solid #EA4335; z-index: 5; }
.wg-event {
  position: absolute; border-radius: 4px;
  padding: 2px 4px; color: #FFF;
  font-size: 9px; line-height: 1.3; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15); z-index: 2;
  cursor: default;
}
.wg-event-title { font-weight: 700; }
.wg-event-time  { opacity: 0.95; font-variant-numeric: tabular-nums; }
.wg-event-meta  { opacity: 0.85; font-size: 8px; }
.wg-event-overlap-notice {
  position: absolute; right: 2px; top: 2px;
  font-size: 8px; padding: 1px 3px;
  background: rgba(0,0,0,0.25); border-radius: 2px;
}

/* 凡例 */
.legend {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px; font-size: 12px;
}
.legend-item {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px; background: #F8F9FA;
  border: 1px solid #ECEDEF; border-radius: 12px;
}
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* 更新情報 */
.refresh-info {
  margin-top: 8px; font-size: 11px;
  color: #9AA0A6; text-align: center;
}

/* ---- スピナー ---- */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.5); border-top-color: #FFF;
  border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 人数インジケータ ---- */
.cap-bar-wrap {
  margin: -4px 0 12px;
  background: #F1F3F4; border-radius: 4px; height: 6px; overflow: hidden;
}
.cap-bar {
  height: 100%; border-radius: 4px;
  transition: width .4s ease, background .3s;
}

/* ---- 今日の混雑サマリ（予約タブ上部） ---- */
.today-summary {
  background: linear-gradient(135deg, #E8F0FE 0%, #F8F9FF 100%);
  border: 1px solid #C6DAFC; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.today-summary .ts-label { font-size: 12px; color: #5F6368; }
.today-summary .ts-val   { font-size: 20px; font-weight: 700; color: #1A73E8; }
.today-summary .ts-unit  { font-size: 12px; color: #5F6368; }
.today-summary .ts-bar-wrap {
  flex: 1; min-width: 80px;
  background: #DADCE0; border-radius: 4px; height: 8px; overflow: hidden;
}
.today-summary .ts-bar {
  height: 100%; border-radius: 4px;
  background: #1A73E8; transition: width .4s ease, background .3s;
}

/* ---- フローティング予約ボタン（スマホ専用） ---- */
.fab {
  display: none;
  position: fixed; right: 18px; bottom: 22px;
  width: 56px; height: 56px;
  background: #1A73E8; color: #FFF;
  border: none; border-radius: 50%;
  font-size: 26px; line-height: 56px; text-align: center;
  box-shadow: 0 4px 12px rgba(26,115,232,0.45);
  cursor: pointer; z-index: 100;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background .15s, transform .1s;
}
.fab:active { transform: scale(0.92); background: #1558B0; }
@media (max-width: 599px) {
  .fab { display: block; }
}

/* ---- スマホ専用の微調整 ---- */
@media (max-width: 599px) {
  .card { padding: 12px 10px; }
  h1.title { font-size: 15px; border-radius: 6px; }
  .tab   { font-size: 12px; padding: 10px 6px; }
  .row   { gap: 6px; }
  .btn-primary { font-size: 15px; padding: 13px 0; }
  .field select,
  .field input[type="text"],
  .field input[type="number"],
  .field input[type="date"] {
    font-size: 16px; /* iOS zoom 防止 */
    padding: 10px 12px;
  }
}
