/* healthhabit - 共通スタイル */

:root {
  --primary-color: #139652;
  --primary-dark: #139652b6;
  --primary-light: #81C784;
  --accent-color: #66BB6A;
  --text-dark: #333333;
  --text-light: #666666;
  --bg-color: #F5F5F5;
  --card-bg: #FFFFFF;
  --border-color: #E0E0E0;
  --error-color: #F14522;
  --warning-color: #FF9800;
  --success-color: #4CAF50;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
  --bottom-nav-height: 64px; /* ボトムナビの高さ */
  --logo-banner-height: 41px; /* ロゴバナーの高さ */
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  background-color: var(--bg-color);
  color: var(--text-dark);
  line-height: 1.6;
  padding-bottom: calc(var(--bottom-nav-height) + var(--logo-banner-height)); /* ナビ + ロゴバナー */
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* ヘッダー */
.header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-content {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* カード */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-dark);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-color);
}

.metric-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.metric-label {
  font-size: 14px;
  color: var(--text-light);
}

/* ボタン */
.btn {
  display: inline-block;
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  text-align: center;
  width: 100%;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-secondary {
  background: white;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
  background: var(--primary-light);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--border-color);
}

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

.btn-danger {
  background: var(--error-color);
  color: white;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* フォーム */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
  line-height: 1.4;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-input.error {
  border-color: var(--error-color);
  background-color: #FFF5F5;
}

.form-input.error:focus {
  border-color: var(--error-color);
}

.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  background: white;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* テーブル */
.table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th {
  background: var(--primary-color);
  color: white;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover {
  background: #F9F9F9;
}

/* アラート */
.alert {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-warning {
  background: #FFF3E0;
  border-left: 4px solid var(--warning-color);
  color: #E65100;
}

.alert-danger {
  background: #FFEBEE;
  border-left: 4px solid var(--error-color);
  color: #C62828;
}

.alert-success {
  background: #E8F5E9;
  border-left: 4px solid var(--success-color);
  color: #2E7D32;
}

.alert-info {
  background: #E3F2FD;
  border-left: 4px solid #2196F3;
  color: #1565C0;
}

.alert-icon {
  font-size: 24px;
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-danger {
  background: var(--error-color);
  color: white;
}

.badge-warning {
  background: var(--warning-color);
  color: white;
}

.badge-success {
  background: var(--success-color);
  color: white;
}

/* ボトムナビゲーション */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height); /* CSS変数で高さを指定 */
  background: white;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-light);
  font-size: 12px;
  padding: 8px 16px;
  transition: color 0.3s;
  flex: 1;
}

.nav-item.active {
  color: var(--primary-color);
}

.nav-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

/* ローディング */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.spinner {
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ログイン・登録画面用 */
.auth-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  padding: 20px;
}

.auth-box {
  background: white;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.auth-logo h1 {
  font-size: 24px;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.auth-logo p {
  font-size: 14px;
  color: var(--text-light);
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-light);
}

.auth-link a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* プロフィール写真アップロード */
.profile-upload {
  text-align: center;
  margin-bottom: 20px;
}

.profile-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--primary-color);
  margin: 0 auto 16px;
  overflow: hidden;
  background: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--text-light);
}

.profile-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 病院カード */
.hospital-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.hospital-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.hospital-card.selected {
  border-color: var(--primary-color);
  background: #E8F5E9;
}

.hospital-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.hospital-info {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 4px;
}

/* カレンダー */
.calendar {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.calendar-day:hover {
  background: var(--primary-light);
  color: white;
}

.calendar-day.selected {
  background: var(--primary-color);
  color: white;
}

.calendar-day.disabled {
  color: var(--border-color);
  cursor: not-allowed;
}

/* タイムスロット */
.time-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.time-slot {
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.time-slot:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
  color: white;
}

.time-slot.selected {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.time-slot.disabled {
  background: var(--bg-color);
  color: var(--text-light);
  cursor: not-allowed;
}

/* レスポンシブ調整 */
@media (max-width: 360px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ユーティリティ */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hidden {
  display: none;
}

/* グラフコンテナ */
.chart-container {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.chart-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chart-controls button {
  flex: 1;
  min-width: 80px;
}

/* 体調選択ボタン */
.condition-option {
  padding: 12px 8px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: white;
  transition: all 0.3s;
}

.condition-option:hover {
  border-color: var(--primary-color);
  background: #F1F8F4;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.condition-option.selected {
  border-color: var(--primary-color);
  background: #E8F5E9;
  box-shadow: var(--shadow);
}

/* ============================================================
   症状チェックリスト（スマホ最適化）
   ============================================================ */

/* 症状カテゴリ */
.symptom-category {
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

/* カテゴリヘッダー */
.symptom-category-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #F9F9F9;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.2s;
  min-height: 50px;
}

.symptom-category-header:hover {
  background: #F1F1F1;
}

.symptom-category-header:active {
  background: #ECECEC;
}

.symptom-category-icon {
  font-size: 24px;
  margin-right: 10px;
}

.symptom-category-label {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-dark);
}

.symptom-category-badge {
  background: var(--primary-color);
  color: white;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 12px;
  margin-right: 8px;
  min-width: 20px;
  text-align: center;
  display: none;
}

.symptom-category-arrow {
  font-size: 14px;
  color: var(--text-light);
  transition: transform 0.3s;
}

/* カテゴリコンテンツ */
.symptom-category-content {
  display: none;
  padding: 8px;
  background: white;
}

/* 症状リスト */
.symptom-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

@media (max-width: 400px) {
  .symptom-list {
    grid-template-columns: 1fr;
  }
}

/* 症状項目（スマホ最適化：大きなタップ領域） */
.symptom-item {
  display: block;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.symptom-item input[type="checkbox"] {
  display: none;
}

.symptom-checkbox {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: white;
  transition: all 0.2s;
  min-height: 48px; /* スマホでタップしやすい最小サイズ */
}

.symptom-checkbox:hover {
  border-color: var(--primary-light);
  background: #F9FFF9;
}

.symptom-checkbox:active {
  transform: scale(0.98);
}

.symptom-item input[type="checkbox"]:checked + .symptom-checkbox {
  border-color: var(--primary-color);
  background: #E8F5E9;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.2);
}

.symptom-icon {
  font-size: 20px;
  margin-right: 8px;
  flex-shrink: 0;
}

.symptom-label {
  font-size: 14px;
  color: var(--text-dark);
  flex: 1;
  line-height: 1.4;
}

.symptom-item input[type="checkbox"]:checked + .symptom-checkbox .symptom-label {
  font-weight: 600;
  color: var(--primary-dark);
}

/* ============================================================
   データ確認画面 - タブナビゲーション
   ============================================================ */

/* タブナビゲーション */
.tab-navigation {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: white;
  padding: 8px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.tab-btn {
  flex: 1;
  padding: 12px 24px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.tab-btn:hover {
  background: var(--bg-color);
}

.tab-btn.active {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow);
}

/* タブコンテンツ */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* 期間選択 */
.period-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-sm {
  padding: 10px 16px;
  font-size: 14px;
}

/* メトリクスセクション */
.metric-section {
  margin-bottom: 32px;
}

.metric-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 12px;
  padding-left: 4px;
}

/* グラフカード */
.chart-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.chart-card canvas {
  max-height: 250px;
}

/* 統計カード */
.stats-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.stat-item {
  text-align: center;
}

.stat-label {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
}

/* スクロール最適化 */
@media (max-width: 480px) {
  .metric-section {
    scroll-margin-top: 80px;
  }

  .chart-card canvas {
    max-height: 200px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-value {
    font-size: 18px;
  }
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--card-bg);
  border-radius: 12px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-content h2 {
  margin-bottom: 16px;
  color: var(--text-dark);
  font-size: 20px;
  font-weight: 600;
}

.modal-content p {
  margin-bottom: 20px;
  color: var(--text-light);
  font-size: 14px;
  line-height: 1.5;
}

/* エラーメッセージ */
.error-message {
  background-color: #FFEBEE;
  color: var(--error-color);
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 14px;
  border-left: 4px solid var(--error-color);
  animation: errorFadeIn 0.3s ease-out;
}

@keyframes errorFadeIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 成功メッセージ */
.success-message {
  background-color: #E8F5E9;
  color: var(--success-color);
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 14px;
  border-left: 4px solid var(--success-color);
  animation: errorFadeIn 0.3s ease-out;
}

/* ============================================================
   画像・ロゴ配置
   ============================================================ */

/* 認証画面のロゴ画像 */
.auth-logo-img {
  height: 120px;
  width: auto;
  margin-bottom: 8px;
}

.auth-logo-subtitle {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 8px;
}

/* ヘッダー内キャラクター */
.header-character {
  height: 32px;
  width: auto;
  border-radius: 4px;
}

/* フルロゴ帯 */
.logo-banner {
  background: #fff;
  text-align: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
}

.logo-banner-bottom {
  position: fixed;
  bottom: var(--bottom-nav-height);
  left: 0;
  right: 0;
  border-bottom: none;
  border-top: 1px solid var(--border-color);
  z-index: 99;
}

.logo-banner-img {
  height: 24px;
  width: auto;
  opacity: 0.9;
}
