/* HelmRoute App Styles — matches landing page design language */

:root {
  --navy: #0a1628;
  --deep: #0f2137;
  --sea: #1a6b5a;
  --teal: #2dd4a8;
  --teal-dim: rgba(45, 212, 168, 0.15);
  --foam: #e0faf0;
  --sand: #f5f0e8;
  --white: #ffffff;
  --mist: #94a3b8;
  --danger: #ef4444;
  --warning: #f59e0b;
  --glass: rgba(10, 22, 40, 0.88);
  --glass-border: rgba(45, 212, 168, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', sans-serif;
  background: var(--navy);
  color: var(--white);
}

h1, h2, h3, h4, h5 {
  font-family: 'Space Grotesk', sans-serif;
}

/* ====== MAP ====== */

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Leaflet overrides */
.leaflet-control-layers {
  background: var(--glass) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--white) !important;
  backdrop-filter: blur(12px);
}

.leaflet-control-layers-expanded {
  padding: 10px 14px !important;
}

.leaflet-control-layers label {
  color: var(--mist) !important;
  font-size: 0.85rem;
}

.leaflet-control-zoom a {
  background: var(--glass) !important;
  color: var(--teal) !important;
  border-color: var(--glass-border) !important;
  backdrop-filter: blur(12px);
}

.leaflet-control-zoom a:hover {
  background: var(--deep) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--glass) !important;
  color: var(--white) !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
}

.leaflet-popup-tip {
  background: var(--glass) !important;
}

.leaflet-popup-content {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--mist);
}

.leaflet-popup-content b {
  color: var(--white);
}

/* ====== CUSTOM MARKERS ====== */

.marker-container {
  background: none !important;
  border: none !important;
}

.custom-marker {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: bold;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.2s;
}

.custom-marker:hover {
  transform: scale(1.1);
}

.marker-from {
  background: var(--teal);
  color: var(--navy);
  box-shadow: 0 0 20px rgba(45, 212, 168, 0.5);
}

.marker-to {
  background: var(--danger);
  color: var(--white);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.marker-waypoint {
  background: var(--warning);
  color: var(--navy);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
}

/* GPS marker pulse animation */
.gps-marker {
  animation: gpsPulse 2s infinite;
}

@keyframes gpsPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(45, 212, 168, 0.6)); }
  50% { filter: drop-shadow(0 0 16px rgba(45, 212, 168, 0.9)); }
}

/* ====== TOP BAR ====== */

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
}

#topbar .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--teal);
  text-decoration: none;
  letter-spacing: -0.5px;
}

#topbar .logo span {
  color: var(--white);
}

#gps-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--mist);
}

.gps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.gps-active { background: var(--teal); box-shadow: 0 0 8px rgba(45, 212, 168, 0.6); }
.gps-acquiring { background: var(--warning); animation: blink 1s infinite; }
.gps-error, .gps-unavailable { background: var(--danger); }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#btn-toggle-search {
  background: var(--teal-dim);
  border: 1px solid var(--glass-border);
  color: var(--teal);
  font-size: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#btn-toggle-search:hover {
  background: rgba(45, 212, 168, 0.25);
}

/* ====== SEARCH PANEL ====== */

#search-panel {
  position: fixed;
  top: 60px;
  left: 1rem;
  right: 1rem;
  z-index: 999;
  max-width: 420px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  transition: all 0.3s ease;
}

#search-panel.collapsed {
  transform: translateY(-120%);
  opacity: 0;
  pointer-events: none;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.search-field:last-of-type {
  margin-bottom: 0;
}

.search-field input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-field input::placeholder {
  color: var(--mist);
  opacity: 0.6;
}

.search-field input:focus {
  border-color: var(--teal);
}

.search-field .dot-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-from { background: var(--teal); }
.dot-to { background: var(--danger); }

#btn-my-location {
  background: var(--teal-dim);
  border: 1px solid var(--glass-border);
  color: var(--teal);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

#btn-my-location:hover {
  background: rgba(45, 212, 168, 0.3);
}

/* Search Results Dropdown */
#search-results {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  margin-top: 0.5rem;
}

#search-results.visible {
  max-height: 280px;
  overflow-y: auto;
}

.search-result {
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.search-result:hover {
  background: var(--teal-dim);
}

.search-result-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--white);
}

.search-result-detail {
  font-size: 0.75rem;
  color: var(--mist);
  margin-top: 2px;
}

/* ====== ROUTE PANEL ====== */

#route-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  max-height: 55vh;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.25rem 1rem 1rem;
  overflow-y: auto;
  transition: all 0.35s ease;
}

#route-panel.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* Route Summary Stats */
#route-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-border);
}

.stat {
  flex: 1;
  text-align: center;
}

.stat-value {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--teal);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--mist);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.15rem;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: var(--teal);
  color: var(--navy);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: -0.3px;
}

.btn-primary:hover {
  background: #38e8b8;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(45, 212, 168, 0.3);
}

.btn-secondary {
  width: 100%;
  padding: 0.65rem;
  background: transparent;
  color: var(--mist);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--mist);
  color: var(--white);
}

.btn-danger {
  width: 100%;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.75rem;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ====== DIRECTIONS LIST ====== */

#directions-list {
  margin-top: 1rem;
}

.direction-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.direction-item:hover {
  background: var(--teal-dim);
}

.direction-item.active {
  background: rgba(45, 212, 168, 0.12);
  border-color: rgba(45, 212, 168, 0.2);
}

.direction-item.depart .direction-arrow,
.direction-item.arrive .direction-arrow {
  background: var(--teal-dim);
}

.direction-arrow {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.direction-content {
  flex: 1;
  min-width: 0;
}

.direction-instruction {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--white);
  line-height: 1.4;
}

.direction-meta {
  font-size: 0.75rem;
  color: var(--mist);
  margin-top: 0.2rem;
}

/* ====== NAVIGATION PANEL ====== */

#nav-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem 1rem 1rem;
  transition: all 0.35s ease;
}

#nav-panel.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#nav-panel.off-route {
  border-top-color: var(--danger);
}

#nav-panel.off-route::before {
  content: 'OFF ROUTE';
  display: block;
  text-align: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--danger);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}

#nav-current-direction {
  text-align: center;
  padding-bottom: 1rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--glass-border);
}

#nav-arrow {
  font-size: 2.5rem;
  color: var(--teal);
  line-height: 1;
  margin-bottom: 0.25rem;
}

#nav-instruction {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

#nav-detail {
  font-size: 0.9rem;
  color: var(--mist);
  margin-top: 0.25rem;
}

#nav-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.nav-stat {
  flex: 1;
  text-align: center;
}

.nav-stat span:first-child {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
}

.nav-stat span:last-child {
  font-size: 0.7rem;
  color: var(--mist);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ====== TOAST ====== */

#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 2000;
  background: var(--deep);
  color: var(--white);
  padding: 0.75rem 1.5rem;
  border-radius: 100px;
  font-size: 0.85rem;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

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

#toast.hidden {
  display: none;
}

/* ====== RESPONSIVE ====== */

@media (min-width: 768px) {
  #search-panel {
    left: 1.5rem;
    right: auto;
    width: 380px;
    top: 70px;
  }

  #route-panel {
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
    max-width: 400px;
    max-height: 70vh;
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
  }

  #nav-panel {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius) var(--radius) 0 0;
  }

  #nav-panel.hidden {
    transform: translateX(-50%) translateY(100%);
  }
}

@media (max-width: 480px) {
  #topbar {
    padding: 0.6rem 0.75rem;
  }

  #topbar .logo {
    font-size: 1.05rem;
  }

  #search-panel {
    left: 0.5rem;
    right: 0.5rem;
    top: 54px;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  #nav-instruction {
    font-size: 1.1rem;
  }
}

/* ====== SCROLLBAR ====== */

#route-panel::-webkit-scrollbar {
  width: 4px;
}

#route-panel::-webkit-scrollbar-track {
  background: transparent;
}

#route-panel::-webkit-scrollbar-thumb {
  background: rgba(45, 212, 168, 0.2);
  border-radius: 4px;
}

/* ====== LEAFLET ATTRIBUTION ====== */

.leaflet-control-attribution {
  background: rgba(10, 22, 40, 0.7) !important;
  color: var(--mist) !important;
  font-size: 0.65rem !important;
  backdrop-filter: blur(8px);
}

.leaflet-control-attribution a {
  color: var(--teal) !important;
}
