:root {
  --primary: #d9383a;
  --primary-dark: #b32024;
  --primary-light: #fbebee;
  --secondary: #0f172a;
  --accent: #d97706;
  --accent-light: #fef3c7;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  padding-bottom: 60px;
}

/* 獨立頂部導覽列（避免按鈕遮擋標題） */
.top-bar {
  background: #0f172a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 0;
  position: relative;
  z-index: 100;
}

.top-bar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.brand-tag {
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-select {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.lang-select option {
  background: #1e293b;
  color: white;
}

.btn-print-action {
  background: var(--surface);
  color: #0f172a;
  border: 1px solid #cbd5e1;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.btn-print-action:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
}

/* Header 區域 */
header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
  color: white;
  padding: 32px 0 28px;
  position: relative;
  overflow: hidden;
}

header::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(217, 56, 58, 0.25) 0%, rgba(217, 56, 58, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.container {
  max-width: 1050px;
  margin: 0 auto;
  padding: 0 16px;
}

.badge-trip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(217, 56, 58, 0.2);
  border: 1px solid rgba(217, 56, 58, 0.4);
  color: #ff8a8c;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}

h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.3;
}

.hero-subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  margin-top: 6px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.stat-label {
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.stat-value {
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 800;
  margin-top: 2px;
}

/* 分頁導覽 */
.nav-tabs-wrapper {
  position: sticky;
  top: 0;
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(12px);
  z-index: 90;
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  margin-bottom: 24px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--surface-subtle);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* 天數按鈕列 */
.day-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 20px;
  scrollbar-width: thin;
}

.day-btn {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 80px;
}

.day-btn:hover {
  border-color: var(--primary);
}

.day-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.day-btn .d-num {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.85;
}

.day-btn .d-date {
  font-size: 0.9rem;
  font-weight: 800;
}

/* 每日詳細行程卡片 */
.day-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.day-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.day-title-group h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--secondary);
}

.city-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  margin-left: 8px;
}

.city-tag.kyoto { background: #fef3c7; color: #92400e; }
.city-tag.osaka { background: #e0e7ff; color: #3730a3; }
.city-tag.usj { background: #fce7f3; color: #9d174d; }

.day-body { padding: 24px; }

.timeline {
  position: relative;
  padding-left: 28px;
  margin-bottom: 24px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-item:last-child { margin-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -28px;
  top: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--primary);
}

.timeline-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.timeline-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.timeline-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.day-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.meta-box h4 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-box p {
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 500;
}

/* 卡片與航班住宿樣式 */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}

.badge-status.pending {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid #fde68a;
}

.flight-route {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0;
  padding: 14px 16px;
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
}

.flight-point { text-align: center; }
.flight-time { font-size: 1.25rem; font-weight: 800; }
.flight-code { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.flight-arrow { color: var(--primary); font-weight: 700; font-size: 0.85rem; text-align: center; }

/* 待辦清單與進度條 */
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
}

.checklist-item:hover { background: var(--surface-subtle); }
.checklist-item input[type="checkbox"] { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.checklist-title { font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.checklist-desc { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

.progress-bar-wrap {
  margin: 16px 0 20px;
  background: var(--surface-subtle);
  border-radius: 10px;
  height: 10px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 10px;
  transition: width 0.3s ease;
}

/* 環球影城特輯 */
.usj-hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.usj-hero h3 { font-size: 1.45rem; font-weight: 800; margin-bottom: 8px; }
.usj-hero p { color: #c7d2fe; font-size: 0.95rem; }
.usj-tips-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.usj-tip-card { background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: var(--radius-md); padding: 16px; }
.usj-tip-title { font-weight: 700; font-size: 0.95rem; color: #fbbf24; margin-bottom: 6px; }
.usj-tip-desc { font-size: 0.85rem; color: #e0e7ff; line-height: 1.5; }

/* 預算表格 */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9rem; }
th { background: var(--surface-subtle); color: var(--text-muted); font-weight: 700; padding: 12px 16px; border-bottom: 2px solid var(--border); }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.num-col { text-align: right; font-weight: 600; }
.tfoot-total td { font-weight: 800; font-size: 1rem; background: var(--surface-subtle); border-top: 2px solid var(--secondary); }

/* ==========================================================================
   A4 申請表列印專用樣式（完美均勻填滿單頁 A4）
   ========================================================================== */
#print-container {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm 10mm 12mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 9.5pt !important;
    line-height: 1.4 !important;
  }

  /* 隱藏網頁互動操作介面 */
  .top-bar, header, .nav-tabs-wrapper, main {
    display: none !important;
  }

  /* 顯示 A4 正式文件格式 */
  #print-container {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
  }

  .print-header {
    text-align: center;
    margin-bottom: 10px;
  }

  .print-title {
    font-size: 16pt !important;
    font-weight: 900 !important;
    color: #0f172a !important;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
  }

  .print-subtitle {
    font-size: 9.5pt !important;
    color: #475569 !important;
    font-weight: 600;
  }

  .print-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    background: #f8fafc !important;
    border: 1px solid #94a3b8 !important;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 9pt !important;
  }

  .print-table {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: fixed !important;
    margin-bottom: 8px !important;
  }

  .print-table th {
    background: #e2e8f0 !important;
    color: #0f172a !important;
    border: 1px solid #64748b !important;
    padding: 5px 6px !important;
    font-size: 9pt !important;
    font-weight: 800 !important;
    text-align: left !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-table td {
    border: 1px solid #94a3b8 !important;
    padding: 5px 6px !important;
    font-size: 8.5pt !important;
    line-height: 1.35 !important;
    color: #1e293b !important;
    vertical-align: top !important;
    word-break: break-word;
  }

  .print-col-date { width: 15%; font-weight: 700; }
  .print-col-city { width: 18%; font-weight: 600; }
  .print-col-plan { width: 44%; }
  .print-col-hotel { width: 23%; white-space: pre-line; font-size: 8pt !important; }

  .print-footer {
    font-size: 7.5pt !important;
    color: #64748b !important;
    text-align: center;
    border-top: 1px solid #cbd5e1;
    padding-top: 4px;
    margin-top: 4px;
  }
}

@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  .day-header { flex-direction: column; align-items: flex-start; }
  .day-meta-grid { grid-template-columns: 1fr; }
}
