/* Modern Dark Glassmorphism Stylesheet for Canyon Discovery Engine */
:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.82);
  --bg-input: rgba(2, 6, 23, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-indigo: #6366f1;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;

  --sidebar-width: 380px;
  --header-height: 56px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  display: flex;
}

/* Glassmorphism utility */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  z-index: 1050;
  transition: transform 0.3s ease;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e11d48, #be123c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.4);
}

.app-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.auth-badge:hover {
  background: rgba(255, 255, 255, 0.1);
}

.auth-badge.authorized {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Panels / Cards */
.panel {
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-indigo);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: #4f46e5;
}

.btn-primary:disabled {
  background: #334155;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn-full {
  width: 100%;
}

/* Form Controls */
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  border-color: var(--accent-indigo);
}

/* Bounding box readout */
.bbox-readout {
  background: rgba(2, 6, 23, 0.9);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bbox-area-val {
  color: var(--accent-cyan);
  font-weight: 700;
}

/* Layer toggles */
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.layer-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Results Cards */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-card {
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}

.route-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent-indigo);
  transform: translateY(-1px);
}

.route-card-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.route-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
}

.tag-day {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.tag-expedition {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
}

.route-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Map area */
.map-container {
  flex: 1;
  height: 100%;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* Map Floating Legend */
.map-legend {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 170px;
}

.legend-header {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Base Layer Switcher */
.basemap-switcher {
  position: absolute;
  top: 16px;
  right: 60px;
  z-index: 1000;
  display: flex;
  border-radius: 8px;
  overflow: hidden;
}

.basemap-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  border-right: 1px solid var(--border-color);
  transition: all 0.2s;
}

.basemap-btn:last-child {
  border-right: none;
}

.basemap-btn.active {
  background: var(--accent-indigo);
  color: #fff;
}

/* Elevation Profile Panel */
.elevation-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 220px;
  z-index: 1000;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.elevation-panel.open {
  transform: translateY(0);
}

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

.elevation-title {
  font-size: 13px;
  font-weight: 700;
}

.elevation-chart-wrap {
  flex: 1;
  position: relative;
}

/* Modals & Overlays */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-indigo);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-cyan));
  transition: width 0.4s ease;
}

/* Helpers */
.hidden {
  display: none !important;
}

/* Leaflet Customizations */
.leaflet-popup-content-wrapper {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-radius: 10px !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-tip {
  background: var(--bg-secondary) !important;
}
