/* css/style.css - 我要回央北 RWD 通勤輔助工具樣式表 */

:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #273549;
  --bg-card-subtle: #182234;
  --border-color: #334155;
  --border-active: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #cbd5e1;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --metro-green: #00874e;
  --metro-green-light: #10b981;
  --circular-yellow: #facc15;
  --bus-blue: #38bdf8;
  --champion-gold: #fbbf24;
  --danger-red: #ef4444;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px -5px rgba(59, 130, 246, 0.3);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang TC", "Noto Sans TC", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-card-subtle: #f8fafc;
    --border-color: #e2e8f0;
    --border-active: #2563eb;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-sub: #334155;
    --shadow-card: 0 4px 15px -1px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 20px -3px rgba(37, 99, 235, 0.2);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: 80px;
}

/* App 容器寬度限制與邊距 */
.app-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 頂部導覽列 */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #10b981, #0284c7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

/* 即時時間與狀態列 */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
}

.live-time-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: #64748b;
  transition: all 0.3s ease;
}

.live-dot.active-live {
  background-color: var(--metro-green-light);
  box-shadow: 0 0 8px var(--metro-green-light);
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.sim-input {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* 控制區塊標題 */
.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 分段切換器 (Segmented Controls) */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.seg-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1.2;
}

.seg-btn small {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.8;
}

.seg-btn:hover {
  color: var(--text-main);
}

.seg-btn.active {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* 排序與腳程快選列 */
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.pill-btn:hover {
  border-color: var(--accent-blue);
}

.pill-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-blue);
  color: #60a5fa;
}

/* 最佳推薦英雄卡片 (Champion Card) */
.champion-card {
  position: relative;
  background: linear-gradient(135deg, #1e293b 0%, #1e3a5f 100%);
  border: 2px solid var(--champion-gold);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: 0 10px 30px -5px rgba(251, 191, 36, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.champion-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.champion-badge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.champion-sub-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.crown-badge {
  background: linear-gradient(90deg, #f59e0b, #d97706);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
}

.champion-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.champion-via {
  font-size: 13px;
  color: var(--text-sub);
}

.champion-main-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.big-eta-group {
  display: flex;
  flex-direction: column;
}

.eta-label {
  font-size: 11px;
  color: #93c5fd;
  font-weight: 600;
}

.eta-time {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -1px;
  color: #ffffff;
  line-height: 1;
}

.total-minutes-badge {
  font-size: 15px;
  font-weight: 700;
  color: #fef08a;
  background: rgba(251, 191, 36, 0.15);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(251, 191, 36, 0.3);
}



/* 路線比較列表 */
.routes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 路線卡片 (Normal Route Card) */
.route-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  position: relative;
  animation: fadeIn 0.25s ease-out;
}

.route-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.route-card.rank-1 {
  border-left: 5px solid var(--champion-gold);
}

.route-card.mrt-type {
  border-left: 5px solid var(--metro-green-light);
}

.route-card.bus-type {
  border-left: 5px solid var(--bus-blue);
}

.route-card.circular-type {
  border-left: 5px solid var(--circular-yellow);
}

.route-card.walk-type {
  border-left: 5px solid #06b6d4;
}

.route-card.route-card-disabled {
  opacity: 0.6;
  filter: grayscale(25%);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.route-main-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.route-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.route-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.route-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-sub);
}

.route-tag.highlight {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.route-badge-fastest {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(6, 182, 212, 0.16);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.45);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
}

.route-badge-least-walk {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
}

.route-via-text {
  font-size: 12px;
  color: var(--text-muted);
}

.card-eta-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.card-eta-time {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.card-total-min {
  font-size: 12px;
  color: var(--accent-cyan);
  font-weight: 700;
}

/* 核心指標水平標籤 */
.metric-pills {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.metric-pill {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-pill.walk {
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.3);
}

.metric-pill.next-dep {
  color: #fde047;
  border-color: rgba(253, 224, 71, 0.3);
}

.metric-pill.fastest {
  color: #22d3ee;
  border-color: rgba(6, 182, 212, 0.45);
  background: rgba(6, 182, 212, 0.14);
}

.metric-pill.least-walk {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.14);
}

/* 展開詳細路徑時間軸 (Timeline) */
.timeline-drawer {
  display: none;
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
  margin-top: 4px;
  flex-direction: column;
  gap: 8px;
}

.route-card.expanded .timeline-drawer {
  display: flex;
}

.timeline-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-main);
  position: relative;
  line-height: 1.4;
}

.step-icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

.step-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
}

.expand-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* 底部功能與設定 Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 20px 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: sheetUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.sheet-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-cyan);
  border-left: 3px solid var(--accent-cyan);
  padding-left: 8px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-md);
}

.setting-label-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.setting-sublabel {
  font-size: 11px;
  color: var(--text-muted);
}

.number-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.num-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.num-btn:active {
  background: var(--accent-blue);
}

.num-display {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  min-width: 44px;
  text-align: center;
}

.sheet-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.btn-primary {
  flex: 1;
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:active {
  opacity: 0.85;
}

.btn-secondary {
  background: var(--bg-card-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

/* 動畫 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin-icon {
  display: inline-block;
  animation: spin 1.8s linear infinite;
}

/* 底部捷徑列 (Sticky Footer bar) */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 8px 16px;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.nav-item.active, .nav-item:hover {
  color: var(--accent-blue);
}

.nav-item svg {
  width: 20px;
  height: 20px;
}
