/* RhythWe アプリケーション共通CSS */
/* LPのスタイルを踏襲した統一デザイン */

:root {
  /* カラーパレット - RhythWeグリーンテーマ */
  --primary-color: #5AA87C;
  --primary-dark: #4A9068;
  --primary-light: #8BC4A3;
  --secondary-color: #6AB0D4;
  --accent-color: #E6B800;
  
  /* グラデーション */
  --gradient-primary: linear-gradient(135deg, #5AA87C 0%, #6AB0D4 100%);
  --gradient-header: linear-gradient(135deg, #3D8B5F 0%, #4A9068 100%);
  
  /* バイオリズムカラー */
  --physical-color: #E05555;
  --emotional-color: #3DB8AC;
  --intellectual-color: #3A9FC4;
  
  /* ニュートラル */
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-light: #707070;
  --bg-white: #ffffff;
  --bg-gray-50: #f5f7f6;
  --bg-gray-100: #eef1f0;
  --border-color: #d0d5d3;
  
  /* シャドウ */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* トランジション */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
}

/* リセット&ベース */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans JP', 'Segoe UI', sans-serif;
  background: var(--bg-gray-50);
  color: var(--text-primary);
  line-height: 1.6;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition-fast);
}

a:hover {
  color: var(--primary-dark);
}

/* ========================================
   ヘッダー・ナビゲーション
   ======================================== */
.header {
  background: var(--gradient-header);
  color: white;
  padding: 0.4rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
}

.logo a {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.3s;
}

.logo a:hover {
  opacity: 0.9;
  color: inherit;
}

.logo img {
  height: 24px;
  width: auto;
}

.app-version {
  font-size: 0.55rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.02em;
  line-height: 1;
  align-self: flex-end;
  margin-bottom: 2px;
  pointer-events: none;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition-fast);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.3);
}

.user-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: var(--transition-fast);
  z-index: 1001;
}

.user-menu-toggle:hover {
  opacity: 0.8;
}

/* 初心者ガイドボタン */
.guide-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: var(--transition-fast);
  z-index: 1001;
}

.guide-btn:hover {
  opacity: 0.8;
}

/* 初心者ガイドモーダル */
.guide-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.guide-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes guideSlideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.guide-modal .guide-modal-content {
  background: white;
  padding: 1rem;
  border-radius: 10px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  max-width: 480px;
  width: 90%;
  max-height: 85vh;
  overflow-y: hidden;
  animation: guideSlideUp 0.3s ease-out;
  display: flex;
  flex-direction: column;
}

.guide-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0.25rem;
}

.guide-page { display: none; }
.guide-page.active { display: block; }

.guide-section {
  background: #f8f9fa;
  border-left: 4px solid var(--primary-color, #5AA87C);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
  line-height: 1.7;
}
.guide-section-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  color: var(--text-primary, #1a1a1a);
}
.guide-section ul {
  margin: 0.3rem 0 0 1.1rem;
  padding: 0;
}
.guide-section li { margin-bottom: 0.2rem; }

.guide-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 2px solid #f0f0f0;
  flex-shrink: 0;
}
.guide-page-indicator { font-size: 0.9rem; color: #999; font-weight: 500; }
.guide-btn-group { display: flex; gap: 0.5rem; }
.guide-nav-btn {
  padding: 0.45rem 1rem;
  border: 2px solid var(--primary-color, #5AA87C);
  background: white;
  color: var(--primary-color, #5AA87C);
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.88rem;
  transition: all 0.2s;
}
.guide-nav-btn:hover { background: var(--primary-color, #5AA87C); color: white; }
.guide-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.guide-nav-btn:disabled:hover { background: white; color: var(--primary-color, #5AA87C); }

/* ── 全画面共通モーダル：高さ制御 ───────────────────────────────
   .modal-content をフレックスコンテナにして max-height を画面高さ以内に制限。
   ヘッダー・フッターは flex-shrink:0 で固定、ボディのみスクロール。       */
.modal-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
}
.modal-header {
  flex-shrink: 0;
}
.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  flex-shrink: 0;
}

.guide-modal .guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 1rem;
}

.guide-modal .guide-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.guide-modal .guide-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
  transition: color 0.2s, transform 0.2s;
}

.guide-modal .guide-close:hover {
  color: #333;
  transform: rotate(90deg);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 500;
}

.logout-btn {
  background: #e74c3c;
  color: white;
  border: 1px solid #c0392b;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition-fast);
}

.logout-btn:hover {
  background: #c0392b;
  border-color: #a93226;
}

.settings-link {
  color: white;
  background: var(--primary-color);
  border: 1px solid var(--primary-dark);
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-link:hover {
  background: var(--primary-dark);
  color: white;
  border-color: var(--primary-dark);
}

/* ========================================
   モバイルタブナビゲーション
   ======================================== */
.mobile-tab-nav {
  display: none;
  background: var(--bg-white);
  border-bottom: 2px solid var(--border-color);
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 99;
}

.tab-link {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0.75rem 0.5rem 0.35rem;
  min-width: 80px;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.75rem;
  font-weight: 500;
}

.tab-link i {
  font-size: 1.05rem;
  margin-bottom: 0.1rem;
}

.tab-link:hover {
  color: var(--text-primary);
  background: rgba(61, 139, 95, 0.05);
}

.tab-link.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* ========================================
   コンテナ・レイアウト
   ======================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ========================================
   カード
   ======================================== */
.card {
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ========================================
   ボタン
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  border: none;
  text-decoration: none;
}

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

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  color: white;
}

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

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

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

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

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #c82333;
}

.btn.btn-success {
  background: #28a745 !important;
  color: white !important;
  border: none !important;
}

.btn.btn-success:hover {
  background: #218838 !important;
  transform: translateY(-2px);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* ========================================
   フォーム
   ======================================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: var(--transition-fast);
  background: var(--bg-white);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(90, 168, 124, 0.15);
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  flex: 1;
  padding-right: 45px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 1.1rem;
  padding: 5px;
  transition: var(--transition-fast);
}

.password-toggle:hover {
  color: var(--primary-color);
}

/* ========================================
   アラート
   ======================================== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-error {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background-color: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-info {
  background-color: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ========================================
   認証ページ専用
   ======================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--gradient-header);
  padding: 0.5rem 0.5rem;
}

.auth-container {
  background: var(--bg-white);
  padding: 1.5rem 1.5rem;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo {
  width: 160px;
  height: auto;
  margin-bottom: 0.75rem;
}

.auth-header h1 {
  color: var(--text-primary);
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.auth-form .form-group {
  margin-bottom: 1rem;
}

.auth-form .form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.auth-form .form-control {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.auth-form .btn {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  margin-top: 0.25rem;
}

.switch-auth {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.switch-auth a {
  display: block;
  color: var(--primary-color);
  font-weight: 600;
  margin-top: 0.25rem;
}

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

/* モバイル最適化（375px 以下） */
@media (max-width: 400px) {
  .auth-page {
    padding: 0.25rem 0.5rem;
  }

  .auth-container {
    padding: 1rem 1rem;
    border-radius: 12px;
  }

  .auth-header {
    margin-bottom: 0.75rem;
  }

  .auth-logo {
    width: 130px;
    margin-bottom: 0.5rem;
  }

  .auth-header h1 {
    font-size: 1.25rem;
    margin-bottom: 0.15rem;
  }

  .auth-header p {
    font-size: 0.85rem;
  }

  .alert {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }
}

/* ========================================
   ダッシュボード
   ======================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.stat-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-card-icon.physical {
  background: rgba(224, 85, 85, 0.1);
  color: var(--physical-color);
}

.stat-card-icon.emotional {
  background: rgba(61, 184, 172, 0.1);
  color: var(--emotional-color);
}

.stat-card-icon.intellectual {
  background: rgba(58, 159, 196, 0.1);
  color: var(--intellectual-color);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ========================================
   テーブル
   ======================================== */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  background: var(--bg-gray-50);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tbody tr:hover {
  background: var(--bg-gray-50);
}

/* ========================================
   リスト
   ======================================== */
.list-group {
  list-style: none;
}

.list-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition-fast);
}

.list-group-item:last-child {
  border-bottom: none;
}

.list-group-item:hover {
  background: var(--bg-gray-50);
}

/* ========================================
   バッジ
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary {
  background: rgba(90, 168, 124, 0.1);
  color: var(--primary-color);
}

.badge-success {
  background: rgba(22, 101, 52, 0.1);
  color: #166534;
}

.badge-warning {
  background: rgba(230, 184, 0, 0.1);
  color: #92400e;
}

.badge-danger {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
}

/* ========================================
   グラフコントロール行（期間ボタン + infoボタン）
   ======================================== */
.chart-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  position: relative;
}

/* chart-header 内では中央揃え・折り返し禁止に上書き */
.chart-header .period-controls {
  justify-content: center;
  margin-bottom: 0;
  flex-wrap: nowrap;
}

/* info ボタンは右端に絶対配置 */
.chart-header .info-btn {
  position: absolute;
  right: 0;
}

.info-btn {
  background: none;
  color: var(--primary-color);
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, transform 0.2s;
  opacity: 0.75;
  line-height: 1;
  flex-shrink: 0;
}

.info-btn:hover {
  color: var(--primary-dark);
  opacity: 1;
  transform: scale(1.15);
}

/* ========================================
   期間選択ボタン（バイオリズムグラフ共通）
   ======================================== */
.period-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.period-btn {
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--border-color);
  background: var(--bg-white);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
}

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

.period-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
}

.period-btn.active:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
}

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 768px) {
  .period-btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
  }

  .chart-header .period-controls {
    gap: 0.4rem;
  }

  .header {
    flex-direction: row;
    gap: 0.75rem;
    padding: 0.4rem 1rem;
    align-items: center;
    justify-content: space-between;
  }
  
  .logo {
    flex-shrink: 0;
  }
  
  .nav-menu {
    display: none;
  }
  
  .mobile-tab-nav {
    display: flex;
  }
  
  .guide-btn {
    display: block;
    margin-left: auto;
  }

  .user-menu-toggle {
    display: block;
  }
  
  .user-info {
    display: none;
    position: fixed;
    top: 40px;
    right: 0;
    background: white;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    color: var(--text-primary);
  }
  
  .user-info.active {
    display: flex;
  }
  
  .user-info .logout-btn {
    background: #e74c3c;
    width: 100%;
  }

  .user-info .logout-btn:hover {
    background: #c0392b;
  }

  .user-info .settings-link {
    background: var(--primary-color);
    width: 100%;
    justify-content: center;
  }

  .user-info .settings-link:hover {
    background: var(--primary-dark);
  }

  .container {
    padding: 1rem;
  }
  
  .auth-container {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
