/**
 * records.css
 * トレーニング記録ページ専用スタイル
 * Version: 1.0.0
 * 作成日: 2025-11-19
 *
 * 対応ページ: records.html
 * 対応セクション:
 * - セクション1: トレーニング統計
 * - セクション3: モード別統計
 *
 * 注意事項:
 * - クラス名衝突を避けるため、training-stat-label等の専用クラスを使用
 * - .stat-labelはプレミアム分析と重複しないよう注意
 */

/* ================================================================
   トレーニング統計（セクション1）
   ================================================================ */

/* 上段：累計トレーニング日数を強調 */
.stats-top-section {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  justify-content: space-between;
}

/* 統計項目（横並び3つ） */
.stat-item {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-item > i,
.stat-item > svg {
  flex-shrink: 0;
}

.stat-item-subtitle {
  font-size: 0.9375rem;
  color: #93c5fd;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

.stat-item-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.2;
  white-space: nowrap;
}

.stat-item-value-stacked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  white-space: normal;
}

.stat-item-date {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.2;
}

.stat-item-elapsed {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-white-60);
  line-height: 1.2;
}

/* 下段：4つの数値カード（PC版：1行4カード / モバイル版：2×2グリッド） */
.stats-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 2rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-white);
  margin-bottom: 0.5rem;
  line-height: 1;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.training-stat-label {
  font-size: 0.9375rem;
  color: #93c5fd;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* モバイル版レスポンシブ */
@media (max-width: 767px) {
  .stats-top-section {
    flex-direction: column;
    gap: 0.75rem;
  }

  .stat-item {
    padding: 0.75rem 0.5rem;
    gap: 0.375rem;
  }

  .stat-item-subtitle {
    font-size: 0.875rem;
  }

  .stat-item-value {
    font-size: 1.25rem;
  }

  .stat-item-date {
    font-size: 1rem;
  }

  .stat-item-elapsed {
    font-size: 0.75rem;
  }

  .stats-cards-grid {
    /* モバイル版：2×2グリッド */
    grid-template-columns: repeat(2, 1fr);
    gap: 0.875rem;
    margin-top: 1.5rem;
  }

  .stat-card {
    padding: 1rem;
    border-radius: 10px;
  }

  .stat-value {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
  }

  .training-stat-label {
    font-size: 0.875rem;
  }
}

/* ================================================================
   モード別統計（セクション3）
   ================================================================ */

/* デスクトップ版テーブル */
.mode-stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem; /* 見出しとの余白 */
}

.mode-stats-table th {
  text-align: left; /* 1列目（モード名）は左寄せ */
  padding: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-white-60);
  font-size: 1rem; /* 14px → 16px */
  font-weight: 500;
}

/* 数値列のヘッダーは中央寄せ */
.mode-stats-table th:nth-child(2),
.mode-stats-table th:nth-child(3),
.mode-stats-table th:nth-child(4) {
  text-align: center;
}

.mode-stats-table td {
  padding: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-white);
  font-size: 1rem; /* 14px → 16px */
}

.mode-stats-table td:nth-child(2),
.mode-stats-table td:nth-child(3),
.mode-stats-table td:nth-child(4) {
  text-align: center;
}

.mode-stats-table td:nth-child(4) {
  font-weight: 600;
}

/* グレードセル（アイコン + テキスト） */
.grade-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

/* モバイル版（1カード内に全モード、横線区切り） */
.mode-stats-mobile {
  display: none; /* デフォルトは非表示（PCでは表示しない） */
  flex-direction: column;
  margin-top: 1.5rem; /* 見出しとの余白 */
}

.mode-stat-item {
  padding: 0.75rem 0;
  background: transparent; /* 背景を透明に（glass-cardの背景を継承） */
}

.mode-stat-item:first-child {
  padding-top: 0;
}

.mode-stat-item:last-child {
  padding-bottom: 0;
}

.mode-stat-item .mode-name {
  color: var(--text-white);
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 1rem; /* 14px → 16px */
}

.mode-stat-item .mode-stats-row {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  font-size: 1rem; /* 14px → 16px */
}

.mode-stat-item .mode-stats-row > span {
  flex: 1;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: transparent; /* 背景を透明に */
}

/* 最初の2つのspan（回数・誤差）のみ色指定 */
.mode-stat-item .mode-stats-row > span:not(:last-child) {
  color: var(--text-white-70);
}

/* 最後のspan（グレード）は太字のみ、色はHTMLで指定 */
.mode-stat-item .mode-stats-row > span:last-child {
  font-weight: 600;
  /* 色はHTMLのクラス（text-yellow-300等）が適用される */
}

/* グレード色を確実に適用（specificityを高くする） */
.mode-stat-item .mode-stats-row > span.text-yellow-300 { color: #fde047; }
.mode-stat-item .mode-stats-row > span.text-gray-300 { color: #9ca3af; }
.mode-stat-item .mode-stats-row > span.text-orange-300 { color: #fdba74; }
.mode-stat-item .mode-stats-row > span.text-green-300 { color: #86efac; }
.mode-stat-item .mode-stats-row > span.text-blue-300 { color: #93c5fd; }
.mode-stat-item .mode-stats-row > span.text-red-300 { color: #fca5a5; }

/* モード間の横線区切り */
.mode-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 0;
}

/* レスポンシブ切り替え */
@media (max-width: 767px) {
  .mode-stats-table {
    display: none;
  }
  .mode-stats-mobile {
    display: flex;
  }
}

@media (min-width: 768px) {
  .mode-stats-table {
    display: table;
  }
  .mode-stats-mobile {
    display: none;
  }
}

/* ================================================================
   セレクトボックス（ソート機能用）
   ================================================================ */

.form-select-compact {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 16px;
}

.form-select-compact:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.form-select-compact:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(59, 130, 246, 0.5);
}

.form-select-compact option {
  background: #1a1a2e;
  color: #ffffff;
}

/* ================================================================
   レッスン履歴テーブル（セクション2）
   ================================================================ */

/* テーブルコンテナ */
.lesson-history-table-container {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* テーブル本体 */
.lesson-history-table {
  width: 100%;
  border-collapse: collapse;
}

/* ヘッダー行 */
.lesson-history-table thead tr {
  background: rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.lesson-history-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lesson-history-table th:last-child {
  text-align: center;
  width: 40px;
}

/* ヘッダーの評価列: 中央寄せ */
.lesson-history-table th:nth-child(3) {
  text-align: center;
}

/* ヘッダーの誤差列: 右寄せ */
.lesson-history-table th:nth-child(4) {
  text-align: right;
}

/* データ行 */
.lesson-history-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.2s ease;
}

.lesson-history-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.08);
}

.lesson-history-table tbody tr:last-child {
  border-bottom: none;
}

.lesson-history-table td {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.9);
  vertical-align: middle;
}

/* 日時列 */
.lesson-history-table .col-date {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* モード列 */
.lesson-history-table .col-mode {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lesson-history-table .col-mode i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* グレード列 */
.lesson-history-table .col-grade {
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
}

/* 誤差列 */
.lesson-history-table .col-error {
  text-align: right;
  font-family: 'Inter', monospace;
}

/* 矢印列 */
.lesson-history-table .col-arrow {
  text-align: center;
  color: rgba(255, 255, 255, 0.3);
}

/* グレード色（UIカタログ総合評価準拠） */
.col-grade.grade-s,
.lesson-history-mobile-grade.grade-s {
  color: #fcd34d; /* yellow-300 */
}

.col-grade.grade-a,
.lesson-history-mobile-grade.grade-a {
  color: #d1d5db; /* gray-300 */
}

.col-grade.grade-b,
.lesson-history-mobile-grade.grade-b {
  color: #fdba74; /* orange-300 */
}

.col-grade.grade-c,
.lesson-history-mobile-grade.grade-c {
  color: #86efac; /* green-300 */
}

.col-grade.grade-d,
.lesson-history-mobile-grade.grade-d {
  color: #93c5fd; /* blue-300 */
}

.col-grade.grade-e,
.lesson-history-mobile-grade.grade-e {
  color: #fca5a5; /* red-300 */
}

/* === モバイル用コンパクトカード === */
.lesson-history-mobile {
  display: none;
}

.lesson-history-mobile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.2s ease;
}

.lesson-history-mobile-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.lesson-history-mobile-item:last-child {
  border-bottom: none;
}

.lesson-history-mobile-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lesson-history-mobile-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.9);
}

.lesson-history-mobile-meta {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

.lesson-history-mobile-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lesson-history-mobile-grade {
  font-weight: 700;
  font-size: 1.25rem;
}

.lesson-history-mobile-error {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  text-align: right;
}

/* レスポンシブ（PC/モバイル切り替え） */
@media (max-width: 768px) {
  .lesson-history-table-container table {
    display: none;
  }
  .lesson-history-mobile {
    display: block;
  }
}

/* ================================================================
   トレーニング履歴ヘッダー（モバイル対応）
   ================================================================ */

/* モバイルでヘッダーを上下配置 */
@media (max-width: 480px) {
  #sessions-content > .flex.items-center.justify-between.mb-4 {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #sessions-content > .flex.items-center.justify-between.mb-4 > .flex.items-center.gap-3 {
    width: 100%;
    justify-content: space-between;
  }
}
