/* ===== VARIABLES ===== */
:root {
  --bg: #06080f;
  --bg2: #0e1222;
  --bg3: #151b30;
  --bg4: #1c2440;
  --bg-hover: #222c50;
  --text: #eef2ff;
  --text2: #8b97b8;
  --text3: #525f80;
  --accent: #3b82f6;
  --accent-g: rgba(59, 130, 246, .2);
  --green: #10b981;
  --green-g: rgba(16, 185, 129, .15);
  --yellow: #f59e0b;
  --yellow-g: rgba(245, 158, 11, .15);
  --red: #ef4444;
  --red-g: rgba(239, 68, 68, .15);
  --purple: #8b5cf6;
  --border: rgba(255, 255, 255, .06);
  --r: 14px;
  --rs: 8px;
  --rl: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, .45);
  --t: .25s cubic-bezier(.4, 0, .2, 1);
  --font: 'Inter', -apple-system, sans-serif;
}

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

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== LOADING ===== */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .5s, visibility .5s;
}

#loading-overlay.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.load-inner {
  text-align: center;
}

.load-icon-wrap {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  animation: glow 2s ease-in-out infinite;
}

.load-icon {
  font-size: 38px;
  color: #fff;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes glow {

  0%,
  100% {
    box-shadow: 0 0 20px var(--accent-g);
  }

  50% {
    box-shadow: 0 0 40px var(--accent-g), 0 0 60px rgba(139, 92, 246, .2);
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

.load-title {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.load-sub {
  color: var(--text2);
  font-size: 13px;
  margin: 4px 0 18px;
}

.load-bar {
  width: 180px;
  height: 4px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  margin: 0 auto;
}

.load-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 4px;
  transition: width .3s;
}

/* ===== APP CONTAINER ===== */
.app-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ===== HEADER ===== */
#nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 34px;
  color: var(--accent);
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
}

.header-link {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 255, 255, .05);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: var(--t);
}

.header-link:hover {
  background: var(--accent);
  color: #fff;
}

/* ===== SEARCH ===== */
.search-section {
  margin-bottom: 24px;
}

.search-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 20px;
  box-shadow: var(--shadow);
}

.search-field {
  position: relative;
}

.field-dot {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  z-index: 2;
}

.dot-green {
  background: var(--green);
  box-shadow: 0 0 8px rgba(16, 185, 129, .5);
}

.dot-red {
  background: var(--red);
  box-shadow: 0 0 8px rgba(239, 68, 68, .5);
}

.search-field input {
  width: 100%;
  height: 50px;
  padding: 0 48px 0 40px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: var(--t);
}

.search-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-g);
}

.search-field input::placeholder {
  color: var(--text3);
}

.field-action {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--t);
}

.field-action:hover {
  color: var(--accent);
  background: var(--accent-g);
}

.field-action .material-icons-round {
  font-size: 20px;
}

/* Divider + Swap */
.search-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-swap-fields {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--t);
  flex-shrink: 0;
}

.btn-swap-fields:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(180deg);
}

.btn-swap-fields .material-icons-round {
  font-size: 18px;
}

/* Suggestions */
.suggest-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  max-height: 220px;
  overflow-y: auto;
  display: none;
  box-shadow: var(--shadow);
}

.suggest-list.open {
  display: block;
}

.suggest-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}

.suggest-item:last-child {
  border-bottom: none;
}

.suggest-item:hover {
  background: var(--bg-hover);
}

.suggest-item .material-icons-round {
  font-size: 18px;
  color: var(--text3);
  flex-shrink: 0;
}

.suggest-name {
  font-size: 13px;
  font-weight: 500;
}

.suggest-routes {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
}

/* Section headers & place items */
.suggest-section {
  padding: 6px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text3);
  background: rgba(255, 255, 255, .02);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.suggest-section .material-icons-round {
  font-size: 14px;
}

.suggest-loading {
  color: var(--purple);
  animation: pulse .8s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: .5;
  }

  50% {
    opacity: 1;
  }
}

.suggest-place .suggest-routes b {
  color: var(--text);
  font-weight: 600;
}

.suggest-list {
  max-height: 300px;
}

/* Find Button */
.btn-find {
  width: 100%;
  height: 50px;
  margin-top: 16px;
  border: none;
  border-radius: var(--r);
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--t);
  position: relative;
  overflow: hidden;
}

.btn-find:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-g);
}

.btn-find:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.btn-find .material-icons-round {
  font-size: 20px;
}

.btn-find.loading {
  pointer-events: none;
}

.btn-find.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .15), transparent);
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 64px;
  opacity: .25;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  line-height: 1.6;
  max-width: 300px;
  margin: 0 auto;
}

/* ===== RESULTS ===== */
.results-section {
  animation: fadeUp .4s ease;
}

.results-section.hidden {
  display: none;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.results-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.btn-reset {
  border: none;
  background: none;
  color: var(--text2);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--t);
}

.btn-reset:hover {
  color: var(--accent);
}

.btn-reset .material-icons-round {
  font-size: 16px;
}

/* Result Card */
.result-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 20px;
  margin-bottom: 14px;
  transition: var(--t);
  animation: fadeUp .4s ease both;
}

.result-card:hover {
  border-color: rgba(59, 130, 246, .25);
}

.result-card.recommended {
  border-color: rgba(16, 185, 129, .3);
  background: linear-gradient(135deg, var(--bg2), rgba(16, 185, 129, .04));
}

.reco-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  padding: 8px 12px;
  margin: -4px -4px 12px;
  background: var(--green-g);
  border-radius: var(--rs);
}

.reco-badge .material-icons-round {
  font-size: 16px;
}

.rc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.rc-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.rc-type.direct {
  background: var(--green-g);
  color: var(--green);
}

.rc-type.transit {
  background: var(--yellow-g);
  color: var(--yellow);
}

.rc-stops {
  font-size: 12px;
  color: var(--text3);
}

.rc-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, .03);
  border-radius: var(--rs);
}

.rc-stats .material-icons-round {
  font-size: 14px;
  color: var(--accent);
}

.rc-stats-sep {
  color: var(--text3);
  margin: 0 2px;
}

/* Route Flow Badges */
.rc-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.rc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.rc-badge .material-icons-round {
  font-size: 14px;
}

.rc-transfer {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--yellow);
  font-weight: 600;
}

.rc-transfer .material-icons-round {
  font-size: 14px;
}

/* Step-by-step Navigation (the core feature) */
.nav-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-tl-step {
  display: flex;
  gap: 14px;
  position: relative;
  padding-bottom: 4px;
}

.nav-tl-step:not(:last-child) {
  padding-bottom: 0;
}

.nav-tl-step:not(:last-child) .tl-track::after {
  content: '';
  position: absolute;
  top: 36px;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--border);
}

/* Track (left column) */
.tl-track {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 32px;
  flex-shrink: 0;
}

.tl-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tl-dot .material-icons-round {
  font-size: 16px;
  color: #fff;
}

.tl-dot.start {
  background: var(--green);
}

.tl-dot.bus {
  background: var(--accent);
}

.tl-dot.transfer {
  background: var(--yellow);
}

.tl-dot.end {
  background: var(--red);
}

/* Content (right column) */
.tl-content {
  flex: 1;
  padding: 4px 0 18px;
  min-width: 0;
}

.tl-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 2px;
}

.tl-title b {
  font-weight: 700;
}

.tl-sub {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
}

.tl-sub-muted {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

/* Bus segment card inside timeline */
.tl-bus-card {
  margin-top: 6px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tl-bus-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.tl-bus-info {
  flex: 1;
  min-width: 0;
}

.tl-bus-name {
  font-size: 13px;
  font-weight: 600;
}

.tl-bus-detail {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
}

/* Halte list inside step */
.tl-halte-list {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, padding .35s ease;
  padding: 0 12px;
}

.tl-halte-list.open {
  max-height: 600px;
  padding: 8px 12px;
  overflow-y: auto;
}

.tl-halte-list::-webkit-scrollbar {
  width: 3px;
}

.tl-halte-list::-webkit-scrollbar-thumb {
  background: var(--text3);
  border-radius: 3px;
}

.tl-halte-item {
  font-size: 12px;
  color: var(--text2);
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tl-halte-item .material-icons-round {
  font-size: 10px;
  color: var(--text3);
}

.btn-show-halte {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--t);
}

.btn-show-halte:hover {
  color: #60a5fa;
}

.btn-show-halte .material-icons-round {
  font-size: 14px;
  transition: transform .25s;
}

.btn-show-halte.open .material-icons-round {
  transform: rotate(180deg);
}

/* No results */
.no-results {
  text-align: center;
  padding: 32px 16px;
  color: var(--text3);
}

.no-results .material-icons-round {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
  opacity: .3;
}

.no-results p {
  font-size: 13px;
  line-height: 1.6;
}

/* Alternative route recommendations */
.alt-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--yellow);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--yellow-g);
  border-radius: var(--rs);
}

.alt-header .material-icons-round {
  font-size: 20px;
}

.alt-card {
  border-left: 3px solid var(--yellow);
  cursor: pointer;
}

.alt-card:hover {
  border-color: var(--accent);
}

.alt-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--yellow);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.alt-info {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  line-height: 1.5;
}

.alt-info .material-icons-round {
  font-size: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.alt-info b {
  color: var(--text);
  font-weight: 600;
}

.alt-dist {
  color: var(--text3);
  font-size: 11px;
}

/* Walking suggestion card */
.walk-card {
  border-color: rgba(139, 92, 246, .3);
  background: linear-gradient(135deg, var(--bg2), rgba(139, 92, 246, .04));
}

/* Google Maps button */
.btn-gmaps {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--rs);
  background: rgba(16, 185, 129, .12);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(16, 185, 129, .2);
  transition: var(--t);
  margin-top: 6px;
}

.btn-gmaps:hover {
  background: rgba(16, 185, 129, .2);
  border-color: var(--green);
}

.btn-gmaps .material-icons-round {
  font-size: 16px;
}

/* ===== TOAST ===== */
.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: var(--rs);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 9999;
  opacity: 0;
  transition: var(--t);
  pointer-events: none;
  white-space: nowrap;
}

.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== RESPONSIVE ===== */
@media(max-width:480px) {
  .app-container {
    padding: 0 12px 32px;
  }

  .search-card {
    padding: 14px;
  }

  .result-card {
    padding: 16px;
  }
}