/**
 * training-log.css — 주간 달력 형태의 활동 로그 스타일
 *
 * 의존: styles.css의 CSS 변수(--color-*, --space-*, --font-* 등)
 * 클래스 접두사: tl- (Training Log)
 */

/* ──────────────────────────────────────────────
   1. 페이지 타이틀 (training-calendar.css와 동일 수치)
   ────────────────────────────────────────────── */
.tl-page-header {
  padding: var(--space-6) var(--space-6) var(--space-4);
}

.tl-title {
  font-size: 28px;   /* --text-display 기준, tc-title과 동일 */
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.tl-subtitle {
  font-size: var(--font-small);
  color: var(--color-text-tertiary);
  margin: 2px 0 0 0;
  font-weight: 400;
}

/* ──────────────────────────────────────────────
   2. 필터바
   ────────────────────────────────────────────── */
.tl-filter-bar {
  position: sticky;
  top: var(--header-h);
  left: 0;
  right: 0;
  height: 52px;   /* 기존 48px → 52px: Maps 필터바와 높이 통일 */
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tl-filter-bar::-webkit-scrollbar { display: none; }

/* 연도 드롭다운 — border-radius:0 (프로젝트 디자인 시스템 준수, 직선 처리) */
.tl-year-select {
  padding: 4px 28px 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 0;                         /* 직선 처리 — 라운드 금지 */
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  cursor: pointer;
  appearance: none;
  /* 화살표 아이콘 인라인 SVG */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%236B6B76'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  white-space: nowrap;
  flex-shrink: 0;
}
.tl-year-select:focus { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* 버블 크기 기준 드롭다운 — tl-year-select와 동일 패턴 (P2) */
.tl-metric-select {
  padding: 4px 28px 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%236B6B76'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  white-space: nowrap;
  flex-shrink: 0;
}
.tl-metric-select:focus { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* 구분선 */
.tl-filter-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* 종목 토글 그룹 */
.tl-sport-group {
  display: flex;
  gap: 6px;              /* 기존 0 → 6px: Maps .maps-filter-group과 통일 (gap:0이면 이중 보더 발생) */
  flex-shrink: 0;
}

/* ※ 종목 토글 버튼 스타일은 styles.css의 .sport-filter-btn(SSOT)에서 상속.
      이 파일에서는 중복 정의하지 않는다. (border-radius 오염 원천 차단) */

/* 요약 텍스트 */
.tl-summary {
  margin-left: auto;
  font-size: 11px;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────
   2. 요일 헤더 (이중 sticky)
   ────────────────────────────────────────────── */
.tl-header-row {
  position: sticky;
  top: calc(var(--header-h) + 52px);  /* 헤더 + 필터바(52px) — 필터바 높이 변경에 따라 동기화 */
  z-index: 40;
  display: grid;
  grid-template-columns: 120px repeat(7, 1fr);
  background: var(--color-surface-alt);
  border-bottom: 2px solid var(--color-border);
  min-width: 640px;
}

.tl-week-col-hdr,
.tl-day-hdr {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}
.tl-week-col-hdr { text-align: left; }

/* ──────────────────────────────────────────────
   3. 주간 그리드 컨테이너
   ────────────────────────────────────────────── */
.tl-container {
  min-width: 640px;
}

/* 주(Week) 행 */
.tl-week-row {
  display: grid;
  grid-template-columns: 120px repeat(7, 1fr);
  border-bottom: 1px solid var(--color-border-light);
  min-height: 88px;
  transition: background 0.1s;
}
.tl-week-row:hover { background: var(--color-surface-hover); }

/* ──────────────────────────────────────────────
   4. 주 요약 셀 (왼쪽 열)
   ────────────────────────────────────────────── */
.tl-week-summary {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--color-border-light);
}

.tl-week-range {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.tl-week-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.tl-week-km {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.tl-week-tss {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  margin-top: 2px;
}

/* P3: "Total Time" 레이블 — 주 요약 좌측 열 */
.tl-week-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--color-text-disabled);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
  line-height: 1;
}

/* ──────────────────────────────────────────────
   5. 날짜 셀
   ────────────────────────────────────────────── */
.tl-day-cell {
  padding: 6px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-right: 1px solid var(--color-border-light);
  min-width: 0;
  position: relative;
  transition: background 0.1s;
}
.tl-day-cell:last-child { border-right: none; }

/* 날짜 숫자 */
.tl-day-num {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-tertiary);
  align-self: flex-start;
  line-height: 1;
}

/* 오늘 강조 */
.tl-day-cell.is-today {
  background: var(--color-primary-light, #FFF0E8);
}
.tl-day-cell.is-today .tl-day-num {
  color: var(--color-primary);
  font-weight: 700;
}

/* TODAY 뱃지 (P4) — 날짜 숫자 우측에 인라인 표시 */
.tl-today-badge {
  font-size: 8px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.05em;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
}

/* Rest 텍스트 */
.tl-rest {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-disabled);
  margin-top: 4px;
  letter-spacing: 0.02em;
  display: none;
}

/* ──────────────────────────────────────────────
   6. 활동 버블
   ────────────────────────────────────────────── */
/* 버블 wrapper: 버블 + 거리 텍스트를 세로로 묶음 */
.tl-bubbles-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.tl-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;   /* tl-bubble-title의 max-width:100% 계산 기준 */
}

/* 버블 본체 (원형, 색상은 JS에서 인라인 스타일로 주입) */
.tl-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
  font-family: var(--font-primary);
  cursor: pointer;
  /* 부드러운 hover 전환 */
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.tl-bubble:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-2);
  filter: brightness(1.08);
}
/* 클릭 피드백 */
.tl-bubble:active { transform: scale(0.97); }

/* 버블 내부: 종목 아이콘 */
.tl-bubble-icon {
  opacity: 0.90;
  display: block;
  flex-shrink: 0;
}

/* 버블 내부: 시간 텍스트 */
.tl-bubble-time {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  letter-spacing: -0.01em;
}

/* 버블 아래: 거리 텍스트 */
.tl-bubble-dist {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* 버블 아래: 활동 제목 — 셀 너비 초과 시 ellipsis 처리 (P1) */
.tl-bubble-title {
  font-size: 10px;
  font-weight: 400;
  color: var(--color-text-tertiary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  line-height: 1.2;
}

/* ──────────────────────────────────────────────
   7. 로딩 오버레이
   ────────────────────────────────────────────── */
.tl-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  gap: 16px;
}

.tl-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.tl-loading-text {
  font-size: 13px;
  color: var(--color-text-tertiary);
}

/* ──────────────────────────────────────────────
   8. 빈 상태
   ────────────────────────────────────────────── */
.tl-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 14px;
}
.tl-empty.hidden { display: none; }

.tl-empty-sub {
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-top: 6px;
}

/* ──────────────────────────────────────────────
   9. 반응형 (모바일 — 가로 스크롤)
   ────────────────────────────────────────────── */

/* 스크롤 래퍼: 데스크탑에서는 투명 래퍼 */
.tl-scroll-wrapper {
  position: relative;
}

@media (max-width: 1023px) {
  .tl-header-row,
  .tl-week-row {
    grid-template-columns: 100px repeat(7, 1fr);
    min-width: 600px;
  }
}

@media (max-width: 767px) {
  /* ── 필터바: 줄바꿈 허용 + 컴팩트 패딩 ── */
  .tl-filter-bar {
    height: auto;
    padding: 8px var(--space-3);
    gap: 6px;
    flex-wrap: wrap;
    overflow-x: visible;
  }
  .tl-sport-group {
    flex-shrink: 1;
    flex-wrap: wrap;
    gap: 4px;
  }
  .tl-filter-divider {
    display: none;
  }

  /* ── 스크롤 래퍼: 헤더+본문 동기 가로 스크롤 ── */
  .tl-scroll-wrapper {
    overflow-x: auto;                /* 하나의 래퍼로 동기 스크롤 */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;           /* Firefox: 얇은 스크롤바 */
  }
  .tl-scroll-wrapper::-webkit-scrollbar {
    height: 4px;                     /* 얇은 가로 스크롤바 */
  }
  .tl-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: 2px;
  }
  .tl-scroll-wrapper::-webkit-scrollbar-track {
    background: transparent;
  }

  /* 헤더/본문 개별 overflow 제거 (래퍼가 담당) */
  .tl-header-row,
  .tl-container {
    overflow-x: visible;
  }

  /* ── 그리드 축소: 모바일 너비에 맞춤 ── */
  .tl-header-row,
  .tl-container {
    min-width: 0;
  }
  .tl-header-row {
    position: relative;   /* 모바일: 필터바 높이가 가변이므로 sticky 해제 */
    top: auto;
  }
  .tl-header-row,
  .tl-week-row {
    grid-template-columns: 72px repeat(7, 1fr);
    min-width: 0;
  }

  /* ── 주간 요약 컴팩트 ── */
  .tl-week-summary {
    padding: 6px 4px;
  }
  .tl-week-time { font-size: 11px; }
  .tl-week-range { font-size: 9px; }
  .tl-week-km { font-size: 9px; }

  /* ── 페이지 타이틀 컴팩트 ── */
  .tl-page-header {
    padding: var(--space-4) var(--space-3) var(--space-3);
  }
  .tl-title {
    font-size: 22px;
  }
}
