/* style.css — Trip Map
   Travel-journal aesthetic: warm, editorial, outdoorsy.
   Palette is spec-declared (not the fleet dashboard tokens) — see DESIGN_NOTES.md. */

:root {
  --bg:              #F7F4EF;
  --surface:         #FFFFFF;
  --header-bg:       rgba(28, 28, 30, 0.92);
  --header-text:     #F7F4EF;
  --text-primary:    #1C1C1E;
  --text-secondary:  #6B6B6B;
  --accent:          #2E7D6E;
  --pill-inactive:   #E8E4DD;
  --pill-inactive-text: #4A4A4A;
  --border:          #E0DBD3;
  --shadow-popup:    0 8px 32px rgba(0, 0, 0, 0.18);
  --shadow-panel:    -4px 0 24px rgba(0, 0, 0, 0.2);
  --edit-bg:         #1C1C1E;
  --edit-text:       #F7F4EF;
  --edit-border:     #3A3A3C;
  --edit-input-bg:   #2A2A2C;
  --radius-popup:    12px;
  --radius-pill:     20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background: var(--bg);
  overflow: hidden;
}

#map { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------------------------------------------------------------------------
   Header (top floating bar)
--------------------------------------------------------------------------- */
.header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: var(--header-bg);
  color: var(--header-text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.header .trip-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
}
.header .trip-subtitle {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}
.trip-switcher {
  background: rgba(255, 255, 255, 0.12);
  color: var(--header-text);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.trip-switcher option { color: #1C1C1E; }

/* ---------------------------------------------------------------------------
   Day filter pills (bottom floating)
--------------------------------------------------------------------------- */
.day-pills {
  position: absolute;
  bottom: 24px; left: 0; right: 0;
  z-index: 9;
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: center;
}
.day-pills::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto;
  background: var(--pill-inactive);
  color: var(--pill-inactive-text);
  border: none;
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.pill:hover { transform: translateY(-1px); }
.pill.active { color: #fff; }

/* ---------------------------------------------------------------------------
   Legend (bottom-left, All Days only)
--------------------------------------------------------------------------- */
.legend {
  position: absolute;
  bottom: 80px; left: 16px;
  z-index: 8;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  font-size: 12px;
  max-width: 220px;
}
.legend.hidden { display: none; }
.legend-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }

/* ---------------------------------------------------------------------------
   Markers (custom AdvancedMarkerElement content)
--------------------------------------------------------------------------- */
.marker {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 14px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease;
  transform-origin: center bottom;
}
.marker:hover { transform: scale(1.1); }
.marker.selected { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.95), 0 2px 8px rgba(0, 0, 0, 0.4); }

/* ---------------------------------------------------------------------------
   Popup (custom, positioned over the map)
--------------------------------------------------------------------------- */
.popup {
  position: absolute;
  z-index: 20;
  width: 340px;
  max-width: 90vw;
  background: var(--surface);
  border-radius: var(--radius-popup);
  box-shadow: var(--shadow-popup);
  overflow: hidden;
  display: none;
  animation: popIn 0.16s ease;
}
.popup.open { display: block; }
@keyframes popIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.popup-media {
  position: relative;
  width: 100%; height: 200px;
  background: #E8E4DD;
}
.popup-media.empty { height: 0; }
.popup-photo, .popup-streetview {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.popup-photo { object-fit: cover; }
.popup-streetview { display: none; }
.popup-media.sv-active .popup-photo { display: none; }
.popup-media.sv-active .popup-streetview { display: block; }
.sv-toggle {
  position: absolute;
  bottom: 8px; left: 8px;
  z-index: 2;
  background: rgba(28, 28, 30, 0.8);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  display: none;
}
.popup-media:not(.empty) .sv-toggle { display: block; }
.sv-none {
  position: absolute; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 12px;
  background: #E8E4DD;
}

.popup-close {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 3;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(28, 28, 30, 0.7);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-body { padding: 14px 16px 16px; }
.popup-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.day-badge {
  color: #fff;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}
.stop-count { font-size: 12px; color: var(--text-secondary); }
.popup-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 6px;
}
.popup-duration {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.popup-desc { font-size: 14px; line-height: 1.5; color: var(--text-primary); }
.popup-considerations { margin-top: 12px; }
.popup-considerations h4 {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.popup-considerations ul { list-style: none; }
.popup-considerations li {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
  padding-left: 14px;
  position: relative;
  margin-bottom: 3px;
}
.popup-considerations li::before {
  content: '•';
  position: absolute;
  left: 2px;
  color: var(--accent);
}
.popup-edit-btn {
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: none;
}
body.edit-active .popup-edit-btn { display: inline-block; }

/* ---------------------------------------------------------------------------
   Lock / edit-entry button (bottom-left corner)
--------------------------------------------------------------------------- */
.lock-btn {
  position: absolute;
  bottom: 24px; left: 16px;
  z-index: 9;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lock-btn.hidden { display: none; }

.password-prompt {
  position: absolute;
  bottom: 24px; left: 16px;
  z-index: 11;
  display: none;
  gap: 6px;
  background: var(--edit-bg);
  padding: 8px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.password-prompt.open { display: flex; }
.password-prompt.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.password-prompt input {
  background: var(--edit-input-bg);
  color: var(--edit-text);
  border: 1px solid var(--edit-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  width: 150px;
}
.password-prompt button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}

/* ---------------------------------------------------------------------------
   Edit panel (right side, dark)
--------------------------------------------------------------------------- */
.edit-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  z-index: 30;
  width: 360px;
  max-width: 100vw;
  background: var(--edit-bg);
  color: var(--edit-text);
  box-shadow: var(--shadow-panel);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 18px;
}
.edit-panel.open { transform: translateX(0); }

.edit-panel h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  margin-bottom: 4px;
}
.edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--edit-border);
}
.edit-panel .muted { color: #9A9A9C; font-size: 12px; }

.edit-section { margin-bottom: 20px; }
.edit-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9A9A9C;
  margin-bottom: 8px;
}

.edit-panel input[type="text"],
.edit-panel input[type="password"],
.edit-panel textarea {
  width: 100%;
  background: var(--edit-input-bg);
  color: var(--edit-text);
  border: 1px solid var(--edit-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  margin-bottom: 8px;
}
.edit-panel textarea { resize: vertical; min-height: 80px; }
.edit-panel label { font-size: 12px; color: #B8B8BA; display: block; margin-bottom: 3px; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--edit-border);
  color: var(--edit-text);
}
.btn-danger { background: #B33A3A; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--edit-text);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 5px;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* Day accordion */
.day-block {
  border: 1px solid var(--edit-border);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}
.day-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
}
.day-swatch { width: 16px; height: 16px; border-radius: 4px; flex: 0 0 auto; }
.day-head-label { font-weight: 600; font-size: 13px; }
.day-head-title { font-size: 12px; color: #9A9A9C; }
.day-head-spacer { flex: 1; }
.day-body { padding: 8px 12px 12px; display: none; }
.day-block.open .day-body { display: block; }

/* Stop rows */
.stop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 6px;
}
.stop-row.sortable-ghost { opacity: 0.4; }
.drag-handle { cursor: grab; color: #7A7A7C; font-size: 14px; }
.stop-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
  flex: 0 0 auto;
}
.stop-info { flex: 1; min-width: 0; }
.stop-info .nm { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-info .du { font-size: 11px; color: #9A9A9C; }

/* Considerations editor */
.consideration-item { display: flex; gap: 6px; align-items: center; }
.consideration-item input { margin-bottom: 6px; }

/* Search results */
.search-results { margin-top: 8px; }
.search-result {
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid var(--edit-border);
  margin-bottom: 5px;
}
.search-result:hover { background: rgba(255, 255, 255, 0.06); }
.search-result .addr { font-size: 11px; color: #9A9A9C; }

.toast {
  position: absolute;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--edit-bg);
  color: var(--edit-text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------------------
   Mobile
--------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .header .trip-name { font-size: 20px; }
  .day-pills { justify-content: flex-start; }
  .legend { display: none; }
  .popup {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-popup) var(--radius-popup) 0 0;
    max-height: 70vh;
    overflow-y: auto;
  }
  .edit-panel {
    width: 100%;
    top: auto;
    height: 82vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .edit-panel.open { transform: translateY(0); }
}
