/* Trip Planner — sidebar + map (extends search route card styles) */

body#trip-planner-page {
  font-family: "Open Sans", sans-serif;
  margin: 0;
  color: #2d2d31;
}

body#trip-planner-page .map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  z-index: 0;
}

body.trip-planner-embed .map {
  position: fixed;
  inset: 0;
  height: 100vh;
}

.trip-overlay-section {
  position: fixed;
  top: 70px;
  left: 16px;
  width: min(420px, 36vw);
  min-width: 300px;
  max-height: calc(100vh - 90px);
  z-index: 1000;
  pointer-events: none;
}

.trip-container {
  pointer-events: auto;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 20px;
  padding: 18px 16px 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.14), 0 0 0 1px rgba(15, 23, 42, 0.06);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.trip-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.trip-back-btn {
  border: none;
  background: #f1f5f9;
  color: #b30738;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.trip-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.trip-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: #64748b;
  line-height: 1.45;
}

.trip-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 6px;
}

.trip-name-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 14px;
  background: #fff;
}

.trip-name-input:focus {
  outline: none;
  border-color: #b30738;
  box-shadow: 0 0 0 3px rgba(179, 7, 56, 0.12);
}

.trip-stops-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.trip-start-hint {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
}

.trip-stops-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.trip-stop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 6px 8px 6px 4px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
}

.trip-stop-row.is-dragging {
  opacity: 0.55;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.trip-drag-handle {
  border: none;
  background: transparent;
  color: #94a3b8;
  width: 28px;
  height: 38px;
  border-radius: 8px;
  cursor: grab;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.trip-drag-handle:active {
  cursor: grabbing;
}

.trip-drag-handle:hover {
  color: #b30738;
  background: rgba(179, 7, 56, 0.06);
}

.trip-stop-index {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #b30738, #8c062c);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.trip-stop-input-wrap {
  flex: 1;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 0 12px;
  height: 38px;
  display: flex;
  align-items: center;
}

.trip-stop-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: #334155;
}

.trip-remove-stop {
  border: none;
  background: transparent;
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
}

.trip-remove-stop:hover {
  background: #fee2e2;
  color: #b30738;
}

.trip-add-stop-btn {
  width: 100%;
  border: 1px dashed #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.trip-add-stop-btn:hover {
  border-color: #b30738;
  color: #b30738;
  background: rgba(179, 7, 56, 0.04);
}

.trip-stop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.trip-add-stop-btn,
.trip-add-favorites-btn {
  width: 100%;
  margin-bottom: 0;
}

.trip-add-favorites-btn {
  border: 1px dashed #cbd5e1;
  background: #fff;
  color: #475569;
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.trip-add-favorites-btn:hover {
  border-color: #b30738;
  color: #b30738;
  background: rgba(179, 7, 56, 0.04);
}

.trip-favorites-picker {
  margin-bottom: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.trip-favorites-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.trip-favorites-picker-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
}

.trip-favorites-picker-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trip-favorites-item {
  text-align: left;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  cursor: pointer;
}

.trip-favorites-item:hover {
  border-color: #b30738;
  background: rgba(179, 7, 56, 0.04);
}

.trip-favorites-item-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}

.trip-favorites-item-address {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.trip-favorites-empty,
.trip-favorites-loading {
  margin: 0;
  padding: 12px;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}

.trip-plan-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #b30738 0%, #8c062c 100%);
  box-shadow: 0 8px 22px rgba(179, 7, 56, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.trip-plan-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(179, 7, 56, 0.42);
}

.trip-plan-btn:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.trip-plan-btn:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.trip-save-btn {
  width: 100%;
  margin-top: 10px;
  border: 2px solid #b30738;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #b30738;
  cursor: pointer;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease, color 0.2s ease;
}

.trip-save-btn:hover {
  background: #b30738;
  color: #fff;
}

.trip-save-btn.is-saved {
  border-color: #16a34a;
  color: #16a34a;
  background: #f0fdf4;
}

.trip-saved-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.trip-saved-toggle {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.trip-saved-toggle:hover {
  border-color: #b30738;
  color: #b30738;
}

.trip-saved-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #b30738;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.trip-saved-count:empty {
  display: none;
}

.trip-saved-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.trip-saved-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
}

.trip-saved-item-body {
  flex: 1;
  min-width: 0;
}

.trip-saved-item-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}

.trip-saved-item-meta {
  margin: 0;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

.trip-saved-item-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.trip-saved-load,
.trip-saved-delete {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 6px;
}

.trip-saved-load {
  color: #b30738;
}

.trip-saved-load:hover {
  background: rgba(179, 7, 56, 0.08);
}

.trip-saved-delete {
  color: #94a3b8;
}

.trip-saved-delete:hover {
  color: #b30738;
  background: #fee2e2;
}

.trip-saved-empty {
  margin: 0;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
  padding: 8px 0;
}

.trip-results {
  margin-top: 16px;
}

.trip-summary-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.trip-summary-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.trip-summary-card p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

.trip-leg-card {
  margin-bottom: 10px;
}

.trip-leg-title {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

/* Embed mode (home page preview) */
body.trip-planner-embed #nav-section {
  display: none;
}

body.trip-planner-embed .trip-overlay-section {
  top: 12px;
  left: 12px;
  width: min(360px, 92vw);
  min-width: 0;
}

body.trip-planner-embed .trip-container {
  max-height: calc(100vh - 24px);
  padding: 14px 12px 16px;
}

body.trip-planner-embed .trip-title {
  font-size: 18px;
}

body.trip-planner-embed .trip-subtitle,
body.trip-planner-embed #trip-name,
body.trip-planner-embed label[for="trip-name"],
body.trip-planner-embed .trip-saved-section,
body.trip-planner-embed .trip-add-favorites-btn,
body.trip-planner-embed .trip-favorites-picker {
  display: none;
}

body.trip-planner-embed .trip-stop-actions {
  grid-template-columns: 1fr;
}

body.trip-planner-embed .trip-back-btn {
  display: none;
}

body.trip-planner-embed .trip-embed-open {
  display: inline-flex !important;
}

.trip-embed-open {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1100;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #b30738;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}

.trip-embed-open:hover {
  background: #fff;
}

@media (max-width: 900px) {
  .trip-overlay-section {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    min-width: 0;
    max-height: none;
    padding: 80px 12px 0;
    box-sizing: border-box;
  }

  .trip-container {
    max-height: none;
  }

  body#trip-planner-page .map {
    position: relative;
    height: 55vh;
    min-height: 280px;
  }
}
