/* cochid-bici · bici.cochid.cl */

:root {
  --bg: #0f172a;
  --bg-panel: rgba(15, 23, 42, 0.92);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #22c55e;
  --accent-light: #86efac;
  --route-color: #06b6d4;
  --border: rgba(148, 163, 184, 0.15);
  --input-bg: rgba(30, 41, 59, 0.9);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ---- Header ---- */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header h1 span {
  color: var(--accent);
}

.header-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  margin-right: 12px;
  padding: 4px;
}

/* ---- Map ---- */
#map {
  position: fixed;
  top: 48px;
  left: 320px;
  right: 0;
  bottom: 0;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 48px;
  left: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow-y: auto;
  z-index: 15;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}

/* ---- Cards ---- */
.card {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.card h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Stats */
.stat-big {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.stat-row:first-of-type {
  border-top: none;
}

.stat-row .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.stat-row .value {
  font-weight: 600;
  color: var(--text);
}

/* ---- Route form ---- */
.route-input-group {
  position: relative;
  margin-bottom: 10px;
}

.route-input-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.route-input-group input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.route-input-group input:focus {
  border-color: var(--accent);
}

.route-input-group input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Autocomplete dropdown */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 2px;
  max-height: 180px;
  overflow-y: auto;
  display: none;
}

.autocomplete-list.show {
  display: block;
}

.autocomplete-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: rgba(34, 197, 94, 0.1);
}

.autocomplete-item .street {
  color: var(--text);
  font-weight: 500;
}

.autocomplete-item .city {
  color: var(--text-muted);
  font-size: 12px;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #0f172a;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-top: 6px;
  font-weight: 400;
  font-size: 13px;
}

/* Route result */
.route-result {
  display: none;
  margin-top: 12px;
  padding: 12px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 8px;
}

.route-result.show { display: block; }

.route-result .route-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.route-result .route-stat .label {
  font-size: 13px;
  color: var(--text-muted);
}

.route-result .route-stat .value {
  font-size: 16px;
  font-weight: 700;
  color: var(--route-color);
}

/* Legend */
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
}

.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Toggle for slope coloring */
.legend-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.slope-legend {
  margin-top: 4px;
}

/* Elevation chart canvas */
#elevationChart {
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Map instructions */
.map-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
}

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: rgba(148, 163, 184, 0.3);
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* Error message */
.error-msg {
  font-size: 13px;
  color: #f87171;
  margin-top: 8px;
  display: none;
}

.error-msg.show { display: block; }

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .header-toggle {
    display: block;
  }

  .sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 45vh;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(calc(100% - 60px));
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateY(0);
  }

  .sidebar::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    margin: 0 auto 12px;
    opacity: 0.4;
  }

  #map {
    left: 0;
    bottom: 60px;
  }
}

/* MapLibre overrides */
.maplibregl-popup-content {
  background: var(--bg-panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  font-size: 13px !important;
  backdrop-filter: blur(12px) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
}

.maplibregl-popup-tip {
  border-top-color: var(--bg-panel) !important;
}

.maplibregl-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 18px !important;
  padding: 2px 6px !important;
}

.maplibregl-ctrl-attrib {
  background: rgba(15, 23, 42, 0.7) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.maplibregl-ctrl-attrib a {
  color: var(--text-muted) !important;
}
