/* ==========================================================
   training-calendar.css — Training Calendar 전용 스타일
   Strava Training Calendar 참조, 기존 디자인 시스템(styles.css) 준수
   ========================================================== */

/* ===== 페이지 헤더: 타이틀 + 년도 네비게이션 ===== */
.tc-page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.tc-title {
  font-size: 28px;   /* --font-display는 font-family 스택이므로 직접 픽셀 지정 (디자인 시스템 --text-display 기준) */
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

/* 년도 네비게이션 (◁ 2026 ▷) */
.tc-year-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.tc-year-label {
  font-size: var(--font-heading);
  font-weight: 700;
  color: var(--color-text-primary);
  min-width: 60px;
  text-align: center;
}

/* 년도 이동 버튼 */
.tc-year-btn {
  background: none;
  border: 1px solid var(--color-border);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.tc-year-btn:hover {
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
  background: var(--color-surface-hover);
}

/* ===== 요약 바: 주간 프로그레스 + 연간 통계 ===== */
.tc-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

/* 52주 프로그레스 바 */
.tc-week-progress-wrap {
  flex: 1;
  min-width: 200px;
}

.tc-week-progress {
  position: relative;
  height: 24px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}

/* 프로그레스 채움 바 */
.tc-week-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--color-primary);
  transition: width 0.6s ease;
}

/* 프로그레스 바 위의 현재 주 마커 */
.tc-week-marker {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--color-text-primary);
  transition: left 0.6s ease;
}

.tc-week-label {
  font-size: var(--font-caption);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
  text-align: right;
}

/* 연간 요약 통계 (4개 카드) */
.tc-year-stats {
  display: flex;
  align-items: center;
  gap: 0;
}

.tc-stat {
  text-align: center;
  padding: 0 var(--space-5);
}

/* 통계 값 (큰 숫자) */
.tc-stat-value {
  font-size: var(--font-heading);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

/* 통계 라벨 */
.tc-stat-label {
  font-size: var(--font-micro);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* 통계 구분선 */
.tc-stat-divider {
  width: 1px;
  height: 36px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* PR 등 값이 0일 때 중립 색상 */
.tc-stat-zero {
  color: var(--color-text-tertiary) !important;
}

/* ===== 12개월 그리드 (4열 × 3행) ===== */
.tc-month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

/* 개별 월 카드 */
.tc-month-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  padding: var(--space-4);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tc-month-card:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

/* 빈 달 카드: 클릭 불가 스타일 */
.tc-month-card:not(.has-activity) {
  cursor: default;
}

/* 활동이 있는 월 카드: 파란/프라이머리 강조 배경 */
.tc-month-card.has-activity {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.tc-month-card.has-activity:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

/* 현재 월 표시 */
.tc-month-card.is-current {
  border-color: var(--color-primary);
  border-width: 2px;
}

/* 월 이름 (우측 상단) */
.tc-month-name {
  font-size: var(--font-body);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: right;
  text-transform: uppercase;
}

.tc-month-card.has-activity .tc-month-name {
  color: rgba(255, 255, 255, 0.85);
}

/* 빈 달 "No activity" 텍스트 */
.tc-month-no-activity {
  font-size: var(--font-caption);
  color: var(--color-text-tertiary);
  margin: auto 0;
  padding: var(--space-2) 0;
}

/* 월별 시간 표시 */
.tc-month-hours {
  margin-top: var(--space-2);
}

.tc-month-hours-value {
  font-size: var(--font-heading);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.tc-month-hours-label {
  font-size: var(--font-micro);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tc-month-card.has-activity .tc-month-hours-value {
  color: #fff;
}

.tc-month-card.has-activity .tc-month-hours-label {
  color: rgba(255, 255, 255, 0.85);
}

/* 주별 바 차트 (월 카드 하단) */
.tc-month-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 40px;
  margin-top: auto;
  padding-top: var(--space-2);
}

/* 개별 바 */
.tc-bar {
  flex: 1;
  min-width: 4px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 1px 1px 0 0;
  transition: height 0.4s ease;
}

.tc-month-card.has-activity .tc-bar {
  background: rgba(0, 0, 0, 0.25);
}

/* 활동이 있는 바 강조 */
.tc-bar.has-data {
  background: var(--color-text-primary);
}

.tc-month-card.has-activity .tc-bar.has-data {
  background: rgba(255, 255, 255, 0.8);
}

/* ===== TSS 차트 섹션 (카드) ===== */
.tc-tss-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  padding: var(--space-5);
  margin-bottom: var(--space-8);
}

.tc-tss-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.tc-tss-title {
  font-size: var(--font-title);
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

/* Weekly/Monthly 토글 */
.tc-tss-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.tc-tss-toggle-btn {
  padding: 6px 16px;
  font-size: var(--font-caption);
  font-weight: 500;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tc-tss-toggle-btn:hover {
  background: var(--color-surface-hover);
}

.tc-tss-toggle-btn.active {
  background: var(--color-primary);
  color: #fff;
}

/* 차트 컨테이너 (카드 내부이므로 border 제거) */
.tc-tss-chart-wrap {
  position: relative;
  height: 300px;
}

/* ===== 최근 활동 섹션 ===== */
.tc-recent-section {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-6);
  margin-top: var(--space-6);
}

.tc-recent-title {
  font-size: var(--font-title);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

.tc-recent-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* 최근 활동 아이템 */
.tc-recent-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-light);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  color: inherit;
}

.tc-recent-item:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-hover);
}

/* 활동 아이콘 (사이클링) */
.tc-recent-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--color-primary);
}

/* 활동 날짜 */
.tc-recent-date {
  font-size: var(--font-body);
  color: var(--color-text-secondary);
  min-width: 90px;
}

/* 활동 제목 */
.tc-recent-name {
  font-size: var(--font-body);
  font-weight: 500;
  color: var(--color-text-primary);
}

/* 활동 통계 (거리, 시간) */
.tc-recent-stats {
  margin-left: auto;
  font-size: var(--font-caption);
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

/* "View all" 링크 */
.tc-recent-view-all {
  margin-top: var(--space-4);
  text-align: right;
}

.tc-recent-view-all a {
  font-size: var(--font-caption);
  font-weight: 500;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.tc-recent-view-all a:hover {
  text-decoration: underline;
}

/* ===== 빈 상태 ===== */
.tc-empty-state {
  text-align: center;
  padding: var(--space-10) 0;
  color: var(--color-text-tertiary);
}

.tc-empty-state svg {
  margin-bottom: var(--space-4);
}

.tc-empty-title {
  font-size: var(--font-title);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.tc-empty-desc {
  font-size: var(--font-body);
  color: var(--color-text-tertiary);
}

/* ===== 로딩 상태 ===== */
.tc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) 0;
  gap: var(--space-3);
  color: var(--color-text-tertiary);
  font-size: var(--font-body);
}

/* ===== 월 클릭 시 활동 목록 오버레이 (드릴다운) ===== */
.tc-month-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.tc-month-detail-overlay.active {
  opacity: 1;
  visibility: visible;
}

.tc-month-detail-modal {
  background: var(--color-surface);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-3);
}

.tc-month-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

.tc-month-detail-title {
  font-size: var(--font-title);
  font-weight: 700;
  color: var(--color-text-primary);
}

.tc-month-detail-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-tertiary);
  padding: var(--space-1);
  transition: color var(--transition-fast);
}

.tc-month-detail-close:hover {
  color: var(--color-text-primary);
}

/* 월 상세 통계 요약 */
.tc-month-detail-stats {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border-light);
}

.tc-month-detail-stat {
  text-align: center;
  flex: 1;
}

.tc-month-detail-stat-value {
  font-size: var(--font-title);
  font-weight: 700;
  color: var(--color-primary);
}

.tc-month-detail-stat-label {
  font-size: var(--font-micro);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
}

/* 월 상세 리포트 (주차별 추이 + 스포츠 분포 + 코칭) */
.tc-month-detail-report { padding: 0 var(--space-6) var(--space-4); }
.tc-mdr-table        { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 10px; }
.tc-mdr-table th,
.tc-mdr-table td     { padding: 5px 8px; border-bottom: 1px solid var(--color-border-light, #f0f0f0); text-align: left; }
.tc-mdr-table th     { font-weight: 600; color: var(--color-text-secondary); font-size: 11px; }
.tc-mdr-coach        { padding: 8px 10px; font-size: 12px; line-height: 1.6; background: var(--color-bg-secondary, #f8f8fa); margin-bottom: 10px; }
.tc-mdr-good         { color: #43A047; font-weight: 600; }
.tc-mdr-warn         { color: #e84040; font-weight: 600; }

/* 월 상세 활동 리스트 */
.tc-month-detail-list {
  padding: var(--space-4) var(--space-6);
}

.tc-month-detail-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition-fast);
}

.tc-month-detail-item:last-child {
  border-bottom: none;
}

.tc-month-detail-item:hover {
  background: var(--color-surface-hover);
  margin: 0 calc(-1 * var(--space-3));
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

.tc-month-detail-item-date {
  font-size: var(--font-caption);
  color: var(--color-text-tertiary);
  min-width: 80px;
}

.tc-month-detail-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-body);
  font-weight: 500;
  color: var(--color-text-primary);
  flex: 1;
  min-width: 0;          /* flex child 텍스트 말줄임 허용 */
}

.tc-detail-sport-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0.9;
}

.tc-detail-sport-icon svg {
  display: block;
}

.tc-month-detail-item-stats {
  font-size: var(--font-caption);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* 월 상세 빈 상태 */
.tc-month-detail-empty {
  text-align: center;
  padding: var(--space-8) var(--space-6);
  color: var(--color-text-tertiary);
  font-size: var(--font-body);
}

/* ===== 반응형 ===== */

/* 태블릿 (768px 이하) */
@media (max-width: 768px) {
  .tc-month-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .tc-summary-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .tc-year-stats {
    justify-content: center;
  }

  .tc-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .tc-year-nav {
    align-self: flex-start;
  }

  .tc-tss-chart-wrap {
    height: 240px;
  }

  .tc-tss-section {
    padding: var(--space-4);
  }
}

/* 모바일 (480px 이하) */
@media (max-width: 480px) {
  .tc-month-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tc-year-stats {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .tc-stat {
    padding: 0 var(--space-3);
  }

  .tc-stat-divider {
    display: none;
  }

  .tc-month-card {
    min-height: 120px;
  }

  .tc-recent-stats {
    display: none;
  }

  .tc-tss-chart-wrap {
    height: 200px;
  }

  .tc-tss-section {
    padding: var(--space-3);
  }

  .tc-tss-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
}

/* ── 소형 모바일 (375px 이하) ── */
@media (max-width: 375px) {
  .tc-month-card {
    min-height: 100px;
  }
  .tc-tss-chart-wrap {
    height: 180px;
  }
  .tc-stat {
    padding: 0 var(--space-2);
  }
}

/* ══════════════════════════════════════════════════
   인사이트 배너 — 문장형 요약 카드
   ══════════════════════════════════════════════════ */
.tc-insight-banner {
  background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-surface-warm, #fff8f3) 100%);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tc-insight-banner p {
  margin: 0;
  font-size: var(--font-body);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.tc-insight-banner p + p {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
}

.tc-insight-banner strong {
  color: var(--color-text-primary);
}

/* ══════════════════════════════════════════════════
   부제목
   ══════════════════════════════════════════════════ */
.tc-subtitle {
  font-size: var(--font-small);
  color: var(--color-text-tertiary);
  margin: 2px 0 0 0;
  font-weight: 400;
}

/* ══════════════════════════════════════════════════
   Year Progress 레이블 행
   ══════════════════════════════════════════════════ */
.tc-week-progress-label-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}

.tc-week-progress-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}

/* ══════════════════════════════════════════════════
   TSS 타이틀 행 (타이틀 + ⓘ 버튼)
   ══════════════════════════════════════════════════ */
.tc-tss-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ══════════════════════════════════════════════════
   ⓘ 정보 버튼
   ══════════════════════════════════════════════════ */
.tc-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--color-text-tertiary);
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  vertical-align: middle;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.tc-info-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(232, 69, 10, 0.06);
}

/* ── 통계 레이블 내부 버튼 정렬 ── */
.tc-stat-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ══════════════════════════════════════════════════
   지표 설명 모달
   ══════════════════════════════════════════════════ */
.tc-info-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: var(--space-4);
}

.tc-info-modal-overlay.active {
  display: flex;
}

.tc-info-modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  animation: tcModalIn 0.2s ease;
}

@keyframes tcModalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.tc-info-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.tc-info-modal-title {
  font-size: var(--font-heading);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.tc-info-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.tc-info-modal-close:hover {
  background: var(--color-hover);
}

.tc-info-modal-body {
  padding: var(--space-4) var(--space-5) var(--space-5);
  font-size: var(--font-body);
  color: var(--color-text-secondary);
  line-height: 1.7;
}

.tc-info-modal-body p {
  margin: 0 0 var(--space-3);
}

.tc-info-modal-body p:last-child {
  margin-bottom: 0;
}

.tc-info-modal-body ul {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
}

.tc-info-modal-body li {
  margin-bottom: var(--space-1);
}

.tc-info-modal-body strong {
  color: var(--color-text-primary);
  font-weight: 600;
}

.tc-info-tip {
  background: rgba(232, 69, 10, 0.06);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-3) var(--space-4) !important;
  font-size: var(--font-small) !important;
  color: var(--color-text-secondary);
}

@media (max-width: 480px) {
  .tc-info-modal {
    max-height: 90vh;
  }
  .tc-insight-banner {
    padding: var(--space-3) var(--space-4);
  }
}
