/**
 * Routenplaner – Stationswechsel (Alternativen-Karussell + Sticky-Leiste)
 * Pfad: /pages/route-planner/assets/route-station-swap.css
 * Eingebunden von: pages/route-planner/route-planner.php
 * Gehört zu: pages/route-planner/assets/route-station-swap.js
 */

/* ---------- Overflow-Fix ----------
   Flex-Items haben default min-width:auto → das Karussell würde die
   Stopp-Karte (und damit die ganze Seite) in die Breite drücken.
   min-width:0 erlaubt dem Detail-Bereich zu schrumpfen, sodass das
   Karussell intern scrollt statt die Seite zu verbreitern. */

[data-charging-stop-card] .flex-1 {
  min-width: 0;
}

/* Der Ladestopps-Tab scrollt vertikal (overflow-y:auto) – horizontales
   Scrollen der ganzen Liste unterbinden, es scrollt nur das Karussell. */
#tab-content-charging-stations {
  overflow-x: hidden;
}

.swap-panel {
  max-width: 100%;
  overflow: hidden;
}

/* ---------- Panel ---------- */

.swap-panel-info {
  font-size: 0.8125rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.swap-panel-info--warn {
  color: #92400e;
  background: #fef3c7;
  border-radius: 0.375rem;
  padding: 0.375rem 0.625rem;
}

/* ---------- Button „Andere Station wählen" ----------
   Auffälliger Pill-Button mit sanftem Puls-Ring, damit die Funktion
   nicht übersehen wird. Puls stoppt, sobald das Panel geöffnet ist. */

.swap-alternatives-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border: 1.5px solid #2563eb;
  border-radius: 9999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease, box-shadow 0.15s ease;
  animation: swap-btn-pulse 2.4s ease-in-out infinite;
}

.swap-alternatives-btn:hover {
  background: #2563eb;
  color: #fff;
  animation: none;
}

/* Panel geöffnet → Aufmerksamkeit erreicht, Puls beenden + gefüllter Zustand */
.swap-alternatives-btn[aria-expanded="true"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  animation: none;
}

.swap-btn-caret {
  font-size: 0.7rem;
  line-height: 1;
}

@keyframes swap-btn-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.35);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(37, 99, 235, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .swap-alternatives-btn {
    animation: none;
  }
}

/* ---------- Schnellfilter: Segmented Control + Favoriten-Toggle ---------- */

.swap-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

/* Verbundene Button-Gruppe (iOS-/Material-Stil) für die Sortierung */
.swap-segmented {
  display: inline-flex;
  align-items: stretch;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.1875rem;
  gap: 0.125rem;
}

.swap-segment {
  padding: 0.3125rem 0.75rem;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: #4b5563;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.swap-segment:hover {
  color: #111827;
}

.swap-segment--active {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Favoriten-Filter: eigenständiger Toggle rechts neben der Sortierung */
.swap-fav-toggle {
  padding: 0.375rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #fff;
  color: #4b5563;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.swap-fav-toggle:hover {
  border-color: #fbbf24;
  color: #92400e;
}

.swap-fav-toggle--active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.swap-panel-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #6b7280;
  padding: 0.75rem 0;
}

.swap-panel-error {
  font-size: 0.875rem;
  color: #b91c1c;
  padding: 0.5rem 0;
}

.swap-retry-btn {
  margin-left: 0.5rem;
  color: #2563eb;
  font-weight: 600;
  text-decoration: underline;
}

.swap-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid #d1d5db;
  border-top-color: #2563eb;
  border-radius: 9999px;
  animation: swap-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes swap-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Karussell ---------- */

.swap-carousel-wrap {
  position: relative;
  max-width: 100%;
}

.swap-carousel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.25rem 0.125rem 0.625rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Pfeil-Navigation (Desktop) */
.swap-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  color: #374151;
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.swap-arrow:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.swap-arrow--left {
  left: -0.5rem;
}

.swap-arrow--right {
  right: -0.5rem;
}

.swap-arrow--hidden {
  opacity: 0;
  pointer-events: none;
}

/* Mobil: Wischen ist natürlicher als Pfeile */
@media (max-width: 640px) {
  .swap-arrow {
    display: none;
  }
}

.swap-carousel::-webkit-scrollbar {
  height: 6px;
}

.swap-carousel::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.swap-carousel::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Karten ---------- */

.swap-card {
  position: relative;
  flex: 0 0 200px;
  width: 200px;
  display: flex;
  flex-direction: column;
  text-align: left;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 0.625rem;
  overflow: hidden;
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.swap-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.swap-card--selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.swap-card--current.swap-card--selected {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.swap-card-badges {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  right: 0.375rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  z-index: 2;
}

.swap-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
}

.swap-badge--current {
  background: #059669;
  color: #fff;
}

.swap-badge--fav {
  background: #fef3c7;
  color: #92400e;
}

.swap-badge--open {
  background: #dbeafe;
  color: #1e40af;
}

.swap-card-img {
  width: 100%;
  height: 84px;
  object-fit: cover;
  background: #f3f4f6;
  display: block;
}

.swap-card-img--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #9ca3af;
}

.swap-card-body {
  padding: 0.5rem 0.625rem 0.375rem;
  flex: 1;
}

.swap-card-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.swap-card-operator {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swap-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #374151;
  margin-top: 0.375rem;
}

.swap-card-rating {
  color: #d97706;
  font-weight: 600;
}

.swap-card-distance {
  font-size: 0.75rem;
  font-weight: 600;
  color: #ea580c;
  margin-top: 0.25rem;
}

.swap-card-distance--current {
  color: #059669;
}

.swap-card-check {
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  background: #f9fafb;
  color: #2563eb;
  border-top: 1px solid #f3f4f6;
}

.swap-card--selected .swap-card-check {
  background: #2563eb;
  color: #fff;
}

.swap-card--current.swap-card--selected .swap-card-check {
  background: #059669;
}

/* ---------- Stopp-Karte mit vorgemerktem Tausch ---------- */

.swap-stop--pending {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.swap-selected-hint {
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.375rem;
  padding: 0.375rem 0.625rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

/* Mini-Vorschaubild der gewählten Ersatz-Station im Hinweis */
.swap-selected-hint-img {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.25rem;
  object-fit: cover;
  border: 1px solid #bfdbfe;
  flex-shrink: 0;
}

/* ---------- Sticky-Leiste „Route aktualisieren" ---------- */

.swap-update-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: #111827;
  color: #fff;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.25);
  animation: swap-bar-in 0.25s ease;
}

@keyframes swap-bar-in {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.swap-update-bar-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}

.swap-update-bar-text {
  font-size: 0.875rem;
  font-weight: 600;
}

.swap-update-bar-actions {
  display: flex;
  gap: 0.5rem;
}

.swap-bar-btn {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.swap-bar-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.swap-bar-btn--primary {
  background: #2563eb;
  color: #fff;
}

.swap-bar-btn--primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.swap-bar-btn--secondary {
  background: transparent;
  color: #d1d5db;
  border: 1px solid #4b5563;
}

.swap-bar-btn--secondary:hover {
  color: #fff;
  border-color: #9ca3af;
}

/* Mobil: Buttons volle Breite */
@media (max-width: 480px) {
  .swap-update-bar-actions {
    width: 100%;
  }

  .swap-bar-btn {
    flex: 1;
  }
}
