/* Origin-Destination Planner Styles */

/* --- Control button (top-right, 4th in the stack: below Rutas IE-TRAM) --- */
.vv-od-control {
  position: fixed !important;
  top: calc(
    10px +
    (clamp(50px, 8vw, 70px) * 3) +
    (clamp(12px, 1.5vw, 20px) * 3)
  );
  right: 10px;
  margin: 0 !important;
  z-index: 1;
  transition: all 0.3s ease;
  border-radius: 16px !important;
  overflow: hidden;
}

@media (min-width: 768px) {
  .vv-od-control {
    top: calc(
      10px +
      (clamp(50px, 5vw, 64px) * 3) +
      (clamp(12px, 1.4vw, 18px) * 3)
    );
    right: 10px;
  }
}

@media (min-width: 1200px) {
  .vv-od-control {
    top: calc(
      10px +
      (clamp(54px, 4.5vw, 72px) * 3) +
      (clamp(14px, 1vw, 20px) * 3)
    );
    right: 10px;
  }
}

/* Hidden on mobile/tablet — mobile uses the Menú sidebar instead */
@media (max-width: 767px) {
  .vv-od-control {
    display: none !important;
  }
}

.vv-od-button {
  min-width: 60px;
  min-height: 60px;
  width: clamp(50px, 8vw, 70px);
  height: clamp(50px, 8vw, 70px);
  border: 3px solid rgba(51, 51, 51, 0.35);
  background: white;
  color: #333;
  cursor: pointer;
  border-radius: 16px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.vv-od-button svg {
  display: block;
  width: 60%;
  height: 60%;
  margin: auto;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .vv-od-button {
    min-width: 52px;
    min-height: 52px;
    width: clamp(50px, 5vw, 64px);
    height: clamp(50px, 5vw, 64px);
  }

  /* Larger icon on desktop */
  .vv-od-button svg {
    width: 60%;
    height: 60%;
  }
}

@media (min-width: 1200px) {
  .vv-od-button {
    min-width: 58px;
    min-height: 58px;
    width: clamp(54px, 4.5vw, 72px);
    height: clamp(54px, 4.5vw, 72px);
  }
}

.vv-od-button.active {
  background: #2563EB;
  border-color: #2563EB;
  color: white;
}

@media (hover: hover) and (pointer: fine) {
  .vv-od-button:hover {
    background: white;
    border-color: #2563EB;
    color: #2563EB;
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
  }
  .vv-od-button.active:hover {
    background: white;
    border-color: #2563EB;
    color: #333;
  }
}

.vv-od-button:focus {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
}
.vv-od-button:focus:not(:focus-visible) {
  outline: none;
}

/* --- Planner panel: styled like the search bar and sitting in its slot --- */
/* While the planner is open, hide the search bar (the planner replaces it). */
body.vv-od-open .vv-search-container {
  display: none !important;
}

.vv-od-panel {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  width: 400px; /* match the search container */
  max-width: calc(100vw - 20px);
  z-index: 1000;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.vv-od-panel.open {
  display: block;
  animation: vvOdSlideIn 0.2s ease;
}

@keyframes vvOdSlideIn {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Mobile: full-width, capped height so it doesn't hide behind the bottom nav */
@media (max-width: 767px) {
  .vv-od-panel {
    width: calc(100vw - 20px);
    max-width: 100%;
    max-height: calc(100vh - 20px - env(safe-area-inset-top, 0px));
    overflow-y: auto;
  }
}
@media (max-width: 360px) {
  .vv-od-panel {
    left: 8px;
    width: calc(100vw - 16px);
  }
}

/* The white rounded box — mirrors .vv-search-shell */
.vv-od-shell {
  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);
  padding: 10px 12px 12px;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.vv-od-shell:focus-within {
  border-color: #2563EB;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.2);
}

.vv-od-shell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.vv-od-title {
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
}

.vv-od-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #6b7280;
  transition: background 0.2s ease, color 0.2s ease;
}
.vv-od-panel-close:hover {
  background: #f3f4f6;
  color: #111827;
}

/* --- Origin / Destination fields --- */
.vv-od-field {
  position: relative;
  margin-bottom: 8px;
}

.vv-od-field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
}

/* Colored dot before the label echoes the origin (green) / dest (red) markers */
.vv-od-field .vv-od-field-label::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.vv-od-field[data-mode="origin"] .vv-od-field-label::before { background: #16a34a; }
.vv-od-field[data-mode="dest"] .vv-od-field-label::before { background: #dc2626; }

.vv-od-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vv-od-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px; /* prevent iOS zoom, like the search input */
  color: #111827;
  background: white;
  box-sizing: border-box;
  transition: border-color 0.2s ease;
}
@media (min-width: 768px) {
  .vv-od-input { height: 40px; font-size: 15px; }
}
.vv-od-input:focus {
  outline: none;
  border-color: #2563EB;
}
.vv-od-input::placeholder { color: #9ca3af; }

.vv-od-icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 2px solid #e5e7eb;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  transition: all 0.2s ease;
}
@media (min-width: 768px) {
  .vv-od-icon-btn { width: 40px; height: 40px; }
}
.vv-od-icon-btn:hover {
  border-color: #2563EB;
  color: #2563EB;
  transform: translateY(-1px);
}
.vv-od-field[data-mode="origin"] .vv-od-pin-btn { color: #16a34a; }
.vv-od-field[data-mode="dest"] .vv-od-pin-btn { color: #dc2626; }

/* --- Place search suggestions dropdown --- */
.vv-od-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  z-index: 10;
  max-height: 220px;
  overflow-y: auto;
}
.vv-od-suggestion {
  padding: 10px 12px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vv-od-suggestion:hover,
.vv-od-suggestion.is-active {
  background: #eff6ff;
  color: #1d4ed8;
}
.vv-od-suggestion-empty {
  padding: 10px 12px;
  font-size: 13px;
  color: #9ca3af;
}

/* --- Hint while placing a pin --- */
.vv-od-hint {
  margin: 8px 0;
  padding: 8px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  color: #1d4ed8;
}

/* --- Actions --- */
.vv-od-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0 0;
}

.vv-od-search-btn,
.vv-od-clear-btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid;
}

.vv-od-search-btn {
  flex: 1;
  background: #2563EB;
  border-color: #2563EB;
  color: white;
}
.vv-od-search-btn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.vv-od-clear-btn {
  background: white;
  border-color: #e5e7eb;
  color: #374151;
}
.vv-od-clear-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

/* --- Results dropdown (sits below the shell, like .vv-search-results) --- */
.vv-od-results-panel {
  margin-top: 8px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  max-height: 50vh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

.vv-od-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vv-od-results-msg {
  margin: 4px 0;
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
}

.vv-od-section-label {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  margin-top: 8px;
}

.vv-od-result-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  background: #f9fafb;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.vv-od-itinerary {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.vv-od-walk-step {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
}

.vv-od-step-arrow {
  color: #9ca3af;
  font-size: 12px;
}
.vv-od-result-card:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.vv-od-result-card.is-active {
  background: #eff6ff;
  border-color: #2563EB;
}

.vv-od-route-badge {
  flex-shrink: 0;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2563EB; /* fallback; overridden inline with the route color */
  color: white;
  font-weight: 700;
  font-size: 12px;
  border-radius: 6px;
  /* Keep the number legible on any route color */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.vv-od-transfer-arrow {
  flex-shrink: 0;
  color: #6b7280;
  font-size: 16px;
  font-weight: 700;
}

/* --- Disclaimer --- */
.vv-od-disclaimer {
  margin: 14px 0 0;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.4;
}

/* --- Planned route bar (top band, right of the search bar) --- */
/* While a planned route is shown, hide the per-route selection bars so they
   don't overlap in the same band. */
body.vv-od-planned-active .vv-active-selection-container {
  display: none !important;
}

.vv-planned-route-container {
  position: absolute;
  top: 10px;
  left: 420px; /* just right of the search bar / planner */
  right: 90px; /* sit to the left of the recharge button control */
  display: flex;
  z-index: 1000;
  pointer-events: none;
  box-sizing: border-box;
}

.vv-planned-route-bar {
  flex: 0 1 auto; /* size to content, shrink only if it would overflow the band */
  min-width: 0;
  max-width: 100%;
  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;
  gap: 10px;
  padding: 4px 12px;
  box-sizing: border-box;
  transform: translateY(-20px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  pointer-events: none;
}

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

.vv-planned-itinerary {
  flex: 0 1 auto; /* size to content (not flex-basis:0, which would collapse it) */
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.vv-planned-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border: 1px solid rgba(0, 0, 0, 0.05);
  color: #111827;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.vv-planned-share-btn:hover {
  background: #e5e7eb;
  color: #000000;
}
.vv-planned-share-btn svg {
  margin-right: 4px;
  flex-shrink: 0;
}

.vv-planned-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #374151;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.vv-planned-close-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

/* Desktop-only band, like the active selection bars */
@media (max-width: 767px) {
  .vv-planned-route-container {
    display: none !important;
  }
}

/* --- Dark mode --- */
@media (prefers-color-scheme: dark) {
  .vv-od-button {
    background: #2a2a2a;
    border-color: rgba(240, 240, 240, 0.38);
    color: #f0f0f0;
  }
  .vv-od-button.active {
    background: #2563EB;
    border-color: #2563EB;
    color: white;
  }
  .vv-od-panel { color: #f0f0f0; }
  .vv-od-shell {
    background: #2a2a2a;
    border-color: rgba(240, 240, 240, 0.38);
  }
  .vv-od-results-panel {
    background: #1f1f1f;
    border-color: #3a3a3a;
  }
  .vv-od-title { color: #9ca3af; }
  .vv-od-panel-close { color: #9ca3af; }
  .vv-od-panel-close:hover { background: #2a2a2a; color: #f0f0f0; }
  .vv-od-icon-btn { background: #2a2a2a; border-color: #3a3a3a; color: #f0f0f0; }
  .vv-od-input {
    background: #2a2a2a;
    border-color: #3a3a3a;
    color: #f0f0f0;
  }
  .vv-od-suggestions {
    background: #1f1f1f;
    border-color: #3a3a3a;
  }
  .vv-od-suggestion { color: #f0f0f0; }
  .vv-od-suggestion:hover,
  .vv-od-suggestion.is-active { background: #1e3a5f; color: #93c5fd; }
  .vv-od-result-card { background: #2a2a2a; }
  .vv-od-result-card:hover { background: #1e3a5f; border-color: #2563EB; }
  .vv-od-clear-btn { background: #2a2a2a; border-color: #3a3a3a; color: #f0f0f0; }
  .vv-planned-route-bar {
    background: #2a2a2a;
    border-color: rgba(240, 240, 240, 0.38);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  .vv-planned-share-btn { background: #3a3a3a; color: #f0f0f0; }
  .vv-planned-share-btn:hover { background: #4a4a4a; color: #ffffff; }
  .vv-planned-close-btn { color: #a3a3a3; }
  .vv-planned-close-btn:hover { background: #3a3a3a; color: #ffffff; }
}
