/* ===== Design Tokens ===== */
:root {
  --primary: #2F80ED;
  --primary-dark: #1C5ED6;
  --secondary: #27AE60;
  --secondary-light: #6FCF97;
  --text: #1F2937;
  --text-muted: #6B7280;
  --bg: #F9FAFB;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --warning: #F59E0B;
  --danger: #EF4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}
.nav-toggle {
  display: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 22px;
  color: var(--text);
  border-radius: 8px;
  margin-left: 8px;
}
.nav-toggle:hover { background: var(--bg); }
.nav-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 20px;
  color: var(--primary-dark);
}
.logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff; font-size: 16px;
}
.logo-img {
  height: 44px;
  width: auto;
  display: block;
}
.nav-links {
  display: flex; gap: 26px; align-items: center;
  font-size: 15px; font-weight: 600;
}
.nav-links a { color: var(--text); }
.nav-links a:hover { color: var(--primary); text-decoration: none; }

/* ===== Hero ===== */
.hero {
  position: relative;
  /* Cartoon scene background — bus on road, mountains, Thailand map.
     Gradient is the fallback shown before the SVG paints. */
  background:
    url("../img/hero-bg.svg") center bottom / cover no-repeat,
    linear-gradient(135deg, #1C5ED6 0%, #2F80ED 50%, #27AE60 100%);
  color: #fff;
  padding: 80px 20px 60px;
  overflow: hidden;
  min-height: 480px;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  /* Soft top-down dim so white text stays readable over the bright sky */
  background:
    linear-gradient(180deg, rgba(15,23,42,0.28) 0%, rgba(15,23,42,0) 45%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,0.18) 0%, transparent 60%);
  pointer-events: none;
}
.hero-inner {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  margin: 0 0 16px;
  line-height: 1.2;
  text-shadow: 0 2px 16px rgba(15,23,42,0.45);
}
.hero p {
  font-size: clamp(15px, 2vw, 18px);
  opacity: .95;
  margin: 0 auto 40px;
  max-width: 600px;
  text-shadow: 0 1px 8px rgba(15,23,42,0.4);
}

/* ===== Search Box ===== */
.search-box {
  position: relative;
  max-width: 1100px;
  margin: 32px auto 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  z-index: 10;
}
.search-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-pill);
  width: fit-content;
}
.search-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  transition: all .2s;
}
.search-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.search-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.field input, .field select {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  transition: all .2s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47,128,237,.15);
}

/* ===== Buttons ===== */
.btn {
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-success {
  background: var(--secondary);
  color: #fff;
}
.btn-success:hover { background: #1F8F4D; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 32px; font-size: 17px; }

/* ===== Sections ===== */
.section {
  max-width: 1200px;
  margin: 80px auto;
  padding: 0 20px;
}
.section-header {
  text-align: center;
  margin-bottom: 40px;
}
.section-header h2 {
  font-size: clamp(24px, 3vw, 32px);
  margin: 0 0 8px;
}
.section-header p {
  color: var(--text-muted);
  margin: 0;
}

/* ===== Features ===== */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}
.feature-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 28px;
  border: 1px solid var(--border);
  transition: all .25s;
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.feature-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: grid; place-items: center;
  color: #fff; font-size: 22px;
  margin-bottom: 16px;
}
.feature-card h3 { margin: 0 0 8px; font-size: 18px; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: 14px; }

/* ===== Popular Routes ===== */
.routes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.route-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, border-color .2s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.route-card:hover {
  border-color: var(--primary);
  box-shadow: 0 12px 28px rgba(47,128,237,.18);
  transform: translateY(-4px);
}
.route-card:hover .route-photo,
.route-card:hover .route-emoji {
  transform: scale(1.06);
}
.route-image {
  position: relative;
  height: 140px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 14px 16px;
  overflow: hidden;
  isolation: isolate;
}
.route-image::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.45) 100%);
  z-index: 1;
}
.route-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
  z-index: 0;
}
.route-emoji {
  position: absolute;
  top: 12px; right: 14px;
  font-size: 32px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
  transition: transform .4s ease;
  z-index: 2;
}
.route-chip {
  position: absolute;
  top: 12px; left: 14px;
  z-index: 2;
  background: rgba(255,255,255,.92);
  color: #1F2937;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.route-chip.in-season {
  background: #FEF3C7;
  color: #92400E;
  animation: chipPulse 2.4s ease-in-out infinite;
}
@keyframes chipPulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(245,158,11,.4); }
  50%      { box-shadow: 0 2px 14px rgba(245,158,11,.7); }
}
.route-subtle {
  position: absolute;
  bottom: 14px; right: 14px;
  z-index: 2;
  color: rgba(255,255,255,.85);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .3px;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
  text-transform: uppercase;
}
.route-destination {
  position: relative;
  z-index: 2;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .2px;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.route-info {
  padding: 14px 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.route-info .title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.35;
}
.route-info .title .arrow {
  color: var(--primary);
  font-weight: 700;
  margin: 0 2px;
}
.route-info .price-badge {
  background: rgba(47,128,237,.1);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== Trip details (expandable amenities on results) ===== */
.trip-details { margin-top: 12px; }
.trip-details summary {
  cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 600; color: var(--primary);
  padding: 8px 0; user-select: none;
}
.trip-details summary::-webkit-details-marker { display: none; }
.trip-details[open] summary { color: var(--primary-dark); }
.trip-details-body { padding: 6px 2px 4px; }
.amenities-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.amenity {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 500;
}
.amenity .ico { font-size: 14px; }
.trip-facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px;
  font-size: 13px; margin-bottom: 12px;
}
.trip-facts > div { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.trip-facts .k { color: var(--text-muted); }
.trip-facts .v { font-weight: 600; text-align: right; }
.trip-policy {
  font-size: 12.5px; color: var(--text-muted); line-height: 1.6;
  background: #F0F7FF; border-radius: 8px; padding: 10px 12px;
}
@media (max-width: 600px) { .trip-facts { grid-template-columns: 1fr; } }

/* ===== Search Results Page ===== */
.results-page {
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}
.filter-panel {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border);
  height: fit-content;
  position: sticky;
  top: 80px;
}
.filter-panel h3 { margin: 0 0 16px; font-size: 16px; }
.filter-group { margin-bottom: 20px; }
.filter-group h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 8px;
  text-transform: uppercase;
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
  cursor: pointer;
}
.filter-option input { accent-color: var(--primary); }

.results-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.results-summary .route-text {
  font-weight: 600;
  font-size: 16px;
}
.results-summary .route-text small {
  display: block;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  margin-top: 2px;
}

.trip-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  transition: all .2s;
}
.trip-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); }
.trip-card-inner {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 20px;
  align-items: center;
}
.trip-provider {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.trip-provider .logo-circle {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  margin-bottom: 6px;
}
.trip-provider .name { font-size: 11px; color: var(--text-muted); }

.trip-timeline {
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  gap: 12px;
  align-items: center;
}
.trip-time {
  font-size: 22px;
  font-weight: 700;
}
.trip-place {
  font-size: 13px;
  color: var(--text-muted);
}
.trip-line {
  position: relative;
  text-align: center;
}
.trip-line::before {
  content: "";
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 2px;
  background: var(--border);
}
.trip-line .duration {
  position: relative;
  background: var(--surface);
  padding: 0 8px;
  font-size: 12px;
  color: var(--text-muted);
  display: inline-block;
}

.trip-meta {
  text-align: center;
}
.trip-type-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}
.badge-train { background: rgba(47,128,237,.1); color: var(--primary); }
.badge-bus { background: rgba(39,174,96,.1); color: var(--secondary); }
.badge-van { background: rgba(245,158,11,.1); color: var(--warning); }
.seats-left {
  font-size: 12px;
  color: var(--warning);
  margin-top: 6px;
}

.trip-action {
  text-align: right;
}
.trip-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 8px;
}
.trip-price small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ===== Progress Bar ===== */
.progress {
  max-width: 800px;
  margin: 30px auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}
.progress-step .num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  z-index: 2;
  transition: all .3s;
}
.progress-step .label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.progress-step.active .num { background: var(--primary); color: #fff; }
.progress-step.active .label { color: var(--primary); font-weight: 600; }
.progress-step.done .num { background: var(--secondary); color: #fff; }
.progress-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 -4px;
  margin-top: -22px;
  position: relative;
  z-index: 1;
}
.progress-line.done { background: var(--secondary); }

/* ===== Booking Form ===== */
.booking-page {
  max-width: 1100px;
  margin: 30px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 28px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 6px;
  font-size: 20px;
}
.card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row.single { grid-template-columns: 1fr; }

/* ===== Summary Sidebar ===== */
.summary {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
  position: sticky;
  top: 80px;
  height: fit-content;
}
.summary h3 { margin: 0 0 16px; font-size: 16px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px dashed var(--border);
}
.summary-row:last-of-type { border-bottom: none; }
.summary-row .label { color: var(--text-muted); }
.summary-total {
  display: flex;
  justify-content: space-between;
  padding: 16px 0 8px;
  margin-top: 8px;
  border-top: 2px solid var(--text);
  font-size: 18px;
  font-weight: 700;
}
.summary-total .price { color: var(--primary-dark); }

/* ===== Payment ===== */
.payment-methods {
  display: grid;
  gap: 10px;
}
.payment-method {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all .2s;
}
.payment-method:hover { border-color: var(--primary); }
.payment-method.selected {
  border-color: var(--primary);
  background: rgba(47,128,237,.04);
}
.payment-method input { accent-color: var(--primary); }
.payment-method .pm-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--bg);
  display: grid; place-items: center;
  font-size: 20px;
}
.payment-method .pm-name { font-weight: 600; flex: 1; }
.payment-method .pm-desc { font-size: 12px; color: var(--text-muted); }

/* ===== Confirmation ===== */
.confirm-page {
  max-width: 700px;
  margin: 60px auto;
  padding: 0 20px;
}
.confirm-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.success-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--secondary);
  color: #fff;
  display: grid; place-items: center;
  margin: 0 auto 20px;
  font-size: 40px;
  animation: pop .4s ease;
}
@keyframes pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
.confirm-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
}
.confirm-card p { color: var(--text-muted); margin: 0 0 28px; }
.booking-id {
  display: inline-block;
  background: var(--bg);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 24px;
}
.qr-placeholder {
  width: 180px; height: 180px;
  background: repeating-linear-gradient(45deg, #1F2937 0 4px, #fff 4px 8px);
  margin: 0 auto 24px;
  border-radius: var(--radius-sm);
  border: 4px solid #fff;
  outline: 1px solid var(--border);
}
.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Footer ===== */
footer {
  background: #1F2937;
  color: #D1D5DB;
  padding: 40px 20px 20px;
  margin-top: 80px;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 24px;
}
.footer-grid h4 { color: #fff; margin: 0 0 12px; font-size: 14px; }
.footer-grid a { display: block; color: #9CA3AF; font-size: 13px; padding: 4px 0; }
.footer-grid a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid #374151;
  padding-top: 16px;
  text-align: center;
  font-size: 13px;
  color: #6B7280;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  /* Hamburger drawer */
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px 16px;
    box-shadow: 0 10px 30px rgba(15,23,42,.12);
    border-top: 1px solid var(--border);
    gap: 4px;
    z-index: 100;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a {
    padding: 12px 8px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
  }
  .nav-links a:hover { background: var(--bg); }
  /* Auth pill stays full-width inside the drawer */
  .nav-links [data-auth-rendered] {
    margin-left: 0 !important;
    width: auto;
    text-align: center;
  }

  .search-grid { grid-template-columns: 1fr; }
  .results-page { grid-template-columns: 1fr; }
  .filter-panel { position: static; }
  .booking-page { grid-template-columns: 1fr; }
  .summary { position: static; }
  .trip-card-inner {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .trip-provider { grid-column: 1; grid-row: 1; flex-direction: row; gap: 10px; }
  .trip-timeline { grid-column: 1 / -1; grid-row: 2; }
  .trip-meta { grid-column: 1; grid-row: 3; text-align: left; }
  .trip-action { grid-column: 2; grid-row: 3; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .hero { padding: 60px 16px 40px; min-height: 360px; }
  .search-box { padding: 16px; margin-top: 20px; }
  .footer-grid { grid-template-columns: 1fr; }
}
