/* flight.css - Modern Responsive Styles for WebETrip Flight Search */
:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --secondary: #0f172a;
  --accent: #f97316;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #38bdf8;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header & Banner */
.site-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #0284c7 100%);
  color: white;
  padding: 30px 20px 40px;
  box-shadow: var(--shadow);
  position: relative;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.top-nav a.back-link {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  backdrop-filter: blur(4px);
  transition: all 0.2s;
}

.top-nav a.back-link:hover {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-title .airplane-icon {
  font-size: 2rem;
  display: inline-block;
  transform: rotate(-25deg);
}

.hero-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.05rem;
  margin-top: 8px;
}

/* Main Container */
.main-content {
  max-width: 1200px;
  margin: -25px auto 60px;
  padding: 0 20px;
}

/* Search Box Card */
.search-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  margin-bottom: 30px;
}

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

.section-title span.badge {
  font-size: 0.75rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.range-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 850px) {
  .range-grid {
    grid-template-columns: 1fr;
  }
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-label small {
  color: var(--text-muted);
  font-weight: normal;
}

/* Chips / Tags for Range Selection */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}

.chip.quick-all {
  border-style: dashed;
  font-weight: 600;
}

/* Custom Input inside chip row */
.custom-code-input {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.custom-code-input input {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  outline: none;
  text-transform: uppercase;
  max-width: 140px;
  transition: border-color 0.2s;
}

.custom-code-input input:focus {
  border-color: var(--primary);
}

.btn-add-code {
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-add-code:hover {
  background: #e2e8f0;
}

/* Date Range Section */
.date-range-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

.date-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.date-input-wrap input[type="date"] {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text-main);
  background: white;
  outline: none;
  transition: border-color 0.2s;
}

.date-input-wrap input[type="date"]:focus {
  border-color: var(--primary);
}

.quick-date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.preset-btn {
  padding: 4px 10px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.preset-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Options / Action Row */
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

.filter-options {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-main);
}

.btn-search {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: white;
  border: none;
  padding: 12px 36px;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  transition: all 0.2s;
}

.btn-search:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
}

.btn-search:active {
  transform: translateY(0);
}

/* Status Banner */
.status-banner {
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.3s ease;
}

.status-db_cache {
  background: var(--success-bg);
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.status-live_crawled {
  background: var(--info-bg);
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.status-hybrid {
  background: var(--purple-bg);
  border: 1px solid #ddd6fe;
  color: #5b21b6;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.82rem;
  background: white;
}

/* Results Stats Bar */
.results-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.stat-val {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--secondary);
  margin-top: 4px;
}

.stat-val.highlight {
  color: var(--accent);
}

/* Price Matrix / Calendar Grid */
.matrix-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
  overflow-x: auto;
}

.matrix-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 600px;
}

.price-table th, .price-table td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: center;
}

.price-table th {
  background: #f1f5f9;
  font-weight: 600;
  color: var(--text-main);
}

.price-table td.has-price {
  font-weight: 700;
  color: var(--primary);
  background: #f0fdf4;
}

.price-table td.min-overall {
  background: #dcfce7;
  color: #15803d;
  font-weight: 800;
  position: relative;
}

.price-table td.min-overall::after {
  content: "★ 最低";
  display: block;
  font-size: 0.68rem;
  font-weight: normal;
}

/* Sort & Filter Controls */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.sort-select {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

/* Flight List Cards */
.flight-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.flight-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 200px 1fr 180px;
  align-items: center;
  gap: 24px;
  transition: all 0.2s ease;
}

.flight-card:hover {
  box-shadow: var(--shadow);
  border-color: #cbd5e1;
}

@media (max-width: 850px) {
  .flight-card {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.airline-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.airline-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--secondary);
}

.airline-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
  width: fit-content;
}

.airline-tag.tag-JX { background: #fef3c7; color: #b45309; } /* 星宇金 */
.airline-tag.tag-BR { background: #dcfce7; color: #15803d; } /* 長榮綠 */
.airline-tag.tag-CI { background: #ffe4e6; color: #be123c; } /* 華航紅 */
.airline-tag.tag-IT { background: #ffedd5; color: #c2410c; } /* 虎航橘 */
.airline-tag.tag-MM { background: #fce7f3; color: #be185d; } /* 樂桃粉 */
.airline-tag.tag-TR { background: #fef08a; color: #854d0e; } /* 酷航黃 */
.airline-tag.tag-CX { background: #ccfbf1; color: #0f766e; } /* 國泰青 */
.airline-tag.tag-JL { background: #fee2e2; color: #b91c1c; } /* 日航紅 */
.airline-tag.tag-NH { background: #e0f2fe; color: #0369a1; } /* 全日空藍 */

.flight-details-col {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.time-box {
  display: flex;
  flex-direction: column;
}

.time-box .time {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--secondary);
}

.time-box .city {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.duration-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 110px;
}

.duration-line .duration {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.duration-line .flight-bar {
  width: 100%;
  height: 2px;
  background: #cbd5e1;
  position: relative;
  margin: 6px 0;
}

.duration-line .flight-bar::after {
  content: "✈";
  position: absolute;
  right: -5px;
  top: -8px;
  font-size: 12px;
  color: var(--primary);
}

.duration-line .stop-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

.stop-badge.direct {
  color: #15803d;
  background: #dcfce7;
}

.stop-badge.transit {
  color: #c2410c;
  background: #ffedd5;
}

.price-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
}

@media (max-width: 850px) {
  .price-col {
    align-items: flex-start;
  }
}

.price-tag {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-hover);
}

.price-tag small {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
}

.source-badge {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Loading & Empty State */
.loading-box, .empty-box {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
