/* Trip Planner — split pane: planner (~30%) | map (~70%) */

body#trip-planner-page {
  font-family: "Open Sans", sans-serif;
  margin: 0;
  color: #2d2d31;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #e8edf3;
}

body#trip-planner-page #nav-section {
  flex-shrink: 0;
  position: relative;
  z-index: 30;
}

.trip-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 30%) 1fr;
  gap: 14px;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
  /* Sit clearly below the navbar with breathing room */
  padding: 14px 16px 16px;
}

.trip-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  border: none;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.trip-map-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #dbe3ee;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1), 0 0 0 1px rgba(15, 23, 42, 0.06);
}

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

body.trip-planner-embed {
  height: auto;
  overflow: auto;
}

body.trip-planner-embed .map {
  position: relative;
  inset: auto;
  width: 100%;
  height: 220px;
}

/* Legacy class name kept for embed CSS targeting */
.trip-overlay-section,
.trip-panel {
  pointer-events: auto;
}

.trip-container {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  padding: 18px 16px 24px;
  box-sizing: border-box;
  /* Capsule / rounded card separating planner from the map */
  border-radius: 28px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow:
    0 14px 36px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

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

.trip-header-text {
  min-width: 0;
  flex: 1;
}

.trip-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #b30738;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.trip-back-btn:hover {
  background: #fff5f7;
  border-color: #b30738;
}

.trip-back-btn i {
  font-size: 12px;
}

.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-select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 10px;
  background: #fff;
  color: #334155;
  cursor: pointer;
}

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

.trip-start-custom-wrap {
  margin-bottom: 14px;
}

.trip-start-custom-wrap .trip-name-input {
  margin-bottom: 0;
}

.trip-timing-block {
  margin-bottom: 14px;
}

.trip-time-mode {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.trip-time-mode-btn {
  flex: 1;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.trip-time-mode-btn:hover {
  border-color: #b30738;
  color: #b30738;
}

.trip-time-mode-btn.is-active {
  background: #b30738;
  border-color: #b30738;
  color: #fff;
}

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

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

.trip-time-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
}

.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;
  position: relative;
  z-index: 1;
}

.trip-stop-row:focus-within {
  z-index: 40;
}

.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;
  position: relative;
  overflow: visible;
  z-index: 5;
}

.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-share-btn {
  width: 100%;
  margin-top: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.trip-share-btn:hover {
  border-color: #b30738;
  color: #b30738;
  background: #fff5f7;
}

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

.trip-share-inline-btn {
  margin-top: 12px;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: #0f172a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.trip-share-inline-btn:hover {
  background: #b30738;
}

.trip-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 10000;
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: min(92vw, 360px);
  text-align: center;
}

.trip-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.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-share,
.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-share {
  color: #475569;
}

.trip-saved-share:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.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 {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

body.trip-planner-embed #nav-section {
  display: none;
}

body.trip-planner-embed .trip-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 10px 12px 16px;
  gap: 10px;
}

body.trip-planner-embed .trip-map-pane {
  order: 1;
  flex: 0 0 220px;
  height: 220px;
  border-radius: 16px;
}

body.trip-planner-embed .trip-panel {
  order: 2;
  border-right: none;
  overflow: visible;
}

body.trip-planner-embed .trip-container {
  height: auto;
  max-height: none;
  padding: 14px 12px 16px;
  border-radius: 18px;
}

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-timing-block .trip-time-hint {
  display: none;
}

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;
}

/* Leg detail preview (search-style timeline) */
.trip-leg-detail {
  margin-top: 4px;
}

.trip-leg-detail .route-preview-container {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.trip-leg-detail .route-preview-header {
  margin-bottom: 8px;
}

.trip-walk-steps {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.trip-walk-steps li {
  margin-bottom: 2px;
}

.trip-intermediate-stops {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 12px;
  color: #64748b;
}

.trip-leg-card.is-active {
  outline: 2px solid rgba(179, 7, 56, 0.35);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  body#trip-planner-page {
    height: auto;
    overflow: auto;
  }

  .trip-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 1fr;
    min-height: calc(100vh - 60px);
    padding: 12px;
    gap: 12px;
  }

  .trip-map-pane {
    order: 1;
    min-height: 42vh;
    max-height: none;
    border-radius: 20px;
  }

  .trip-panel {
    order: 2;
    overflow: visible;
  }

  .trip-container {
    height: auto;
    max-height: none;
    border-radius: 22px;
  }

  body#trip-planner-page .map {
    position: absolute;
  }
}
