/* Desktop Active Selection Container */
.vv-active-selection-container {
  position: absolute;
  top: 10px;
  left: 420px;
  right: 90px; /* sit just to the left of the recharge button control */
  display: flex;
  flex-direction: row;
  gap: 10px;
  overflow: hidden; /* Prevent side scrolling */
  z-index: 1000;
  pointer-events: none; /* Allow clicking the map between gaps */
  box-sizing: border-box;
}

/* Desktop Active Selection Bar */
.vv-active-selection-bar {
  flex: 1; /* Distribute space equally when multiple are present */
  min-width: 0; /* Allow shrinking below content size so they fit without scrolling */
  min-height: 46px;
  height: 46px;
  background: white;
  border: 3px solid rgba(51, 51, 51, 0.35);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  padding: 4px 12px;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, flex-basis 0.3s ease;
  transform: translateY(-20px);
  opacity: 0;
  pointer-events: none;
  container-type: inline-size; /* enable per-bar width queries for the share button */
  container-name: vvbar;
}

.vv-active-selection-bar.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* If there is only 1 route, restrict its width to ~30% of the available space */
.vv-active-selection-bar:first-child:last-child {
  flex: none;
  width: 30%;
  max-width: 400px; /* Match search container width on large screens */
  min-width: 280px; /* Ensure readability */
}

/* Route Badge (Common) */
.vv-selection-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
  background-color: #2563EB; /* fallback */
  padding: 3px 8px;
  border-radius: 6px;
  margin-right: 12px;
  min-width: 24px;
  height: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

/* Route Name (Common) */
.vv-selection-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  margin-right: 12px;
}

/* Share Button (Common) */
.vv-selection-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border: 1px solid rgba(0, 0, 0, 0.05);
  color: #111827; /* Darker text for stronger look */
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600; /* Bolder weight */
  cursor: pointer;
  margin-right: 8px;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.vv-selection-share-btn:hover {
  background: #e5e7eb;
  color: #000000;
}

.vv-selection-share-btn svg {
  margin-right: 4px;
  flex-shrink: 0;
}

/* When a bar gets crowded (many routes and/or a narrow device), collapse the
   share button to its icon only so the route name keeps as much room as possible. */
@container vvbar (max-width: 280px) {
  .vv-selection-share-btn {
    padding: 6px 8px;
  }
  .vv-selection-share-btn span {
    display: none;
  }
  .vv-selection-share-btn svg {
    margin-right: 0;
  }
}

/* Close (X) Button (Common) */
.vv-selection-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #374151; /* Darker gray for stronger look (was #9ca3af) */
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.vv-selection-close-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

/* Badge Row for multiple selections */
.vv-selection-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  flex-shrink: 0;
}

/* Individual Route Chip */
.vv-selection-chip {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
  padding: 3px 6px 3px 8px;
  border-radius: 6px;
  height: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
}

.vv-selection-chip-num {
  margin-right: 4px;
  line-height: 1;
}

/* Chip Close (✕) Button */
.vv-selection-chip-remove {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.vv-selection-chip-remove:hover {
  background: rgba(255, 255, 255, 0.4);
  color: #fff;
}

/* Mobile Floating Capsule Pill */
.vv-mobile-selection-pill {
  position: absolute;
  bottom: calc(var(--vv-bottom-nav-height, 64px) + 14px); /* above the bottom nav */
  left: 50%;
  transform: translate(-50%, 100px);
  min-height: 48px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 9999px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 4px 6px 4px 14px;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  width: calc(100vw - 32px);
  max-width: 360px;
  opacity: 0;
  pointer-events: none;
}

.vv-mobile-selection-pill.open {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}

.vv-mobile-selection-pill .vv-selection-name {
  max-width: 160px;
  margin-right: 8px;
}

.vv-mobile-selection-pill .vv-selection-share-btn {
  padding: 6px 10px;
  margin-right: 4px;
}

/* Send pill to background when any bottom sheet is open */
body.vv-sheet-open .vv-mobile-selection-pill {
  z-index: 35; /* below backdrop (40) and sheet (45) */
}

/* Hide pill entirely on Favoritos and Tarjeta tabs (persists through sheet collapse) */
body.vv-tab-overlay .vv-mobile-selection-pill {
  display: none !important;
}

/* Responsive display toggle */
@media (min-width: 768px) {
  .vv-mobile-selection-pill {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .vv-active-selection-bar {
    display: none !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .vv-active-selection-bar {
    background: #2a2a2a;
    border-color: rgba(51, 51, 51, 0.35);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  .vv-selection-name {
    color: #f0f0f0;
  }
  
  .vv-selection-share-btn {
    background: #3a3a3a;
    color: #f0f0f0;
  }
  
  .vv-selection-share-btn:hover {
    background: #4a4a4a;
    color: #ffffff;
  }
  
  .vv-selection-close-btn {
    color: #a3a3a3;
  }
  
  .vv-selection-close-btn:hover {
    background: #3a3a3a;
    color: #ffffff;
  }

  .vv-mobile-selection-pill {
    background: rgba(42, 42, 42, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  }
}
