/* ===== ROOT & THEME ===== */
:root {
  --primary: #1a6fc4;
  --primary-dark: #145aa0;
  --primary-light: #e8f1fb;
  --accent: #f97316;
  --success: #16a34a;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== NAVBAR ===== */
#mainNav {
  background: var(--primary);
  padding: 0.75rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.navbar-brand {
  color: #fff !important;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.navbar-brand i { margin-right: 8px; }
.nav-link { color: rgba(255,255,255,0.85) !important; border-radius: 6px; padding: 0.4rem 0.8rem !important; transition: background 0.2s; }
.nav-link:hover, .nav-link.active { color: #fff !important; background: rgba(255,255,255,0.15); }
.navbar-toggler { border-color: rgba(255,255,255,0.4); }
.navbar-toggler-icon { filter: invert(1); }

/* ===== HERO ===== */
.hero-section {
  background: linear-gradient(135deg, #1a6fc4 0%, #0f4a8a 60%, #0c3d72 100%);
  padding: 60px 0 80px;
  color: #fff;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 4px 16px;
  font-size: 0.85rem;
  font-weight: 500;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
}
.hero-title .highlight { color: #fbbf24; }
.hero-subtitle {
  font-size: 1.1rem;
  opacity: 0.88;
  margin-bottom: 2rem;
}

/* ===== SEARCH CARD ===== */
.search-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.search-bar-section { background: var(--primary); padding-bottom: 0; }
.search-bar-section .search-card { border-radius: var(--radius) var(--radius) 0 0; }

.form-label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.form-control { border: 1.5px solid var(--border); border-radius: 8px; color: var(--text); }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,111,196,0.12); }
.form-control-lg { font-size: 1rem; padding: 0.7rem 1rem; }

.btn-search {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  transition: background 0.2s;
}
.btn-search:hover { background: var(--primary-dark); color: #fff; }

.btn-swap {
  background: var(--primary-light);
  color: var(--primary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.btn-swap:hover { background: var(--primary); color: #fff; }

/* ===== AUTOCOMPLETE ===== */
.autocomplete-wrapper { position: relative; width: 100%; }
.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.06);
  max-height: 280px;
  overflow-y: auto;
  z-index: 9999;
  display: none;
  scroll-behavior: smooth;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.1s;
  color: var(--text);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--primary-light); color: var(--primary); }
.autocomplete-item.active { background: var(--primary-light); color: var(--primary); }
.autocomplete-item:hover .autocomplete-match,
.autocomplete-item.active .autocomplete-match { color: var(--primary-dark); }
.autocomplete-item i { color: var(--primary); font-size: 0.8rem; width: 16px; flex-shrink: 0; }
.autocomplete-match { font-weight: 800; color: var(--primary); background: rgba(26,111,196,0.1); border-radius: 3px; padding: 0 2px; }
.autocomplete-empty {
  padding: 16px 14px;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
}

/* ===== POPULAR ROUTES ===== */
.section-title { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.route-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.route-card:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.route-card .from-to { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.route-card .arrow { color: var(--accent); }
.route-card .route-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ===== FEATURES ===== */
.features-section { background: #fff; }
.feature-card { padding: 1.5rem 1rem; }
.feature-icon {
  width: 56px; height: 56px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 1rem;
}
.feature-card h5 { font-weight: 700; margin-bottom: 0.5rem; }
.feature-card p { color: var(--text-muted); font-size: 0.92rem; }

/* ===== STATS ===== */
.stats-section { background: var(--primary); }
.stat-box { padding: 1rem; }
.stat-num { font-size: 1.8rem; font-weight: 800; color: #fff; }
.stat-label { font-size: 0.82rem; color: rgba(255,255,255,0.75); text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== FILTER BAR ===== */
.filter-bar { background: #fff; border: 1.5px solid var(--border); border-radius: 10px; padding: 0.75rem 1rem; }
.filter-label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.btn-filter {
  font-size: 0.82rem;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  transition: all 0.15s;
}
.btn-filter:hover { border-color: var(--primary); color: var(--primary); }
.btn-filter.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.sort-select { font-size: 0.82rem; max-width: 180px; border-radius: 6px; }

/* ===== BUS TABLE ===== */
.bus-table { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1.5px solid var(--border); }
.bus-table thead th {
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  padding: 12px 14px;
}
.bus-table tbody tr { transition: background 0.12s; }
.bus-table tbody tr:hover { background: var(--primary-light); }
.bus-table td { padding: 12px 14px; border-color: var(--border); font-size: 0.9rem; vertical-align: middle; }

/* Route cell — full trip name + via pill */
.route-cell { display: flex; flex-direction: column; gap: 3px; }
.route-main { font-size: 0.88rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.route-via  {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 600;
  background: #f0fdf4; color: #15803d;
  border-radius: 10px; padding: 2px 8px;
  width: fit-content;
}

.type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.type-ordinary { background: #f1f5f9; color: #475569; }
.type-ac       { background: #dbeafe; color: #1d4ed8; }
.type-volvo    { background: #fef3c7; color: #92400e; }
.type-other    { background: #f0fdf4; color: #15803d; }

.op-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 4px;
  display: inline-block;
}
.op-govt    { background: #e0f2fe; color: #075985; }
.op-other   { background: #fef3c7; color: #92400e; }

/* ===== BUS CARDS (MOBILE) ===== */
.bus-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.bus-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.6rem; }
.bus-no { font-weight: 700; font-size: 1rem; color: var(--primary); }
.bus-times { display: flex; align-items: center; gap: 8px; margin: 0.5rem 0; }
.bus-time { font-size: 1.1rem; font-weight: 700; }
.time-arrow { color: var(--text-muted); font-size: 0.8rem; }
.bus-duration { font-size: 0.78rem; color: var(--text-muted); }
.bus-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.bus-meta span { display: flex; align-items: center; gap: 4px; }

/* Full route display inside card */
.bus-route-full {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  background: var(--primary-light);
  border-radius: 6px;
  padding: 5px 10px;
  margin-top: 6px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.bus-route-full i { color: var(--primary); margin-top: 2px; flex-shrink: 0; }

/* ===== BADGES ===== */
.badge-route {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: all 0.15s;
}
.badge-route:hover { background: var(--primary); color: #fff; }
.cache-badge { font-size: 0.72rem; padding: 3px 8px; border-radius: 12px; font-weight: 600; }
.from-cache { background: #f0fdf4; color: #15803d; }
.live-data  { background: #fef3c7; color: #92400e; }

/* ===== FOOTER ===== */
.site-footer {
  background: #1e293b;
  color: #94a3b8;
  padding: 2.5rem 0 1.5rem;
  margin-top: 3rem;
}
.site-footer h5, .site-footer h6 { color: #f8fafc; font-weight: 700; margin-bottom: 0.75rem; }
.site-footer a { color: #94a3b8; text-decoration: none; transition: color 0.15s; display: block; margin-bottom: 4px; }
.site-footer a:hover { color: #f8fafc; }
.site-footer hr { border-color: #334155; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .hero-section { padding: 40px 0 60px; }
  .bus-table { display: none; }
  #busCards { display: block !important; }
}
@media (min-width: 769px) {
  #busCards { display: none !important; }
}

/* ===== HINDI / LANGUAGE TOGGLE ===== */
.btn-lang {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 14px;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
.btn-lang:hover { background: rgba(255,255,255,0.32); color: #fff; }

/* ===== HERO INLINE SEARCH ERROR ===== */
.hero-search-error {
  background: rgba(220, 53, 69, 0.18);
  border: 1px solid rgba(220, 53, 69, 0.5);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  text-align: left;
}

/* ===== LAST BUS WARNING ===== */
.last-bus-warning {
  background: linear-gradient(90deg, #1e293b 0%, #2d3748 100%);
  color: #fbbf24;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  border-left: 4px solid #fbbf24;
}

/* ===== MOBILE FILTER PANEL ===== */
@media (max-width: 767px) {
  .filter-panel {
    display: none;
    margin-top: 0.5rem;
  }
  .filter-panel.filter-panel-open {
    display: block;
  }
  .filter-active-count {
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 6px;
  }
}
@media (min-width: 768px) {
  .filter-panel { display: block !important; }
}

/* ===== SWAP BUTTON — bigger tap target on mobile ===== */
.btn-swap {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== RECENT SEARCHES CARD ===== */
.recent-route-card {
  border-style: dashed;
}
.recent-route-card .route-meta {
  color: var(--primary);
}

/* ===== PRINT STYLES ===== */
@media print {
  #mainNav, .filter-bar, .btn-via, .hero-section,
  .search-bar-section, .site-footer, #filtersRow,
  #resultsHeader .d-flex > *:not(h5), #busCards { display: none !important; }
  .bus-table { display: table !important; border: 1px solid #ccc; }
  body { background: #fff; color: #000; }
}
