/* ════════════════════════════════════════════════
   WHERE IS DAVID — style.css
   ════════════════════════════════════════════════ */

:root {
  --bg:       #111820;
  --surface:  #182030;
  --surface2: #1e2a3a;
  --border:   #2a3d52;
  --green:    #3a7d5e;
  --green-lt: #52b38a;
  --amber:    #e8943a;
  --amber-lt: #f5b96a;
  --text:     #d8e4f0;
  --text-dim: #6a8aaa;
  --red:      #c0392b;
  --mono:     'JetBrains Mono', monospace;
  --serif:    'Playfair Display', Georgia, serif;
  --sans:     'Lato', sans-serif;
}

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

html { height: 100%; }

body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── NOISE OVERLAY ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ─── HEADER ─── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  z-index: 100;
}

.hike-title {
  font-family: var(--serif);
  font-size: 1.4rem;
  color: var(--text);
  letter-spacing: 0.02em;
  flex: 1;
  cursor: pointer;
}
.hike-title span { color: var(--amber); font-style: italic; }

.status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
}

.pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green-lt);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}

.last-update {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* ─── BUTTONS ─── */
.btn {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.btn:hover                { border-color: var(--amber); color: var(--amber); }
.btn.primary              { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover        { background: var(--green-lt); border-color: var(--green-lt); }
.btn.danger               { border-color: var(--red); color: var(--red); background: transparent; }
.btn.danger:hover         { background: var(--red); color: #fff; }

/* ─── LAYOUT ─── */
main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── MAP ─── */
#map {
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* Leaflet overrides */
.leaflet-container         { background: #0e1520; }
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: 6px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-tip         { background: var(--surface) !important; }
.leaflet-popup-content     { margin: 10px 14px !important; }
.leaflet-popup-close-button { color: var(--text-dim) !important; }

/* ─── BASEMAP CONTROL (Leaflet control) ─── */
.basemap-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
/* Kill any Leaflet-inherited focus/active color on control children */
.basemap-control a,
.basemap-control div {
  color: inherit;
}
.leaflet-control .basemap-btn:focus,
.leaflet-control .basemap-btn:focus-visible {
  outline: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.basemap-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.basemap-btn:hover        { border-color: var(--amber); color: var(--text); }
.basemap-btn.active       { border-color: var(--amber); color: var(--amber); background: #1a2535; }
.basemap-thumb {
  width: 24px; height: 17px;
  border-radius: 2px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255,255,255,0.15);
}

/* ─── SIDEBAR ─── */
#sidebar {
  width: 360px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  padding: 11px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab.active              { color: var(--amber); border-bottom-color: var(--amber); }
.tab:hover:not(.active)  { color: var(--text); }

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ─── WAYPOINT LIST ─── */
.wp-list { padding: 8px; }

.wp-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface2);
  position: relative;
}
.wp-item:hover, .wp-item.active { border-color: var(--amber); background: #1a2535; }
.wp-item.active::before {
  content: '';
  position: absolute;
  left: -1px; top: -1px; bottom: -1px;
  width: 3px;
  background: var(--amber);
  border-radius: 6px 0 0 6px;
}
.wp-num   { font-family: var(--mono); font-size: 0.65rem; color: var(--amber); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 4px; }
.wp-time  { font-family: var(--mono); font-size: 0.75rem; color: var(--text); margin-bottom: 3px; }
.wp-coords { font-family: var(--mono); font-size: 0.65rem; color: var(--text-dim); }
.wp-note  { font-size: 0.78rem; color: var(--green-lt); margin-top: 5px; font-style: italic; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--text-dim); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.85rem; line-height: 1.6; }

/* ─── DETAIL VIEW ─── */
.detail-header  { padding: 14px 16px 0; }
.detail-num     { font-family: var(--mono); font-size: 0.65rem; color: var(--amber); text-transform: uppercase; letter-spacing: 0.1em; }
.detail-time    { font-family: var(--serif); font-size: 1.15rem; color: var(--text); margin: 4px 0 2px; }
.detail-coords  { font-family: var(--mono); font-size: 0.72rem; color: var(--text-dim); }

.street-view-container {
  margin: 14px 16px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.sv-label {
  position: absolute;
  bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.7);
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  padding: 3px 7px;
  border-radius: 3px;
  letter-spacing: 0.06em;
}
.sv-placeholder {
  height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  gap: 8px;
}
.sv-placeholder .icon { font-size: 2rem; opacity: 0.3; }

.detail-links {
  padding: 0 16px 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-note {
  margin: 0 16px 14px;
  padding: 10px 12px;
  background: rgba(58,125,94,0.12);
  border: 1px solid rgba(82,179,138,0.25);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--green-lt);
  line-height: 1.5;
}
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s;
}
.back-btn:hover { color: var(--amber); }

/* ─── ADMIN PANEL ─── */
#admin-panel {
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  padding: 14px 16px;
}
.admin-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--amber);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

textarea.input, input.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 8px 10px;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
textarea.input { resize: vertical; min-height: 80px; max-height: 140px; line-height: 1.5; font-size: 0.68rem; }
textarea.input:focus, input.input:focus { border-color: var(--amber); }
textarea.input::placeholder, input.input::placeholder { color: var(--text-dim); }

.admin-actions { display: flex; gap: 8px; margin-top: 4px; }
.admin-actions .btn { flex: 1; }

/* ─── MODALS ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
  width: 400px;
  max-width: 95vw;
}
.modal h2        { font-family: var(--serif); font-size: 1.2rem; margin-bottom: 6px; }
.modal p         { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 18px; line-height: 1.5; }
.modal label     { display: block; font-family: var(--mono); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: 6px; }
.modal-error     { font-family: var(--mono); font-size: 0.7rem; color: var(--red); margin-top: 8px; min-height: 16px; }
.modal-actions   { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.settings-section { margin-bottom: 14px; }

/* ─── TOAST ─── */
#toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 20px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
  z-index: 2000;
  transition: transform 0.3s ease;
  white-space: nowrap;
  pointer-events: none;
}
#toast.show    { transform: translateX(-50%) translateY(0); }
#toast.success { border-color: var(--green); color: var(--green-lt); }
#toast.error   { border-color: var(--red); color: #e87070; }

/* ─── COORD STRIP ─── */
.coord-strip {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 6px 16px;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  display: flex;
  gap: 16px;
  align-items: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.coord-strip span { color: var(--amber); }

/* ─── MAP MARKERS ─── */
.custom-marker {
  width: 28px; height: 28px;
  background: var(--amber);
  border: 2.5px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.custom-marker.latest {
  background: var(--green-lt);
  animation: markerPulse 2s ease-in-out infinite;
}
@keyframes markerPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(82,179,138,0.5); }
  50%       { box-shadow: 0 0 0 10px rgba(82,179,138,0); }
}
.marker-num {
  transform: rotate(45deg);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  color: #fff;
  line-height: 1;
}

/* ─── PHOTO in detail panel ─── */
.detail-photo {
  margin: 14px 16px 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.detail-photo img {
  width: 100%;
  display: block;
  max-height: 220px;
  object-fit: cover;
}

/* ─── RESPONSIVE / MOBILE BOTTOM SHEET ─── */
@media (max-width: 700px) {
  #sidebar { display: none; }

  /* Bottom sheet overlay */
  #bottom-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 600;
  }
  #bottom-sheet-overlay.open { display: block; }

  /* Bottom sheet panel */
  #bottom-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    z-index: 700;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }
  #bottom-sheet.open { transform: translateY(0); }

  /* Drag handle */
  .sheet-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto 8px;
  }

  /* Close button */
  .sheet-close {
    position: absolute;
    top: 14px; right: 16px;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface2);
  }

  /* Street view full width on mobile */
  #bottom-sheet .street-view-container {
    margin: 14px 12px;
  }
  #bottom-sheet .detail-header  { padding: 4px 16px 0; }
  #bottom-sheet .detail-links   { padding: 0 12px 12px; }
  #bottom-sheet .detail-note    { margin: 0 12px 12px; }
  #bottom-sheet .detail-photo   { margin: 14px 12px 0; }

  /* Coord strip smaller on mobile */
  .coord-strip { font-size: 0.58rem; gap: 8px; flex-wrap: wrap; }
}

@media (min-width: 701px) {
  #bottom-sheet-overlay,
  #bottom-sheet { display: none !important; }
}
