/* ============================================================
   COMPONENTS — Berlin Live Transit
   ============================================================ */

/* ============================
   APP HEADER
   ============================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  background: hsl(220, 20%, 7%, 0.85);
  border-bottom: 1px solid var(--border-subtle);
}

.app-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-primary);
  transition: opacity var(--duration-fast);
}

.app-logo:hover {
  opacity: 0.8;
  text-decoration: none;
}

.app-logo-mark {
  width: 36px;
  height: 36px;
  background: var(--color-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--color-accent-glow);
}

.app-logo-mark svg {
  width: 20px;
  height: 20px;
  fill: var(--text-inverse);
}

.app-logo-text {
  display: flex;
  flex-direction: column;
}

.app-logo-title {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.app-logo-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Language toggle */
.lang-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  transition: background var(--duration-fast), color var(--duration-fast);
  color: var(--text-muted);
}

.lang-btn.active {
  background: var(--color-accent);
  color: var(--text-inverse);
}

.lang-btn:hover:not(.active) {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

/* ============================
   MAIN CONTENT
   ============================ */
.app-main {
  flex: 1;
  padding-block: var(--space-8) var(--space-16);
}

/* ============================
   HERO SECTION
   ============================ */
.hero {
  text-align: center;
  padding-block: var(--space-10) var(--space-8);
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-4);
}

.hero-eyebrow::before,
.hero-eyebrow::after {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--color-accent);
  opacity: 0.5;
}

.hero-title {
  font-size: clamp(var(--text-3xl), 6vw, var(--text-4xl));
  font-weight: var(--weight-black);
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

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

.hero-subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 420px;
  margin-inline: auto;
  line-height: var(--leading-normal);
}

/* ============================
   SEARCH BAR
   ============================ */
.search-section {
  margin-bottom: var(--space-6);
}

.search-wrapper {
  position: relative;
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  transition:
    border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out),
    background var(--duration-base);
}

.search-input-group:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
  background: var(--bg-elevated);
}

.search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--duration-fast);
  width: 20px;
  height: 20px;
}

.search-input-group:focus-within .search-icon {
  color: var(--color-accent);
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  caret-color: var(--color-accent);
}

/* Hide native webkit search clear button */
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

.search-input::placeholder {
  color: var(--text-muted);
  font-weight: var(--weight-normal);
}

.search-clear {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--duration-fast), color var(--duration-fast);
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast);
}

.search-clear.visible {
  opacity: 1;
  pointer-events: auto;
}

.search-clear:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

/* ── Dropdown ── */
.search-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideDown var(--duration-base) var(--ease-out);
}

.search-dropdown:not(.visible) {
  display: none;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--duration-fast);
  border-bottom: 1px solid var(--border-subtle);
}

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

.dropdown-item:hover,
.dropdown-item.focused {
  background: var(--bg-glass-hover);
}

.dropdown-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
  color: white;
}

.dropdown-item-info {
  flex: 1;
  min-width: 0;
}

.dropdown-item-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-item-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 1px;
}

.dropdown-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.dropdown-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ── Nearby button ── */
.nearby-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  transition:
    background var(--duration-fast),
    border-color var(--duration-fast),
    color var(--duration-fast);
}

.nearby-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.nearby-btn svg {
  color: var(--color-accent);
  flex-shrink: 0;
}

/* ============================
   QUICK ACTIONS (Favorites)
   ============================ */
.quick-section {
  margin-bottom: var(--space-6);
}

.section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  padding-left: var(--space-1);
}

/* ============================
   STOP CARD
   ============================ */
.stop-cards-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stop-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition:
    background var(--duration-fast),
    border-color var(--duration-fast),
    transform var(--duration-fast);
  text-align: left;
  width: 100%;
}

.stop-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-default);
  transform: translateY(-1px);
}

.stop-card:active {
  transform: translateY(0);
}

.stop-card-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.stop-card-info {
  flex: 1;
  min-width: 0;
}

.stop-card-name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  flex-wrap: wrap;
}

.stop-card-distance {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.mode-badges {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.mode-badge {
  font-size: 9px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.mode-badge.ubahn   { background: hsl(219, 52%, 48%, 0.2); border-color: hsl(219, 52%, 48%, 0.4); color: hsl(219, 70%, 70%); }
.mode-badge.sbahn   { background: hsl(142, 68%, 40%, 0.2); border-color: hsl(142, 68%, 40%, 0.4); color: hsl(142, 70%, 60%); }
.mode-badge.bus     { background: hsl(349, 72%, 50%, 0.2); border-color: hsl(349, 72%, 50%, 0.4); color: hsl(349, 70%, 70%); }
.mode-badge.tram    { background: hsl(349, 72%, 50%, 0.2); border-color: hsl(349, 72%, 50%, 0.4); color: hsl(349, 70%, 70%); }
.mode-badge.ferry   { background: hsl(210, 80%, 50%, 0.2); border-color: hsl(210, 80%, 50%, 0.4); color: hsl(210, 80%, 70%); }
.mode-badge.express { background: hsl(262, 50%, 55%, 0.2); border-color: hsl(262, 50%, 55%, 0.4); color: hsl(262, 70%, 75%); }

.stop-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ── Favourite star ── */
.fav-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--duration-fast), background var(--duration-fast);
}

.fav-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--color-accent);
}

.fav-btn.active {
  color: var(--color-accent);
  animation: bounceIn var(--duration-slow) var(--ease-spring);
}

.fav-btn svg {
  width: 18px;
  height: 18px;
  transition: fill var(--duration-fast);
}

.fav-btn.active svg { fill: var(--color-accent); }

/* ============================
   DEPARTURE BOARD
   ============================ */
.board-section {
  margin-top: var(--space-2);
}

.board-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.board-stop-name {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.025em;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

.board-stop-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  flex-wrap: wrap;
}

.board-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Refresh button */
.refresh-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: background var(--duration-fast), color var(--duration-fast), transform var(--duration-base);
}

.refresh-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.refresh-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

/* Real-time badge */
.realtime-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: 3px var(--space-2);
  border-radius: var(--radius-full);
  background: hsl(142, 70%, 45%, 0.15);
  border: 1px solid hsl(142, 70%, 45%, 0.3);
  color: hsl(142, 70%, 60%);
}

.realtime-badge.stale {
  background: hsl(38, 95%, 55%, 0.15);
  border-color: hsl(38, 95%, 55%, 0.3);
  color: hsl(38, 95%, 65%);
}

.realtime-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  animation: pulseDot 2s ease-in-out infinite;
}

/* Last updated */
.last-updated {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Departure list ── */
.departure-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ── Departure item ── */
.departure-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: background var(--duration-fast), border-color var(--duration-fast);
}

.departure-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-default);
}

.departure-item.cancelled {
  opacity: 0.5;
  background: hsl(4, 80%, 58%, 0.05);
  border-color: hsl(4, 80%, 58%, 0.2);
}

/* Line badge */
.line-badge {
  min-width: 48px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  letter-spacing: -0.01em;
  color: white;
  padding-inline: var(--space-2);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Direction & platform */
.departure-info {
  min-width: 0;
}

.departure-direction {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.departure-cancelled-label {
  font-size: var(--text-xs);
  color: var(--color-danger);
  font-weight: var(--weight-semibold);
  margin-top: 2px;
}

.departure-platform {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Countdown */
.departure-countdown {
  text-align: right;
  flex-shrink: 0;
}

.countdown-value {
  font-size: var(--text-xl);
  font-weight: var(--weight-black);
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1;
}

.countdown-value.now {
  color: var(--color-accent);
  font-size: var(--text-lg);
}

.countdown-unit {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
}

/* Delay badge */
.delay-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  margin-top: var(--space-1);
  white-space: nowrap;
}

.delay-badge.ontime {
  background: hsl(142, 70%, 45%, 0.15);
  color: hsl(142, 70%, 60%);
}

.delay-badge.slight {
  background: hsl(38, 95%, 55%, 0.15);
  color: hsl(38, 95%, 65%);
}

.delay-badge.late {
  background: hsl(4, 80%, 58%, 0.15);
  color: hsl(4, 80%, 70%);
}

/* ── Mode group divider ── */
.mode-group-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.mode-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ============================
   DISRUPTION BANNER
   ============================ */
.disruption-banner {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  background: hsl(38, 95%, 55%, 0.08);
  border: 1px solid hsl(38, 95%, 55%, 0.25);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  animation: fadeInUp var(--duration-slow) var(--ease-out);
}

.disruption-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
  line-height: 1.3;
}

.disruption-content {
  flex: 1;
  min-width: 0;
}

.disruption-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: hsl(38, 95%, 70%);
  margin-bottom: var(--space-1);
}

.disruption-text {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}

/* ============================
   EMPTY / ERROR STATES
   ============================ */
.state-container {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  animation: fadeIn var(--duration-slow) var(--ease-out);
}

.state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  line-height: 1;
}

.state-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.state-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 300px;
  margin-inline: auto;
  line-height: var(--leading-normal);
}

/* ── Skeleton board ── */
.skeleton-board {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-item {
  height: 68px;
  border-radius: var(--radius-lg);
}

/* ============================
   APP FOOTER
   ============================ */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  padding-block: var(--space-6);
  margin-top: auto;
}

.app-footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

.footer-attribution {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

.footer-attribution a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-disclaimer {
  font-size: var(--text-xs);
  color: var(--text-muted);
  max-width: 480px;
  line-height: var(--leading-normal);
}

.footer-links {
  display: flex;
  gap: var(--space-4);
}

.footer-links a {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--text-secondary);
}

/* ============================
   BACK BUTTON
   ============================ */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.back-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  text-decoration: none;
}

/* ============================
   RESPONSIVE
   ============================ */
/* ============================
   JOURNEY ROUTING
   ============================ */

.journey-form {
  margin-bottom: var(--space-6);
}

.journey-inputs {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-2) var(--space-4);
}

.journey-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-accent);
  color: #000;
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: transform var(--duration-fast), filter var(--duration-fast);
  box-shadow: 0 4px 12px rgba(255, 204, 0, 0.2);
}

.journey-search-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

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

.journey-input-row {
  position: relative;
}

.journey-input-row .search-input-group {
  border: none !important;
  background: none !important;
  box-shadow: none !important;
  padding-inline: 0;
  padding-block: var(--space-3);
}

.journey-input-row .search-dropdown {
  left: -1rem;
  right: -1rem;
  width: auto;
}

.journey-swap-row {
  position: relative;
  height: 1px;
  display: flex;
  align-items: center;
}

.journey-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-subtle);
}

.swap-btn {
  position: absolute;
  right: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  z-index: 10;
  transition: all var(--duration-fast);
}

.swap-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.journey-card {
  animation: fadeInUp var(--duration-slow) var(--ease-out);
}
.journey-card:hover .journey-card-header {
  background: var(--bg-elevated) !important;
}

@media (max-width: 480px) {
  .hero-title { font-size: var(--text-3xl); }
  .hero-subtitle { font-size: var(--text-sm); }

  .departure-item {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
  }

  .departure-countdown {
    grid-row: 1;
    grid-column: 3;
  }

  .app-logo-sub { display: none; }
}
