/* ==========================================================================
   eBus Design System & Main Stylesheet
   ========================================================================== */
@import './ticket.css';

:root {
  /* Brend ranglari (sublimation.uz uslubi: to'q ko'k + moviy oila) */
  --ink: #00102d;
  --blue: #4db1ef;
  --ice: #99ddff;
  --mist: #c1d4e0;
  --sky: #57a3ff;
  --deep: #0554c6;

  --primary-rgb: 5, 84, 198;
  --on-primary: #ffffff;
  --solid-bg: #00102d;
  --solid-fg: #ffffff;

  --primary-50: #edf7ff;
  --primary-100: #d3ecfc;
  --primary-200: #99ddff;
  --primary-300: #7cc6f5;
  --primary-400: #4db1ef;
  --primary-500: #4db1ef;
  --primary-600: #0554c6;
  --primary-700: #04419a;
  --primary-800: #022f70;
  --primary-900: #00102d;

  /* Holat ranglari (faqat to'langan / kutilmoqda / xato uchun) */
  --accent-50: #e8f8f2;
  --accent-100: #c8efe0;
  --accent-500: #12a37a;
  --accent-600: #0b8a66;
  --accent-700: #076b4f;

  --warning-50: #fff7e6;
  --warning-100: #fdebc1;
  --warning-500: #f59e0b;
  --warning-600: #b86e00;
  --warning-700: #8a5200;

  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-200: #fecaca;
  --danger-500: #ef4444;
  --danger-600: #c81e1e;

  /* Yuzalar va neytral ranglar */
  --surface-bg: #f3f8fc;
  --surface-card: #ffffff;
  --surface-muted: #e8f0f6;
  --surface-border: #c9dae6;
  --surface-border-focus: #0554c6;
  --line-strong: rgba(0, 16, 45, 0.35);
  --ticket-line: rgba(0, 16, 45, 0.6);
  --header-bg: rgba(255, 255, 255, 0.97);

  /* Matn */
  --text-main: #00102d;
  --text-body: #243a5a;
  --text-muted: #52667f;
  --text-subtle: #8396ae;
  --text-white: #ffffff;

  /* Shriftlar */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Roboto Condensed', 'Arial Narrow', Arial, sans-serif;

  /* Soyalar (sayt deyarli soyasiz: yupqa chiziqlar, faqat kartalarda yumshoq soya) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 16, 45, 0.05);
  --shadow-md: 0 4px 10px -2px rgba(0, 16, 45, 0.1);
  --shadow-lg: 0 10px 20px -4px rgba(0, 16, 45, 0.12);
  --shadow-xl: 0 10px 36px rgba(0, 16, 45, 0.28);
  --shadow-glow: 0 0 20px rgba(77, 177, 239, 0.35);

  /* Burchaklar */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Animatsiyalar */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  /* Qorong'i yuzalar */
  --surface-bg: #00102d;
  --surface-card: #071c40;
  --surface-muted: #0d2850;
  --surface-border: #1c3866;
  --surface-border-focus: #4db1ef;
  --line-strong: rgba(193, 212, 224, 0.4);
  --ticket-line: rgba(193, 212, 224, 0.4);
  --header-bg: rgba(0, 16, 45, 0.97);

  /* Qorong'i matn */
  --text-main: #f2f8fc;
  --text-body: #c1d4e0;
  --text-muted: #93a9c2;
  --text-subtle: #6a82a0;

  /* Qorong'i mavzuda asosiy rang yorqin moviy bo'ladi (matn sifatida ham o'qiladi) */
  --primary-rgb: 77, 177, 239;
  --on-primary: #00102d;
  --solid-bg: #4db1ef;
  --solid-fg: #00102d;

  --primary-50: rgba(77, 177, 239, 0.12);
  --primary-100: rgba(77, 177, 239, 0.22);
  --primary-200: rgba(77, 177, 239, 0.38);
  --primary-300: #4db1ef;
  --primary-400: #4db1ef;
  --primary-500: #4db1ef;
  --primary-600: #4db1ef;
  --primary-700: #99ddff;
  --primary-800: #c1d4e0;

  --accent-50: rgba(18, 163, 122, 0.16);
  --accent-100: rgba(18, 163, 122, 0.28);
  --accent-600: #34d3a1;
  --accent-700: #6ee7b7;
  --warning-50: rgba(245, 158, 11, 0.15);
  --warning-100: rgba(245, 158, 11, 0.28);
  --warning-600: #f5a524;
  --warning-700: #fbbf24;
  --danger-50: rgba(239, 68, 68, 0.15);
  --danger-100: rgba(239, 68, 68, 0.28);
  --danger-200: rgba(239, 68, 68, 0.4);
  --danger-600: #f87171;

  /* Soyalar */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(77, 177, 239, 0.4);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Telefonda bosilganda brauzer qo'yadigan ko'k/kulrang yaltirash olib tashlanadi (bosish holati .btn:active va h.k. bilan) */
  -webkit-tap-highlight-color: transparent;
}

/* Tugmalar matni bosib turilganda ko'k belgilanib qolmasin; ikki marta bosganda kattalashish kechikishi bo'lmasin */
button, [role="button"] {
  -webkit-user-select: none;
  user-select: none;
}

a, button, [role="button"], select, label {
  touch-action: manipulation;
}

body {
  font-family: var(--font-body);
  background-color: var(--surface-bg);
  color: var(--text-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-main);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h1, h2 {
  text-transform: uppercase;
}

:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: 2px;
}

::selection {
  background: var(--blue);
  color: var(--ink);
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

@media (hover: hover) {
  a:hover {
    color: var(--primary-700);
  }
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* Sahifa qisqa bo'lsa ham pastki to'q chiziq ekran tagiga tushadi (tagida och bo'shliq qolmasin) */
.app-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

#view-search.active-view {
  display: flex !important;
  flex-direction: column;
  flex: 1 0 auto;
}

#view-search .features-bar {
  margin-top: auto;
}

.hidden {
  display: none !important;
}

.hidden-view {
  display: none !important;
}

.active-view {
  display: block !important;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--surface-border);
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-main);
}

/* Logotip: keng variant (yorug'/qorong'i mavzu uchun alohida) va telefonda faqat "e" belgisi */
.brand-img {
  display: block;
  height: 34px;
  width: auto;
  transition: transform var(--transition-fast);
}

@media (hover: hover) {
  .brand-logo:hover .brand-img {
    transform: scale(1.03);
  }
}

.brand-mark,
.brand-on-dark {
  display: none;
}

[data-theme="dark"] .brand-on-light {
  display: none;
}

[data-theme="dark"] .brand-on-dark {
  display: block;
}

.modal-logo {
  display: block;
  height: 28px;
  width: auto;
  margin-bottom: 10px;
}

.brand-tag {
  padding-left: 12px;
  border-left: 1.5px solid var(--surface-border);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Navigation */
.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-body);
  cursor: pointer;
  transition: all var(--transition-fast);
}

@media (hover: hover) {
  .nav-link:hover {
    background: var(--surface-muted);
    color: var(--text-main);
  }
}

.nav-link.active {
  background: var(--solid-bg);
  color: var(--solid-fg);
  font-weight: 600;
}

.badge-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--deep);
  color: #fff;
  box-shadow: 0 0 0 2px var(--surface-card);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Auth Box */
.auth-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-muted);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--surface-border);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

@media (hover: hover) {
  .user-badge:hover {
    background: var(--primary-50);
    border-color: var(--primary-200);
    color: var(--primary-600);
  }
}

.badge-gear-icon {
  opacity: 0.6;
  transition: transform var(--transition-bounce);
}

@media (hover: hover) {
  .user-badge:hover .badge-gear-icon {
    opacity: 1;
    transform: rotate(45deg);
  }
}

.user-badge-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

@media (hover: hover) {
  .theme-toggle-btn:hover {
    background: var(--primary-50);
    border-color: var(--primary-200);
    color: var(--primary-600);
    transform: rotate(15deg);
  }
}

.theme-icon-sun {
  display: none;
}
.theme-icon-moon {
  display: block;
}

[data-theme="dark"] .theme-icon-sun {
  display: block;
  color: #f59e0b;
}
[data-theme="dark"] .theme-icon-moon {
  display: none;
}

/* Language Switcher */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
}

.lang-btn {
  min-width: 36px;
  padding: 5px 10px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

@media (hover: hover) {
  .lang-btn:hover {
    color: var(--text-main);
  }
}

.lang-btn.active {
  background: var(--solid-bg);
  color: var(--solid-fg);
}

/* Buttons (sublimation.uz uslubi: to'liq yumaloq, yupqa ramka, soyasiz, hover'da rang almashadi) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.2;
  min-height: 44px;
  border-radius: var(--radius-full);
  padding: 10px 22px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform 120ms;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--ink);
}

@media (hover: hover) {
  .btn-primary:hover {
    background: var(--ice);
    border-color: var(--ice);
  }
}

/* Tasdiqlash / to'lash: to'q tugma (qorong'i mavzuda och) */
.btn-success {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

@media (hover: hover) {
  .btn-success:hover {
    background: var(--deep);
    border-color: var(--deep);
  }
}

[data-theme="dark"] .btn-success {
  background: var(--mist);
  border-color: var(--mist);
  color: var(--ink);
}

@media (hover: hover) {
  [data-theme="dark"] .btn-success:hover {
    background: var(--blue);
    border-color: var(--blue);
  }
}

.btn-outline {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text-main);
}

@media (hover: hover) {
  .btn-outline:hover {
    background: var(--surface-muted);
    border-color: var(--text-main);
  }
}

.btn-outline-danger {
  background: transparent;
  border-color: var(--danger-200, #fecaca);
  color: var(--danger-600);
}

@media (hover: hover) {
  .btn-outline-danger:hover {
    background: var(--danger-50);
    border-color: var(--danger-500);
  }
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 14px;
}

@media (hover: hover) {
  .btn-ghost:hover {
    color: var(--text-main);
    background: var(--surface-muted);
  }
}

.btn-sm {
  min-height: 36px;
  padding: 6px 16px;
  font-size: 0.92rem;
}

.btn-lg {
  min-height: 56px;
  padding: 14px 32px;
  font-size: 1.2rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Hero Section */
.hero-section {
  position: relative;
  background-color: var(--ink);
  color: #fff;
  padding: 48px 0 54px;
  overflow: hidden;
  min-height: 440px;
}

/* Burchak ramkalari (sublimation.uz hero'sidagi kabi) */
.hero-section::before,
.hero-section::after {
  content: '';
  position: absolute;
  z-index: 2;
  width: 48px;
  height: 48px;
  border: 0 solid var(--blue);
  pointer-events: none;
}

.hero-section::before {
  top: 18px;
  left: 18px;
  border-top-width: 3px;
  border-left-width: 3px;
}

.hero-section::after {
  right: 18px;
  bottom: 18px;
  border-right-width: 3px;
  border-bottom-width: 3px;
}

/* Avtobus foni (to'q ko'k → moviy duotone): rasm butun hero orqasida (cover) turadi, o'ng tomonda avtobus,
   chap tomoni rasmning o'zida to'q ko'k fonga so'ngan — chetda ko'rinadigan chegara yo'q.
   Manba: img/hero-bus.webp (954x700) → img/hero-bg.webp (2400x875, Pillow bilan: 1.25x, alfa gradient, o'ngga surilgan). */
.hero-bus-backdrop {
  position: absolute;
  inset: 0;
  background-image: url('/img/hero-bg.webp');
  background-repeat: no-repeat;
  background-position: right 58%;
  background-size: cover;
  pointer-events: none;
  z-index: 0;
}

/* Rasm ustidagi qoplama: chapda matn o'qilishi uchun qalin, o'ngda deyarli shaffof */
.hero-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 25%, rgba(77, 177, 239, 0.16) 0%, transparent 55%),
    linear-gradient(90deg, rgba(0, 16, 45, 0.9) 0%, rgba(0, 16, 45, 0.6) 38%, rgba(0, 16, 45, 0.12) 72%, rgba(0, 16, 45, 0) 100%),
    linear-gradient(180deg, rgba(0, 16, 45, 0.35) 0%, rgba(0, 16, 45, 0) 30%, rgba(0, 16, 45, 0.5) 100%);
  z-index: 1;
  pointer-events: none;
}

.hero-container {
  position: relative;
  z-index: 2;
  text-align: left;
}

.hero-text-wrap {
  margin-bottom: 26px;
  max-width: 680px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(77, 177, 239, 0.12);
  border: 1.5px solid rgba(77, 177, 239, 0.5);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ice);
  margin-bottom: 14px;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 8px var(--blue);
}

.hero-title {
  font-size: clamp(2.2rem, 4.6vw, 3.9rem);
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
  letter-spacing: 0.01em;
  line-height: 1.04;
}

.hero-title span {
  color: var(--blue);
}

.hero-subtitle {
  font-size: clamp(0.95rem, 1.4vw, 1.15rem);
  color: var(--mist);
  max-width: 620px;
  margin: 0;
  line-height: 1.55;
}

/* Search Card */
.search-card {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-xl);
  max-width: 1050px;
  margin: 0 auto;
  text-align: left;
  color: var(--text-main);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr auto;
  gap: 12px;
  align-items: flex-end;
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field-label svg {
  color: var(--primary-600);
}

.field-select,
.field-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-main);
  background: var(--surface-bg);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.field-select:focus,
.field-input:focus {
  border-color: var(--primary-600);
  background: var(--surface-card);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

.swap-action {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 6px;
}

.btn-swap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-bounce);
}

@media (hover: hover) {
  .btn-swap:hover {
    background: var(--primary-50);
    color: var(--primary-600);
    border-color: var(--primary-200);
    transform: rotate(180deg);
  }
}

.btn-search {
  height: 52px;
  padding: 0 28px;
  font-size: 1rem;
}

/* Quick Route Chips */
.quick-routes {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.chips-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.route-chip {
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-body);
  cursor: pointer;
  transition: all var(--transition-fast);
}

@media (hover: hover) {
  .route-chip:hover {
    background: var(--primary-50);
    border-color: var(--primary-200);
    color: var(--primary-700);
    transform: translateY(-1px);
  }
}

/* Features Bar */
.features-bar {
  background: var(--ink);
  border-top: 1px solid var(--surface-border);
  padding: 32px 0;
}

[data-theme="dark"] .features-bar {
  background: var(--surface-card);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.feature-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--blue);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-item h4 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 4px;
}

.feature-item p {
  font-size: 0.88rem;
  color: var(--mist);
  line-height: 1.4;
}

/* Search Results Section */
.results-section {
  padding: 28px 20px 56px;
  /* Qidiruvdan keyin shu joyga o'tilganda yopishqoq sarlavha ostida qolib ketmasin */
  scroll-margin-top: 84px;
}

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

.section-title {
  font-size: 2.1rem;
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.results-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.results-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-muted);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

/* Trips List & Cards */
.trips-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.trip-card {
  position: relative;
  overflow: hidden;
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--ticket-line);
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 2.5fr 1.5fr 1fr;
  align-items: center;
  gap: 24px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-normal);
}

/* Chipta kesiklari (yon tomonlarda yarim doira) */
.trip-card::before,
.trip-card::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 26px;
  height: 26px;
  margin-top: -13px;
  border-radius: 50%;
  background: var(--surface-bg);
  border: 1.5px solid var(--ticket-line);
}

.trip-card::before {
  left: -14px;
}

.trip-card::after {
  right: -14px;
}

@media (hover: hover) {
  .trip-card:hover {
    border-color: var(--primary-600);
    box-shadow: var(--shadow-md);
  }
}

.trip-route-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

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

.time-val {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.city-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-body);
}

.date-val {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.route-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 10px;
}

.duration-tag {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-line {
  position: relative;
  width: 100%;
  height: 2px;
  background: var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-line::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-600);
}

.line-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-border);
}

.line-dot.active {
  background: var(--primary-600);
}

.trip-bus-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 1px solid var(--surface-border);
  padding-left: 20px;
}

.bus-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-body);
}

.bus-plate {
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 700;
  background: #fff;
  color: var(--ink);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--ink);
}

.seats-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.seats-badge.in-stock {
  color: var(--accent-600);
}

.seats-badge.low-stock {
  color: var(--warning-600);
}

.seats-badge.no-stock {
  color: var(--danger-600);
}

.trip-action-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.trip-price {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.trip-price-currency {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--surface-border);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: var(--surface-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
}

.empty-title {
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 450px;
  margin: 0 auto 20px;
}

/* Skeletons */
.skeleton-card {
  height: 110px;
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface-border) 50%, var(--surface-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Modal Core Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 16, 45, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.modal-dialog {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 550px;
  /* auto: sig'sa vertikal markazda, sig'masa tepadan boshlanib sahifa aylanadi */
  margin: auto;
  position: relative;
  overflow: hidden;
  animation: modalIn var(--transition-normal);
}

.modal-dialog.modal-sm {
  max-width: 440px;
}

.modal-dialog.modal-lg {
  max-width: 960px;
}

.modal-dialog.modal-ticket {
  max-width: 760px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 24px 28px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--surface-border);
}

.modal-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary-600);
  background: var(--primary-50);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.modal-title {
  font-size: 1.4rem;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 0 4px;
  transition: color var(--transition-fast);
}

@media (hover: hover) {
  .btn-close:hover {
    color: var(--text-main);
  }
}

.modal-body {
  padding: 24px 28px 28px;
}

/* Forms in Modals */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background: var(--surface-bg);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--primary-600);
  background: var(--surface-card);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

/* Parol maydoni: ko'z tugmasi (js/password-toggle.js) */
.password-field {
  position: relative;
}

.password-field .form-control {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

@media (hover: hover) {
  .password-toggle:hover {
    color: var(--text-main);
  }
}

.password-toggle:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: -2px;
}

.form-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-success {
  padding: 10px 14px;
  background: var(--accent-50);
  border: 1px solid var(--accent-100);
  border-radius: var(--radius-md);
  color: var(--accent-600);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.auth-intro {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-link {
  display: block;
  margin: 14px auto 0;
  padding: 4px 8px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary-600);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  user-select: none;
}

.form-error {
  padding: 10px 14px;
  background: var(--danger-50);
  border: 1px solid var(--danger-100);
  border-radius: var(--radius-md);
  color: var(--danger-600);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: var(--radius-full);
  margin-bottom: 24px;
}

.auth-tab-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-tab-btn.active {
  background: var(--solid-bg);
  color: var(--solid-fg);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary-600);
  min-width: 300px;
  max-width: 450px;
  animation: toastSlideIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
  transition: all var(--transition-fast);
}

.toast.toast-success {
  border-left-color: var(--accent-600);
}

.toast.toast-error {
  border-left-color: var(--danger-600);
}

.toast.toast-warning {
  border-left-color: var(--warning-600);
}

.toast > svg {
  flex-shrink: 0;
  color: var(--primary-600);
}

.toast.toast-success > svg {
  color: var(--accent-600);
}

.toast.toast-error > svg {
  color: var(--danger-600);
}

.toast.toast-warning > svg {
  color: var(--warning-600);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

/* Responsive Media Queries */
@media (max-width: 992px) {
  .hero-section {
    padding: 36px 0 42px;
  }
  .hero-bus-backdrop {
    opacity: 0.55;
    background-position: 81% 55%;
  }
  .hero-text-wrap {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
  }
  .hero-title {
    text-align: center;
  }
  .hero-subtitle {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
  }
  .search-form {
    grid-template-columns: 1fr 1fr;
  }
  .swap-action {
    display: none;
  }
  .search-submit {
    grid-column: span 2;
  }
  .features-grid {
    grid-template-columns: 1fr;
  }
  .trip-card {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .trip-bus-meta {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--surface-border);
    padding-top: 14px;
  }
  .trip-action-box {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  /* Telefon: sarlavha bir qatorga sig'adi — ixcham qilinadi (aks holda sahifa kengayib, kichrayib ketadi) */
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
  .header-content {
    height: 60px;
    gap: 8px;
  }
  .brand-logo {
    gap: 8px;
    min-width: 0;
  }
  .brand-img {
    height: 30px;
  }
  .brand-tag {
    display: none;
  }
  .header-right {
    gap: 6px;
    min-width: 0;
  }
  .theme-toggle-btn {
    width: 34px;
    height: 34px;
  }
  .lang-btn {
    min-width: 26px;
    padding: 4px 6px;
    font-size: 0.7rem;
  }
  .auth-box {
    gap: 6px;
  }
  .auth-box .btn-sm {
    padding: 7px 12px;
    font-size: 0.82rem;
  }
  /* Ro'yxatdan o'tish — kirish oynasining ichidagi ikkinchi tabda; chiqish — profil sahifasida */
  #btn-open-register,
  #btn-logout,
  .user-badge-name,
  .badge-gear-icon {
    display: none;
  }
  .user-badge {
    padding: 6px;
  }
  .search-form {
    grid-template-columns: 1fr;
  }
  .search-submit {
    grid-column: span 1;
  }
  .hero-section {
    padding: 24px 0 32px;
  }
  .results-section {
    padding: 20px 12px 40px;
  }
  .trip-route-info {
    gap: 8px;
  }
  .time-box {
    min-width: 0;
  }
  .time-val {
    font-size: 1.55rem;
  }
  .city-val {
    font-size: 0.88rem;
  }
  .route-progress {
    min-width: 40px;
    padding: 0 4px;
  }
}

/* ==========================================================================
   Profile Modal & Settings Styles
   ========================================================================== */
.modal-dialog.modal-md {
  max-width: 560px;
}

.profile-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 22px;
  padding-bottom: 2px;
}

.profile-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

@media (hover: hover) {
  .profile-tab-btn:hover {
    color: var(--text-main);
  }
}

.profile-tab-btn.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
}

.profile-tab-pane {
  display: none;
}

.profile-tab-pane.active {
  display: block;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-stat-card {
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-fast);
}

@media (hover: hover) {
  .profile-stat-card[role="button"]:hover {
    border-color: var(--primary-400);
    background: var(--surface-card);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
  }
}

.profile-stat-card .stat-number {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-600);
  line-height: 1.1;
}

.profile-stat-card.success .stat-number {
  color: var(--accent-600);
}

.profile-stat-card .stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-link-hint {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary-600);
  margin-top: 6px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.profile-meta-note {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 10px 0;
  margin-bottom: 16px;
  border-top: 1px dashed var(--surface-border);
}

/* Theme Picker Cards */
.theme-picker-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-choice-card {
  display: block;
  cursor: pointer;
}

.theme-choice-card input {
  display: none;
}

.theme-card-content {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface-bg);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

@media (hover: hover) {
  .theme-choice-card:hover .theme-card-content {
    border-color: var(--primary-300);
  }
}

.theme-choice-card input:checked + .theme-card-content {
  border-color: var(--primary-600);
  background: var(--primary-50);
}

.theme-preview-box {
  width: 52px;
  height: 38px;
  border-radius: 6px;
  border: 1.5px solid var(--surface-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.preview-light { background: #f3f8fc; }
.preview-light .preview-header { height: 10px; background: #0554c6; }
.preview-light .preview-body { flex: 1; background: #ffffff; }

.preview-dark { background: #00102d; }
.preview-dark .preview-header { height: 10px; background: #4db1ef; }
.preview-dark .preview-body { flex: 1; background: #071c40; }

.preview-auto {
  background: linear-gradient(135deg, #ffffff 50%, #00102d 50%);
}
.preview-auto .preview-header { height: 10px; background: #0554c6; }
.preview-auto .preview-body { flex: 1; }

.theme-choice-label {
  display: flex;
  flex-direction: column;
}

.theme-choice-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.theme-choice-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Alohida sahifalar (joy tanlash, profil) va telefon uchun pastki navigatsiya
   ========================================================================== */
html {
  /* Kutilmagan gorizontal toshib ketish sahifani telefonda kichraytirib yubormasligi uchun */
  overflow-x: hidden;
}

.page-view {
  padding-top: 24px;
  padding-bottom: 48px;
}

.page-topbar {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}

.btn-back {
  padding-left: 8px;
}

.page-card {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.page-card-narrow {
  max-width: 720px;
  margin: 0 auto;
}

.page-card-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--surface-border);
}

.page-card-body {
  padding: 24px 28px 28px;
}

.profile-logout-row {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px dashed var(--surface-border);
}

/* "Tepaga" tugmasi: qidiruv sahifasida pastga aylantirilganda chiqadi (qidiruv formasiga qaytish uchun) */
.scroll-top-btn {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 105;
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(0, 16, 45, 0.28);
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

body[data-view="search"] .scroll-top-btn {
  display: flex;
}

body[data-view="search"] .scroll-top-btn.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Planshet va telefon: navigatsiya pastga (ilovalardagi kabi) tushadi */
@media (max-width: 992px) {
  .app-header {
    /* backdrop-filter ichidagi fixed elementlar uchun "ona" bo'lib qolardi — pastki navigatsiya buziladi */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--surface-card);
  }

  body {
    padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px));
  }

  .main-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 110;
    justify-content: space-around;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--surface-card);
    border-top: 1px solid var(--surface-border);
    box-shadow: 0 -4px 14px rgba(0, 16, 45, 0.1);
  }

  .nav-link {
    position: relative;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 6px 4px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    line-height: 1.2;
    text-align: center;
  }

  .nav-link .badge-counter {
    position: absolute;
    top: 0;
    left: calc(50% + 6px);
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    font-size: 0.65rem;
  }

  /* Joy tanlash sahifasida pastki navigatsiya yo'q: orqaga tugmasi bor, e'tibor bitta ishda */
  body[data-view="booking"] {
    padding-bottom: 0;
  }
  body[data-view="booking"] .main-nav {
    display: none;
  }

  .toast-container {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  /* Pastki navigatsiya ustida turadi */
  .scroll-top-btn {
    right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 640px) {
  .page-view {
    padding-top: 14px;
    padding-bottom: 28px;
  }
  .page-card {
    border-radius: var(--radius-lg);
  }
  .page-card-header {
    padding: 18px 16px 14px;
  }
  .page-card-body {
    padding: 16px;
  }
  .modal-title {
    font-size: 1.2rem;
  }
  /* Uchala tab ekranga sig'ishi uchun: teng kenglik, belgisiz */
  .profile-tabs {
    gap: 0;
  }
  .profile-tab-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 6px;
    font-size: 0.84rem;
  }
  .profile-tab-btn svg {
    display: none;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .seat-legend {
    gap: 12px;
    padding: 8px 10px;
    flex-wrap: wrap;
  }
}

/* Sublimation uslubi: ixcham kondensirlangan shrift, KATTA HARFLAR (tugma, tab, navigatsiya) */
.nav-link,
.tab-btn,
.profile-tab-btn,
.auth-tab-btn {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

@media (min-width: 993px) {
  .nav-link {
    font-size: 1.05rem;
  }
}

.tab-btn,
.profile-tab-btn,
.auth-tab-btn {
  font-size: 1rem;
}

@media (max-width: 640px) {
  .hero-section::before,
  .hero-section::after {
    display: none;
  }

  .trip-card {
    padding: 20px 22px;
  }

  .btn-search {
    width: 100%;
  }
}

/* Tor telefonda sarlavhaga keng logotip sig'maydi — faqat "e" belgisi */
@media (max-width: 480px) {
  .brand-wide {
    display: none !important;
  }

  .brand-mark {
    display: block;
  }
}
