/* ============================================================
   Timeline - Calendar + Daily Feed
   ============================================================ */

/* Filter row */
.timeline-filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
/* .tab-bar의 기본 위·아래 마진(var(--space-4))을 제거 — 리포트 탭과 동일한
   시작 높이로 맞추기 위함. 캘린더와의 간격은 부모(.timeline-filter-row)의
   margin-bottom이 담당. */
.timeline-filter-row .tab-bar { margin: 0; }

.manager-select {
  height: 36px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.manager-select:focus {
  outline: none;
  border-color: var(--ad-primary);
}

/* 2-column layout: calendar + feed */
.timeline-2col {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: var(--space-4);
  align-items: start;
}

/* === Calendar === */
.tl-calendar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  /* 7×6 날짜 grid가 들어가는 특수 영역이라 다른 카드(16px)보다 한 단계 큰 padding 유지 */
  padding: var(--space-5);
  position: sticky;
  top: 80px;
}

.tl-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.tl-cal-title {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tl-cal-nav {
  display: flex;
  gap: var(--space-1);
}

.tl-cal-nav button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 8px;
  cursor: pointer;
  font-size: var(--text-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-family: inherit;
}

.tl-cal-nav button:hover { background: var(--bg-subtle); border-color: var(--text-muted); }
.tl-cal-nav button:focus-visible { outline: none; border-color: var(--ad-primary); box-shadow: var(--focus-ring); }

.tl-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.tl-cal-dow {
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  padding: var(--space-1) 0 var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tl-cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
  gap: 2px;
}

.tl-cal-day:hover { background: var(--bg-subtle); }
.tl-cal-day.other-month { color: var(--border); cursor: default; }
.tl-cal-day.other-month:hover { background: transparent; }
.tl-cal-day.today { font-weight: 800; color: var(--ad-primary); }

.tl-cal-day.selected {
  background: var(--ad-primary);
  color: white;
  font-weight: 800;
}

.tl-cal-day.selected .tl-cal-dot { background: white; }

.tl-cal-day.has-alert::after {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--danger);
  position: absolute;
  bottom: var(--space-1);
}

.tl-cal-day.selected.has-alert::after { background: white; }

/* === Daily Feed === */
.tl-feed {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.tl-feed-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tl-feed-title {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tl-feed-count {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

.tl-feed-list {
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* Timeline 표 — 컬럼: 시간 / 아이콘 / 근로자(+매니저) / 사유·위치 / 상태(+처리자)
   stg-data-row와 같은 톤(세로선 + 가운데 정렬)이지만 timeline 전용 grid-template. */
.tl-table-cols {
  display: grid;
  grid-template-columns: 90px 64px 1fr 1fr 1.3fr 1fr 100px 90px;
  align-items: stretch;
  gap: 0;
}
/* 근로자/담당/사유/처리자 컬럼은 좌측 정렬(긴 정보가 자연스럽게 흐르도록).
   시간/아이콘/처리일시/상태는 짧으니 가운데 유지. */
.tl-table-cols > .tl-col-worker,
.tl-table-cols > .tl-col-manager,
.tl-table-cols > .tl-col-detail,
.tl-table-cols > .tl-col-actor {
  justify-content: flex-start;
  text-align: left;
  padding-left: var(--space-3);
}
.tl-table-cols > * {
  border-right: 1px solid var(--border);
  padding: 0 var(--space-2);
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
  font-size: var(--text-base);
  white-space: nowrap;
}
.tl-table-cols > *:last-child { border-right: none; padding-right: var(--space-4); }
/* 아이콘 컬럼(2번째) — 셀 폭 64px, 좌우 padding 16px씩 → dot 32x32 가운데.
   시간 셀과의 좌측 보더 유지, 우측 보더 제거. */
.tl-table-cols > *:nth-child(2) {
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  border-right: none;
  justify-content: center;
}

.tl-table-header {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Timeline item */
.timeline-item {
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
}

.timeline-item:last-child { border-bottom: none; }
.timeline-item:hover { background: var(--bg-subtle); }

.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  flex-shrink: 0;
}

.timeline-dot.danger { background: var(--danger-bg); color: var(--danger); }
.timeline-dot.caution { background: var(--caution-bg); color: var(--caution); }
.timeline-dot.info { background: var(--info-light); color: var(--info); }
.timeline-dot.success { background: var(--success-light); color: var(--success); }

.timeline-time { font-size: var(--text-sm); color: var(--text-secondary); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 한 줄 표시 — 모든 셀이 한 줄에 inline */
.tl-col-worker, .tl-col-manager, .tl-col-detail, .tl-col-status { gap: var(--space-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--text-base); }
.tl-col-worker .tl-name { font-weight: 700; }
.tl-col-manager { color: var(--text-secondary); font-weight: 500; }
.tl-col-detail .tl-reason { color: var(--text); font-weight: 600; }
.tl-col-detail .tl-zone-line { color: var(--text-secondary); font-weight: 500; }
.tl-col-status .tl-actor { color: var(--text-secondary); font-weight: 600; }

/* .tl-manager → .tag .tag--micro .tag--admin로 마이그레이션됨 (components.css 참조). */

/* .pending-badge/.resolved-badge → .tag .tag--label로 마이그레이션됨 (components.css 참조). */

/* Clock-in items */
.timeline-item.clock-in { opacity: 0.6; cursor: default; }
.timeline-item.clock-in:hover { background: transparent; }

/* Load more */
.tl-load-more {
  padding: var(--space-3) var(--space-5);
  text-align: center;
}

.tl-load-more button {
  padding: var(--space-2) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-family: inherit;
}

.tl-load-more button:hover { background: var(--bg-subtle); }
.tl-load-more button:focus-visible { outline: none; border-color: var(--ad-primary); box-shadow: var(--focus-ring); }

.timeline-empty {
  text-align: center;
  padding: 60px var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-base);
}
/* 인라인 스타일 클래스화 (시각 변화 없음). .timeline-empty i는 (0,1,1)로
   늦게 로드되는 bootstrap-icons .bi(0,1,0)를 이기도록 컨텍스트 셀렉터 사용. */
.timeline-empty i { font-size: 24px; display: block; margin-bottom: 8px; }
.timeline-dot--center { margin: 0 auto; }

/* === Responsive — 태블릿 이하에서 캘린더 위 / 피드 아래로 === */
@media (max-width: 1024px) {
  .timeline-2col { grid-template-columns: 1fr; }
  .tl-calendar { position: static; }
}
