/* ============================================================
   Student Athlete Diary - メインCSS
   ============================================================ */

/* ---- リセット ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP',
               'Yu Gothic', sans-serif;
  line-height: 1.6;
  color: #1a1a2e;
  background: #f5f7fa;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font: inherit; }

/* ---- カラーパレット ---- */
:root {
  --clr-primary:    #2563eb;
  --clr-primary-d:  #1d4ed8;
  --clr-accent:     #10b981;
  --clr-danger:     #ef4444;
  --clr-warning:    #f59e0b;
  --clr-surface:    #ffffff;
  --clr-border:     #e2e8f0;
  --clr-text:       #1a1a2e;
  --clr-text-sub:   #64748b;
  --clr-bg:         #f5f7fa;
  --nav-h:          60px;
}

/* ---- レイアウト ---- */
.page-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 16px);
}

/* ---- ナビゲーション（ボトム） ---- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  display: flex;
  z-index: 100;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  color: var(--clr-text-sub);
  gap: 2px;
  transition: color .15s;
  min-height: 44px;
}
.bottom-nav a.active,
.bottom-nav a:hover { color: var(--clr-primary); }
.bottom-nav svg { width: 22px; height: 22px; }

/* ---- ヘッダー ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 1.2rem; font-weight: 700; }

/* ---- カード ---- */
.card {
  background: var(--clr-surface);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 12px;
}
.card-title {
  font-size: .8rem;
  color: var(--clr-text-sub);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}

/* ---- 数値カード（ダッシュボード） ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--clr-surface);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  text-align: center;
}
.stat-card .val {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--clr-primary);
}
.stat-card .val.danger { color: var(--clr-danger); }
.stat-card .label { font-size: .75rem; color: var(--clr-text-sub); margin-top: 4px; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  border: none;
  transition: background .15s, opacity .15s;
  cursor: pointer;
}
.btn-primary { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-d); }
.btn-accent  { background: var(--clr-accent); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--clr-primary);
  color: var(--clr-primary);
}
.btn-danger  { background: var(--clr-danger); color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: .8rem; }
.btn-full { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .5; pointer-events: none; }

/* ---- フォーム ---- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--clr-text);
}
.form-label .req { color: var(--clr-danger); margin-left: 2px; }
.form-control {
  width: 100%;
  height: 44px;
  padding: 8px 12px;
  border: 1.5px solid var(--clr-border);
  border-radius: 8px;
  font-size: .95rem;
  font: inherit;
  color: var(--clr-text);
  background: var(--clr-surface);
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea.form-control { height: auto; min-height: 80px; resize: vertical; }
.form-error { color: var(--clr-danger); font-size: .8rem; margin-top: 4px; }

/* ---- スライダー（RPE・VAS） ---- */
.slider-wrap { position: relative; }
input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  border-radius: 3px;
  background: var(--clr-border);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--clr-primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--clr-text-sub);
  margin-top: 4px;
}

/* ---- チップ（複数選択） ---- */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
}
.chip .chip-del {
  width: 16px; height: 16px;
  background: none; border: none;
  color: #0369a1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; line-height: 1; padding: 0;
}

/* ---- リストアイテム ---- */
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--clr-surface);
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.list-item:hover { background: #f8fafc; }
.list-item .meta { flex: 1; }
.list-item .date { font-size: .75rem; color: var(--clr-text-sub); }
.list-item .title { font-size: .95rem; font-weight: 600; margin: 2px 0; }
.list-item .sub   { font-size: .8rem; color: var(--clr-text-sub); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }

/* ---- VAS インジケーター ---- */
.vas-dot {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem; color: #fff; flex-shrink: 0;
}
.vas-low    { background: var(--clr-accent); }
.vas-mid    { background: var(--clr-warning); }
.vas-high   { background: var(--clr-danger);  }

/* ---- 人体図 ---- */
.body-svg-wrap { text-align: center; }
.body-svg-wrap svg { max-width: 200px; margin: 0 auto; }
.body-part-btn {
  fill: #e2e8f0; stroke: #94a3b8; stroke-width: 1.5;
  cursor: pointer; transition: fill .15s;
}
.body-part-btn:hover, .body-part-btn.selected { fill: var(--clr-primary); stroke: var(--clr-primary-d); }

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}
.modal-box {
  background: var(--clr-surface);
  width: 100%; max-width: 480px;
  border-radius: 16px 16px 0 0;
  padding: 24px 20px 32px;
}
@media (min-width: 600px) {
  .modal-box { border-radius: 16px; }
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }

/* ---- トースト ---- */
.toast-wrap {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%; transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .85rem;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.toast.success { background: var(--clr-accent); }
.toast.error   { background: var(--clr-danger);  }

/* ---- ログイン/登録 ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}
.auth-card {
  background: var(--clr-surface);
  border-radius: 16px;
  padding: 32px 24px;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--clr-primary); }
.auth-logo p  { font-size: .8rem; color: var(--clr-text-sub); }

/* ---- コーチダッシュボード ---- */
.athlete-card {
  background: var(--clr-surface);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  display: flex;
  align-items: center;
  gap: 12px;
}
.athlete-card.alert { border-left: 4px solid var(--clr-danger); }
.athlete-card .avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--clr-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.athlete-card .info { flex: 1; }
.athlete-card .name { font-weight: 700; font-size: .95rem; }
.athlete-card .stats { font-size: .75rem; color: var(--clr-text-sub); }
.athlete-card .flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

/* ---- レスポンシブ（PC） ---- */
@media (min-width: 768px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .page-wrap  { padding-top: 24px; }
  .bottom-nav {
    top: 0; bottom: auto;
    height: 56px;
    border-top: none;
    border-bottom: 1px solid var(--clr-border);
  }
  .bottom-nav a { flex-direction: row; font-size: .85rem; gap: 6px; }
  body { padding-top: 56px; }
  .toast-wrap { bottom: 24px; }
  .page-wrap { padding-bottom: 24px; }
}

/* ---- スピナー ---- */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- セクション区切り ---- */
.section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--clr-text-sub);
  margin: 20px 0 8px;
}

/* ---- アクセシビリティ ---- */
:focus-visible {
  outline: 3px solid var(--clr-primary);
  outline-offset: 2px;
}
