/* ============================================================
   N-Trip · 일정 타임라인 화면 (premium variant A)
   디자인 핸드오프: timeline.jsx + timeline.css 기반
   ============================================================ */

/* 토큰 보강 — base.css에 이미 있는 것은 재정의하지 않음 */
:root {
  --tl-bg-0: var(--bg);
  --tl-text:   hsl(0 0% 98%);
  --tl-text-2: hsl(0 0% 72%);
  --tl-text-3: hsl(0 0% 52%);
  --tl-border:        rgba(255, 255, 255, 0.10);
  --tl-border-strong: rgba(255, 255, 255, 0.18);
  --shadow-glow: 0 0 32px var(--primary-glow);

  /* '명소'는 기본 카테고리이므로 테마를 따라감, 나머지는 의미 색상 고정 */
  --cat-attraction: var(--primary);
  --cat-food:       hsl(28 95% 62%);
  --cat-stay:       hsl(265 85% 70%);
  --cat-cafe:       hsl(40 90% 60%);
  --cat-shop:       hsl(200 90% 65%);
  --cat-transport:  hsl(0 0% 70%);
}

/* ============================================================
   #detail-screen 전체 컨테이너 — 풀블리드 레이아웃
   .screen이 position:absolute; height:100% 라 자체 세로 스크롤 필요.
   ============================================================ */
#detail-screen.tl-screen {
  display: block;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
#detail-screen.tl-screen .detail-body { display: none; } /* 구버전 레이아웃 비활성 */

/* Top bar */
.tl-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(to bottom, var(--bg) 60%, transparent);
  backdrop-filter: blur(14px);
}
.tl-topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tl-icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--tl-border);
  border-radius: var(--r-md); color: var(--text-primary);
  cursor: pointer; transition: all .2s;
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}
.tl-icon-btn:hover { background: var(--surface-2); border-color: var(--tl-border-strong); }
.tl-icon-btn i { font-size: 20px; }

.tl-topbar-title { min-width: 0; }
.tl-trip-title {
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 360px;
}
.tl-trip-subtitle { font-size: 13px; color: var(--tl-text-3); margin-top: 2px; }

.tl-topbar-right { display: flex; gap: 8px; }

.tl-export-wrap { position: relative; }
.tl-export-dropdown {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 220px;
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 8px;
  z-index: 3000;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
}
.tl-export-dropdown.show { display: block; }
.tl-export-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: transparent; border: none;
  color: var(--text-primary); font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: left; transition: background 0.2s;
}
.tl-export-item:hover { background: rgba(255, 255, 255, 0.07); }
.tl-export-item i { font-size: 20px; }

/* ============================================================
   Day rail (가로 스크롤 날짜)
   ============================================================ */
.tl-day-rail {
  display: flex; gap: 10px;
  padding: 8px 28px 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tl-day-rail::-webkit-scrollbar { display: none; }
.tl-day-pill {
  flex-shrink: 0;
  min-width: 92px;
  padding: 12px 18px;
  background: var(--surface); border: 1px solid var(--tl-border);
  border-radius: var(--r-md);
  cursor: pointer; transition: all .25s;
  text-align: left;
  color: var(--text-primary);
  font-family: inherit;
}
.tl-day-pill:hover { background: var(--surface-2); transform: translateY(-2px); }
.tl-day-pill.active {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  box-shadow: var(--shadow-glow);
}
.tl-day-pill-date {
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em;
  font-family: 'Outfit', 'Pretendard', sans-serif;
}
.tl-day-pill-label {
  font-size: 11px; color: var(--tl-text-3);
  margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.tl-day-pill.active .tl-day-pill-label { color: var(--primary); }

/* ============================================================
   Main grid: 좌측 타임라인 / 우측 요약
   ============================================================ */
.tl-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 28px 80px;
}
@media (max-width: 900px) {
  .tl-main { grid-template-columns: 1fr; }
  .tl-summary { order: -1; position: static !important; }
}

/* ============================================================
   타임라인 헤더 (Day 정보 + 액션)
   ============================================================ */
.tl-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--tl-border);
  flex-wrap: wrap; gap: 16px;
}
.tl-head-info h2 {
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 12px;
  color: var(--text-primary);
  margin: 0;
}
.tl-head-icon {
  width: 36px; height: 36px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 10px; display: grid; place-items: center;
}
.tl-head-icon i { font-size: 20px; }
.tl-head-meta { font-size: 13px; color: var(--tl-text-2); margin-top: 6px; }

.tl-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tl-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--tl-border);
  border-radius: 999px; color: var(--text-primary);
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .2s;
  font-family: inherit;
}
.tl-btn:hover { background: var(--surface-2); border-color: var(--tl-border-strong); }
.tl-btn i { font-size: 14px; }
.tl-btn.primary {
  background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary);
}
.tl-btn.primary:hover { background: hsl(var(--pc-h) var(--pc-s) 60% / 0.24); }

/* 타임라인/지도 탭 토글 (헤더 좌측 위) */
.tl-view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--tl-border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 16px;
}
.tl-view-toggle button {
  padding: 6px 14px;
  background: transparent; border: none;
  color: var(--tl-text-3);
  font-size: 12px; font-weight: 600;
  cursor: pointer; border-radius: 999px;
  font-family: inherit; transition: all .2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.tl-view-toggle button i { font-size: 14px; }
.tl-view-toggle button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ============================================================
   타임라인 카드 (.tcard)
   ============================================================ */
.tl-list { position: relative; }

.tl-list::before {
  content: '';
  position: absolute;
  left: 27px; top: 8px; bottom: 8px;
  width: 2px;
  background: repeating-linear-gradient(
    to bottom,
    var(--primary-line) 0 6px,
    transparent 6px 12px
  );
  opacity: 0.5;
}

.tcard {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  margin-bottom: 14px;
}
.tcard:last-child { margin-bottom: 0; }

.tcard-orb {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), hsl(calc(var(--pc-h) + 20) var(--pc-s) 55%));
  color: var(--bg);
  font-size: 22px; font-weight: 800;
  display: grid; place-items: center;
  box-shadow: 0 0 0 4px var(--bg), 0 0 20px var(--primary-glow);
  z-index: 2;
  font-family: 'Outfit', sans-serif;
}

.tcard-body {
  background: var(--surface);
  border: 1px solid var(--tl-border);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  backdrop-filter: blur(16px);
  transition: all .25s;
}
.tcard:hover .tcard-body {
  background: var(--surface-2);
  border-color: var(--tl-border-strong);
  border-left-color: var(--primary);
  transform: translateX(2px);
}

.tcard-meta {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.cat-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: var(--cat-bg, var(--surface-2));
  color: var(--cat-color, var(--tl-text-2));
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
}
.cat-chip i { font-size: 12px; }
.cat-chip.attraction { --cat-bg: var(--primary-soft); --cat-color: var(--primary); }
.cat-chip.food       { --cat-bg: hsl(28 95% 62% / 0.15);  --cat-color: var(--cat-food); }
.cat-chip.stay       { --cat-bg: hsl(265 85% 70% / 0.15); --cat-color: var(--cat-stay); }
.cat-chip.cafe       { --cat-bg: hsl(40 90% 60% / 0.15);  --cat-color: var(--cat-cafe); }
.cat-chip.shop       { --cat-bg: hsl(200 90% 65% / 0.15); --cat-color: var(--cat-shop); }

.time-chip {
  font-family: 'Outfit', monospace;
  font-size: 12px; font-weight: 600;
  color: var(--tl-text-2);
  letter-spacing: 0.04em;
}
.duration-chip {
  font-size: 11px; color: var(--tl-text-3);
  padding: 3px 8px;
  background: var(--surface-2);
  border-radius: 6px;
}

.tcard-title {
  font-size: 17px; font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--text-primary);
}
.tcard-addr {
  font-size: 13px; color: var(--tl-text-2);
  display: flex; align-items: center; gap: 6px;
}
.tcard-addr i { font-size: 14px; opacity: 0.6; flex-shrink: 0; }

.tcard-memo {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.025);
  border: 1px dashed var(--tl-border);
  border-radius: var(--r-sm);
  font-size: 13px; color: var(--tl-text-2); line-height: 1.5;
}

.tcard-photos {
  display: flex; gap: 6px; margin-top: 12px;
}
.photo-thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-2);
  border: 1px solid var(--tl-border);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}
.photo-thumb.add {
  background: var(--surface);
  border: 1px dashed var(--tl-border-strong);
  display: grid; place-items: center;
  color: var(--tl-text-3);
}
.photo-thumb.add:hover { color: var(--primary); border-color: var(--primary-line); }
.photo-thumb.add i { font-size: 18px; }
.photo-thumb-more {
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text-primary);
  background: rgba(0,0,0,0.55);
}

.tcard-actions {
  display: flex; gap: 6px; align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--tl-border);
  flex-wrap: wrap;
}
.tcard-action {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px;
  font-size: 12px; color: var(--tl-text-2);
  background: transparent; border: none;
  cursor: pointer; border-radius: 8px;
  font-family: inherit;
  transition: all .15s;
}
.tcard-action:hover { background: var(--surface-2); color: var(--text-primary); }
.tcard-action i { font-size: 14px; }
.tcard-action.danger { margin-left: auto; }
.tcard-action.danger:hover { color: hsl(0 80% 65%); background: hsl(0 80% 65% / 0.1); }
.tcard-action[disabled] { opacity: 0.3; cursor: not-allowed; }

/* ============================================================
   장소 간 이동 표시 (.travel-leg)
   ============================================================ */
.travel-leg {
  position: relative;
  margin: -2px 0 12px 56px;
  padding: 8px 16px;
  display: flex; align-items: center; gap: 14px;
  font-size: 12px; color: var(--tl-text-3);
}
.travel-leg-icon {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: var(--surface);
  border-radius: 8px;
  color: var(--primary);
}
.travel-leg-icon i { font-size: 14px; }
.travel-leg b { color: var(--tl-text-2); font-weight: 600; }

/* 빈 상태 */
.tl-empty {
  padding: 60px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--tl-border);
  border-radius: var(--r-lg);
  color: var(--tl-text-3);
}
.tl-empty i { font-size: 36px; color: var(--primary); margin-bottom: 12px; display: block; }
.tl-empty p { margin: 4px 0; }

/* ============================================================
   우측 요약 패널 (.tl-summary)
   ============================================================ */
.tl-summary {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 100px;
  align-self: start;
}
.tl-summary-card {
  background: var(--surface);
  border: 1px solid var(--tl-border);
  border-radius: var(--r-lg);
  padding: 20px;
  backdrop-filter: blur(16px);
}
.tl-summary-card h3 {
  font-size: 12px; font-weight: 600;
  color: var(--tl-text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 14px;
}
.tl-summary-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.tl-summary-stat-num {
  font-size: 24px; font-weight: 700;
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
  color: var(--primary);
}
.tl-summary-stat-num small { font-size: 14px; color: var(--tl-text-3); margin-left: 2px; }
.tl-summary-stat-label { font-size: 11px; color: var(--tl-text-3); margin-top: 2px; }

/* 미니 동선 */
.tl-mini-route {
  position: relative;
  padding-left: 10px;
}
.tl-mini-route-empty {
  font-size: 13px; color: var(--tl-text-3);
  text-align: center; padding: 16px 0;
}
.tl-mini-route-item {
  position: relative;
  padding: 8px 0 8px 18px;
  font-size: 13px;
  color: var(--tl-text-2);
  border-left: 2px dashed var(--primary-line);
  margin-left: 4px;
}
.tl-mini-route-item::before {
  content: '';
  position: absolute;
  left: -5px; top: 14px;
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--bg), 0 0 8px var(--primary-glow);
}
.tl-mini-route-item:last-child { border-left-color: transparent; }
.tl-mini-route-item-name { font-weight: 600; color: var(--text-primary); }
.tl-mini-route-item-time { font-size: 11px; color: var(--tl-text-3); margin-top: 2px; }

/* 지도 모드 */
#detail-screen.tl-screen .tl-map-wrap {
  display: none;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--tl-border);
  margin-bottom: 24px;
  height: 480px;
}
#detail-screen.tl-screen .tl-map-wrap.show { display: block; }
#detail-screen.tl-screen .tl-map-wrap #map-view { height: 100%; }

/* 모바일 */
@media (max-width: 640px) {
  .tl-topbar { padding: 14px 18px; }
  .tl-day-rail { padding: 8px 18px 18px; }
  .tl-main { padding: 12px 18px 80px; gap: 24px; }
  .tl-head h2 { font-size: 22px; }
  .tcard { grid-template-columns: 48px 1fr; gap: 12px; }
  .tcard-orb { width: 48px; height: 48px; font-size: 18px; }
  .tcard-body { padding: 14px 16px; }
  .travel-leg { margin-left: 48px; }
}
