/* ============================================================
   BiciMap — Precision Cycling Design System
   Fonts: Outfit (headings/brand) + DM Sans (UI/inputs)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=DM+Sans:wght@400;500;600&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES — Light Mode (default)
   ============================================================ */

:root {
  /* Brand */
  --accent:          #FF5C39;
  --accent-hover:    #E0471E;
  --accent-glow:     rgba(255, 92, 57, 0.15);
  --accent-shadow:   0 4px 14px rgba(255, 92, 57, 0.35);
  --teal:            #006272;
  --teal-light:      #008799;
  --lime:            #C8D400;

  /* Backgrounds */
  --bg-base:         #F3F4F0;
  --bg-card:         #FFFFFF;
  --bg-input:        #F8F9F7;
  --bg-subtle:       #F0F2EE;

  /* Borders */
  --border:          #E2E5DF;
  --border-focus:    #FF5C39;

  /* Text */
  --text-primary:    #111714;
  --text-secondary:  #4A5450;
  --text-muted:      #8A9490;

  /* Shadows */
  --shadow-card:     0 2px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-float:    0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);

  /* Shape */
  --radius-card:     18px;
  --radius-input:    12px;
  --radius-btn:      12px;

  /* Transitions */
  --transition-base: 0.2s ease;
  --transition-theme: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* ============================================================
   DARK MODE
   ============================================================ */

[data-theme="dark"] {
  --bg-base:        #0C100E;
  --bg-card:        #161B18;
  --bg-input:       #1E2520;
  --bg-subtle:      #1A1F1C;
  --border:         #2A3128;
  --text-primary:   #EDF0EB;
  --text-secondary: #9BA89F;
  --text-muted:     #5A6860;
  --shadow-card:    0 2px 16px rgba(0,0,0,0.30);
  --shadow-float:   0 8px 32px rgba(0,0,0,0.40);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  font-size: 16px;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  position: relative;
  overflow: hidden;
  transition: var(--transition-theme);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: -0.5px;
  margin-bottom: 18px;
  transition: var(--transition-theme);
}

h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--teal);
  letter-spacing: -0.3px;
  margin: 18px 0 10px;
  transition: var(--transition-theme);
}

h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--teal);
  letter-spacing: -0.2px;
  transition: var(--transition-theme);
}

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

#map {
  flex: 1;
  height: 100vh;
  width: 100vw;
  background: var(--bg-base);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

#sidebar {
  width: 360px;
  max-width: 90vw;
  background: transparent;
  padding: 16px;
  z-index: 1000;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  pointer-events: none;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#sidebar::-webkit-scrollbar {
  width: 4px;
}

#sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

#sidebar > * {
  pointer-events: auto;
}

/* ============================================================
   SIDEBAR CONTAINER (main card)
   ============================================================ */

.sidebar-container {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  transition: var(--transition-theme);
}

/* ============================================================
   SIDEBAR HEADER (logo + brand + dark mode toggle)
   ============================================================ */

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.sidebar-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.sidebar-header-logo {
  height: 44px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-header-name-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.sidebar-header-name {
  height: 32px;
  width: auto;
}

.sidebar-beta-badge {
  position: absolute;
  top: -4px;
  right: -40px;
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 6px;
  border-radius: 5px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  transition: var(--transition-theme);
}

/* Dark mode toggle */
#theme-toggle {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text-secondary);
  transition: var(--transition-theme), transform 0.15s ease;
  box-shadow: none;
  flex-shrink: 0;
}

#theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.08);
  box-shadow: none;
}

#theme-toggle:active {
  transform: scale(0.94);
}

/* ============================================================
   SECTION DIVIDER
   ============================================================ */

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
  transition: var(--transition-theme);
}

/* ============================================================
   SEARCH BOX LAYOUT
   ============================================================ */

.search-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

#search-mode {
  position: relative;
}

/* ============================================================
   INPUT ICON WRAPPERS
   ============================================================ */

.input-icon-wrapper {
  position: relative;
  width: 100%;
}

.input-icon-wrapper .input-pin-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--teal-light);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: var(--transition-theme);
}

[data-theme="dark"] .input-pin-icon {
  color: var(--teal-light);
  opacity: 0.8;
}

/* ============================================================
   INPUT FIELDS
   ============================================================ */

input[type="text"],
input[type="search"] {
  width: 100%;
  padding: 13px 44px 13px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: var(--transition-theme), box-shadow 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]::placeholder,
input[type="search"]::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

input[type="text"]:focus,
input[type="search"]:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-glow);
  color: var(--text-primary);
}

/* Range input */
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  height: 4px;
}

input[type="range"]:focus {
  outline: none;
  box-shadow: none;
  border: none;
}

/* ============================================================
   SELECT DROPDOWNS
   ============================================================ */

select {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 10px 36px 10px 14px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A9490' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: var(--transition-theme), box-shadow 0.2s ease;
  width: auto;
}

select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select:hover {
  border-color: var(--accent);
}

/* Bike type + priority select inline row */
.route-options-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.route-options-row label {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: 0.2px;
  transition: var(--transition-theme);
}

.route-options-row select {
  font-size: 11px;
  padding: 6px 30px 6px 10px;
  border-radius: 8px;
}

/* ============================================================
   AUTOCOMPLETE DROPDOWN
   ============================================================ */

.autocomplete-dropdown {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  max-height: 200px;
  box-shadow: var(--shadow-float);
  overflow-y: auto;
  width: calc(100% - 40px);
  z-index: 1002;
  display: none;
  transition: var(--transition-theme);
}

#search-dropdown  { top: 52px; }
#origin-dropdown  { top: 90px; }
#destination-dropdown { top: 142px; }

.autocomplete-item {
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--transition-base), color var(--transition-base);
}

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

.autocomplete-item:hover {
  background: var(--accent-glow);
  color: var(--text-primary);
}

/* ============================================================
   BUTTONS — Base Reset
   ============================================================ */

button {
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-btn);
  transition: all var(--transition-base);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

/* ============================================================
   PRIMARY BUTTON (#calculate, #generate-training)
   ============================================================ */

#calculate,
#generate-training {
  width: 100%;
  height: 48px;
  padding: 0 20px;
  background: linear-gradient(135deg, var(--accent) 0%, #FF7048 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-btn);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.1px;
  box-shadow: var(--accent-shadow);
  transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
  margin-top: 4px;
}

#calculate:hover,
#generate-training:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 92, 57, 0.45);
  background: linear-gradient(135deg, var(--accent-hover) 0%, #FF5C39 100%);
}

#calculate:active,
#generate-training:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--accent-shadow);
}

/* ============================================================
   SECONDARY / GHOST BUTTON
   ============================================================ */

.back-button {
  background: transparent;
  color: var(--teal);
  border: none;
  padding: 4px 8px;
  font-size: 20px;
  width: auto;
  margin-bottom: 8px;
  border-radius: 8px;
  font-weight: 400;
  box-shadow: none;
}

.back-button:hover {
  color: var(--accent);
  background: var(--accent-glow);
  box-shadow: none;
  transform: none;
}

/* ============================================================
   SWAP BUTTONS
   ============================================================ */

.swap-button {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  padding: 6px;
  font-size: 18px;
  width: 100%;
  margin: -4px 0;
  border-radius: 6px;
  font-weight: 400;
  box-shadow: none;
  transition: var(--transition-theme), border-color var(--transition-base);
}

.swap-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
  transform: none;
  box-shadow: none;
}

.swap-button-compact {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  padding: 9px 12px;
  font-size: 16px;
  border-radius: 10px;
  font-weight: 400;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: none;
  transition: var(--transition-theme), border-color var(--transition-base);
}

.swap-button-compact:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
  transform: none;
  box-shadow: none;
}

/* ============================================================
   UTILITY / SMALL BUTTONS
   ============================================================ */

.add-waypoint-button {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  padding: 10px 14px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  width: 100%;
  border-radius: 10px;
  box-shadow: none;
  transition: var(--transition-theme), border-color var(--transition-base), background var(--transition-base);
}

.add-waypoint-button:hover {
  background: var(--bg-card);
  border-color: var(--teal-light);
  color: var(--teal);
  transform: none;
  box-shadow: none;
}

.training-mode-button {
  background: linear-gradient(135deg, var(--accent) 0%, #ff7a5c 100%);
  color: white;
  border: none;
  padding: 11px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(255, 92, 57, 0.28);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.training-mode-button:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255, 92, 57, 0.38);
}

/* General fallback for other buttons (e.g. inside modals) */
button:not(#calculate):not(#generate-training):not(.back-button):not(.swap-button):not(.swap-button-compact):not(.add-waypoint-button):not(.training-mode-button):not(#theme-toggle):not(#layers-btn):not(#menu-btn):not(#info-btn):not(#geolocate-btn):not(.location-btn):not(.remove-waypoint-btn):not(#layers-submenu button):not(.btn-download):not(.btn-close) {
  padding: 12px 18px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(255, 92, 57, 0.22);
}

button:not(#calculate):not(#generate-training):not(.back-button):not(.swap-button):not(.swap-button-compact):not(.add-waypoint-button):not(.training-mode-button):not(#theme-toggle):not(#layers-btn):not(#menu-btn):not(#info-btn):not(#geolocate-btn):not(.location-btn):not(.remove-waypoint-btn):not(#layers-submenu button):not(.btn-download):not(.btn-close):hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 92, 57, 0.35);
}

/* ============================================================
   WAYPOINTS
   ============================================================ */

.waypoint-item {
  position: relative;
  width: 100%;
  margin: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.waypoint-item.dragging {
  opacity: 0.45;
}

.waypoint-drag-handle {
  cursor: move;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 8px 6px;
  font-size: 15px;
  color: var(--text-muted);
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-theme);
}

.waypoint-input-wrapper {
  flex: 1;
  position: relative;
}

.remove-waypoint-btn {
  background: #FF4444;
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: none;
}

.remove-waypoint-btn:hover {
  background: #CC0000;
  transform: scale(1.08);
  box-shadow: none;
}

.waypoint-marker {
  background: var(--lime);
  color: var(--teal);
  border: 2px solid var(--teal);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  margin-left: -14px;
  margin-top: -14px;
}

/* ============================================================
   LOCATION BUTTON (inside inputs)
   ============================================================ */

.location-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  padding: 6px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition-theme), transform 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.location-btn img {
  width: 18px;
  height: 18px;
  display: block;
}

.location-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--accent);
  transform: translateY(-50%) scale(1.06);
  box-shadow: none;
}

.location-btn:active {
  transform: translateY(-50%) scale(0.94);
}

/* ============================================================
   ROUTE INFO SECTION
   ============================================================ */

#route-info {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: none;
  transition: var(--transition-theme);
}

#route-info.active {
  display: block;
}

.info-item {
  margin: 5px 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  transition: var(--transition-theme);
}

.info-item strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Route stats grid (injected by app.js) */
.route-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.route-stats-grid .stat-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  transition: var(--transition-theme);
}

.route-stats-grid .stat-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 3px;
  font-family: 'DM Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.route-stats-grid .stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--teal);
}

#breakdown-details.open {
  max-height: 500px !important;
}

/* ============================================================
   ELEVATION MINI CHART
   ============================================================ */

.elevation-mini-chart {
  width: 100%;
  height: 90px;
  margin: 12px 0;
  background: var(--bg-subtle);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: var(--transition-theme);
}

.elevation-mini-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.elevation-mini-chart path {
  fill: rgba(0, 98, 114, 0.35);
  stroke: var(--teal);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

[data-theme="dark"] .elevation-mini-chart path {
  fill: rgba(0, 135, 153, 0.25);
  stroke: var(--teal-light);
}

.elevation-mini-chart text {
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  fill: var(--text-muted);
}

/* ============================================================
   EXPORT GPX BUTTON
   ============================================================ */

.export-gpx-button {
  background: var(--bg-subtle) !important;
  color: var(--text-secondary) !important;
  border: 1.5px solid var(--border) !important;
  box-shadow: none !important;
  font-weight: 600;
}

.export-gpx-button:hover {
  background: var(--bg-card) !important;
  border-color: var(--teal) !important;
  color: var(--teal) !important;
  transform: translateY(-1px);
}

/* ============================================================
   LOADING & ERROR STATES
   ============================================================ */

.loading {
  text-align: center;
  color: var(--accent);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 14px;
  animation: pulse 1.5s ease-in-out infinite;
}

.error {
  text-align: center;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 8px;
  background: var(--accent-glow);
  border-radius: 8px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ============================================================
   DIFFICULTY OPTIONS (training)
   ============================================================ */

.difficulty-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  transition: var(--transition-theme), border-color var(--transition-base), transform var(--transition-base);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

input[name="training-difficulty"]:checked + .difficulty-option {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.difficulty-option:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* ============================================================
   PRIORITY SELECTOR
   ============================================================ */

.priority-selector {
  margin: 10px 0;
  padding: 10px;
  background: var(--bg-subtle);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: var(--transition-theme);
}

.priority-label {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  color: var(--teal);
  font-size: 12px;
  margin-bottom: 6px;
  letter-spacing: 0.2px;
  transition: var(--transition-theme);
}

.priority-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  background: var(--teal);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
  position: relative;
  transition: var(--transition-theme);
}

.priority-info-icon:hover .priority-tooltip {
  visibility: visible;
  opacity: 1;
}

.priority-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-card);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 1003;
  transition: opacity 0.2s;
  line-height: 1.5;
  font-family: 'DM Sans', sans-serif;
  box-shadow: var(--shadow-float);
}

.priority-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
}

.priority-tooltip strong {
  color: var(--accent);
}

.priority-options {
  display: flex;
  gap: 6px;
}

.priority-option {
  flex: 1;
  cursor: pointer;
  position: relative;
}

.priority-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.priority-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 4px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  transition: var(--transition-theme), border-color var(--transition-base), transform var(--transition-base);
  font-size: 11px;
  color: var(--text-secondary);
}

.priority-option input[type="radio"]:checked + .priority-text {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.priority-option:hover .priority-text {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(255, 92, 57, 0.2);
}

.priority-name {
  font-weight: 600;
  font-size: 12px;
  font-family: 'Outfit', sans-serif;
}

.priority-desc {
  font-size: 9px;
  opacity: 0.8;
  text-align: center;
  display: none;
}

.priority-option input[type="radio"]:checked + .priority-text .priority-desc {
  opacity: 0.9;
}

/* ============================================================
   LEGEND
   ============================================================ */

.legend {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1.5px solid var(--border);
  transition: var(--transition-theme);
}

.legend-item {
  display: flex;
  align-items: center;
  margin: 7px 0;
  padding: 4px 0;
}

.legend-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-right: 10px;
  cursor: pointer;
  accent-color: var(--accent);
  border-radius: 4px;
  padding: 0;
  border: none;
  background: transparent;
}

.legend-item label {
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-color {
  width: 28px;
  height: 4px;
  margin-right: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-text {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  transition: var(--transition-theme);
}

/* Sidebar legend */
.legend-sidebar {
  padding: 12px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1.5px solid var(--border);
  transition: var(--transition-theme);
}

.legend-header-sidebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--teal);
  transition: var(--transition-theme);
}

.legend-header-sidebar:hover {
  opacity: 0.7;
}

.legend-content-sidebar {
  margin-top: 8px;
  max-height: 250px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: max-height 0.3s ease;
  padding-bottom: 4px;
}

.legend-content-sidebar.collapsed {
  max-height: 0;
  margin-top: 0;
  padding-bottom: 0;
}

/* ============================================================
   FLOATING BUTTONS (right side of map)
   ============================================================ */

#layers-btn,
#menu-btn,
#info-btn,
#geolocate-btn {
  position: fixed;
  right: 20px;
  z-index: 1001;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  cursor: pointer;
  box-shadow: var(--shadow-float);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-theme), transform 0.18s ease, border-color 0.18s ease;
}

#geolocate-btn {
  bottom: 28px;
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  padding: 11px;
}

#layers-menu {
  position: fixed;
  right: 20px;
  bottom: 84px;
  z-index: 1001;
}

#layers-btn {
  position: static;
  width: 46px;
  height: 46px;
}

#menu-btn {
  bottom: 140px;
}

#info-menu {
  position: fixed;
  right: 20px;
  bottom: 196px;
  z-index: 1001;
}

#info-btn {
  position: static;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
}

#layers-btn:hover,
#menu-btn:hover,
#info-btn:hover,
#geolocate-btn:hover {
  border-color: var(--accent);
  transform: scale(1.08);
  background: var(--bg-card);
  box-shadow: var(--shadow-float), 0 0 0 3px var(--accent-glow);
}

#layers-btn:active,
#menu-btn:active,
#info-btn:active,
#geolocate-btn:active {
  transform: scale(0.95);
}

#layers-btn img,
#menu-btn img,
#geolocate-btn img {
  width: 22px;
  height: 22px;
  display: block;
}

/* Iconos de imagen en dark mode → naranja */
[data-theme="dark"] .location-btn img,
[data-theme="dark"] #geolocate-btn img,
[data-theme="dark"] #layers-btn img,
[data-theme="dark"] #menu-btn img {
  filter: brightness(0) saturate(100%) invert(52%) sepia(80%) saturate(600%) hue-rotate(332deg) brightness(105%);
}

/* Layers submenu */
#layers-submenu {
  position: absolute;
  bottom: 56px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  padding-bottom: 10px;
}

#layers-menu:hover #layers-submenu,
#layers-menu.active #layers-submenu {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

#layers-submenu button {
  background: var(--bg-card);
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-float);
  transition: var(--transition-theme), transform 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text-primary);
}

#layers-submenu button:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  transform: scale(1.1);
  box-shadow: var(--shadow-float);
}

/* Info submenu */
#info-submenu {
  position: absolute;
  bottom: 0;
  right: 58px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-float);
  padding: 6px 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  transition: var(--transition-theme), opacity 0.2s ease, transform 0.2s ease;
}

#info-menu.active #info-submenu {
  opacity: 1;
  pointer-events: all;
  transform: translateX(0);
}

#info-submenu a {
  display: block;
  padding: 10px 18px;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition-base), color var(--transition-base);
}

#info-submenu a:hover {
  background: var(--bg-subtle);
  color: var(--teal);
}

/* ============================================================
   SIDEBAR BLOG LINK
   ============================================================ */

.sidebar-blog-link {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  transition: var(--transition-theme);
}

.sidebar-blog-link a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--teal);
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  transition: background var(--transition-base), color var(--transition-base),
              border-color var(--transition-base), box-shadow var(--transition-base);
}

.sidebar-blog-link a:hover {
  background: var(--bg-card);
  border-color: var(--teal-light);
  color: var(--teal-light);
  box-shadow: 0 2px 8px rgba(0, 98, 114, 0.12);
}

[data-theme="dark"] .sidebar-blog-link a {
  color: var(--text-secondary);
  border-color: var(--border);
}

[data-theme="dark"] .sidebar-blog-link a:hover {
  color: var(--text-primary);
  border-color: var(--teal-light);
}

.sidebar-blog-link svg {
  flex-shrink: 0;
  opacity: 0.75;
  transition: var(--transition-theme);
}

.sidebar-blog-link a:hover svg {
  opacity: 1;
}

/* ============================================================
   MODAL
   ============================================================ */

.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.55);
  animation: fadeIn 0.2s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 28px;
  border-radius: var(--radius-card);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-float);
  animation: slideUp 0.3s ease;
  border: 1px solid var(--border);
  transition: var(--transition-theme);
}

.modal-close {
  position: absolute;
  right: 18px;
  top: 16px;
  font-size: 26px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-base);
  background: none;
  border: none;
  padding: 4px;
  border-radius: 6px;
}

.modal-close:hover {
  color: var(--accent);
  background: var(--accent-glow);
  transform: none;
  box-shadow: none;
}

.modal-content h2 {
  margin: 0 0 14px;
  font-size: 22px;
}

.modal-content h3 {
  margin: 14px 0 8px;
  font-size: 15px;
}

.modal-content p,
.modal-content ul {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0 0 10px;
  transition: var(--transition-theme);
}

.modal-content ul {
  padding-left: 20px;
}

.modal-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.modal-content a {
  color: var(--teal);
  transition: color var(--transition-base);
}

.modal-content a:hover {
  color: var(--accent);
}

/* ============================================================
   ROUTE INFO MOBILE (bottom sheet)
   ============================================================ */

#route-info-mobile {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.14);
  z-index: 1002;
  max-height: 50vh;
  overflow-y: auto;
  padding: 18px 16px 16px;
  transform: translateY(100%);
  transition: transform 0.3s ease, background-color 0.25s ease;
  border-top: 1px solid var(--border);
}

#route-info-mobile.visible {
  transform: translateY(0);
}

#route-info-mobile.compact {
  transform: translateY(calc(100% - 80px));
}

#route-info-mobile.compact #mobile-elevation-chart,
#route-info-mobile.compact .actions {
  display: none;
}

#route-info-mobile .handle {
  width: 38px;
  height: 4px;
  background: var(--lime);
  border-radius: 2px;
  margin: -6px auto 14px;
  cursor: pointer;
}

#route-info-mobile .route-stats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
}

#route-info-mobile .stat-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 9px 8px;
  border-radius: 10px;
  text-align: center;
  flex: 1;
  min-width: 68px;
  transition: var(--transition-theme);
}

#route-info-mobile .stat-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#route-info-mobile .stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--teal);
}

#route-info-mobile .actions {
  display: flex;
  gap: 10px;
}

#route-info-mobile .btn-download {
  flex: 1;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(255, 92, 57, 0.28);
}

#route-info-mobile .btn-download:hover {
  background: var(--accent-hover);
  transform: none;
  box-shadow: 0 4px 12px rgba(255, 92, 57, 0.38);
}

#route-info-mobile .btn-close {
  flex: 1;
  padding: 12px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 14px;
}

#route-info-mobile .btn-close:hover {
  background: var(--bg-card);
  border-color: var(--text-secondary);
  transform: none;
  box-shadow: none;
}

/* ============================================================
   ROUTE COMPACT (mobile, post-route)
   ============================================================ */

.route-compact {
  display: none;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: 14px;
  cursor: pointer;
  border: 1.5px solid var(--teal);
  transition: var(--transition-theme);
  box-shadow: var(--shadow-card);
}

.route-compact:active {
  transform: scale(0.98);
}

/* ============================================================
   COMPACT MODE — DESKTOP HIDDEN
   ============================================================ */

#training-mode-compact,
.route-compact {
  display: none !important;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Map tile animations */
.leaflet-tile-container {
  transition: opacity 0.2s ease-in-out;
}

.leaflet-tile {
  transition: opacity 0.2s ease-in-out;
}

.leaflet-tile-loaded {
  animation: fadeInTile 0.2s ease-in-out;
}

@keyframes fadeInTile {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.cycle-layer-smooth img {
  transition: opacity 0.3s ease-in-out;
}

.cycle-overlay-enhanced {
  filter: contrast(2.5) saturate(3) brightness(1.3);
  mix-blend-mode: multiply;
  opacity: 1;
}

.cycle-overlay-enhanced img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.leaflet-tile-pane,
.leaflet-layer {
  will-change: transform;
}

/* ============================================================
   LEAFLET OVERRIDES
   ============================================================ */

.leaflet-control-zoom {
  border: 1.5px solid var(--border) !important;
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: var(--shadow-float) !important;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  background: var(--bg-card) !important;
  color: var(--text-secondary) !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: 18px !important;
  transition: var(--transition-theme);
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
  background: var(--bg-subtle) !important;
  color: var(--accent) !important;
}

/* ============================================================
   RESPONSIVE — MOBILE (≤768px)
   ============================================================ */

@media (max-width: 768px) {
  #route-info-mobile {
    display: block;
  }

  body.route-active #route-info {
    display: none;
  }

  body.route-active #sidebar {
    overflow: hidden;
  }

  .leaflet-control-zoom {
    display: none !important;
  }

  #sidebar {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    bottom: auto;
    max-height: 52vh;
  }

  .sidebar-container {
    padding: 18px 16px;
    border-radius: 16px;
  }

  #sidebar .search-extra-buttons {
    display: none;
  }

  #sidebar.search-expanded .search-extra-buttons {
    display: block;
  }

  /* Compact route in mobile */
  .route-compact {
    display: none;
    padding: 12px 14px;
  }

  body.route-active .route-compact {
    display: block !important;
  }

  body.route-active #route-mode-expanded {
    display: none;
  }

  body.route-active.route-expanded .route-compact {
    display: none !important;
  }

  body.route-active.route-expanded #route-mode-expanded {
    display: block;
  }

  /* Compact training in mobile */
  #training-mode-compact {
    display: none !important;
  }

  body.training-active #training-mode-compact {
    display: block !important;
  }

  body.training-active #training-mode-expanded {
    display: none !important;
  }

  body.training-active.training-expanded #training-mode-compact {
    display: none !important;
  }

  body.training-active.training-expanded #training-mode-expanded {
    display: block !important;
  }

  h1 {
    font-size: 20px !important;
  }

  img[alt="BiciMap Logo"] {
    height: 38px !important;
  }

  .search-box {
    gap: 8px !important;
  }

  input[type="text"],
  input[type="search"] {
    font-size: 16px !important;
    padding: 12px 44px 12px 14px !important;
  }

  button {
    font-size: 15px !important;
    min-height: 46px;
  }

  .location-btn {
    width: 34px !important;
    height: 34px !important;
    right: 6px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    padding: 6px !important;
    border-radius: 50% !important;
    min-height: auto !important;
  }

  .location-btn img {
    width: 18px !important;
    height: 18px !important;
  }

  #layers-menu {
    bottom: 76px !important;
    right: 15px !important;
  }

  #layers-btn {
    bottom: 76px !important;
    right: 15px !important;
  }

  #layers-btn,
  #menu-btn {
    width: 44px !important;
    height: 44px !important;
    padding: 10px !important;
  }

  #menu-btn {
    bottom: 130px !important;
    right: 15px !important;
  }

  #info-menu {
    bottom: 184px !important;
    right: 15px !important;
  }

  #info-btn {
    width: 44px !important;
    height: 44px !important;
  }

  #layers-btn img,
  #menu-btn img {
    width: 22px !important;
    height: 22px !important;
  }

  #layers-submenu button {
    width: 44px !important;
    height: 44px !important;
    font-size: 20px !important;
  }

  @media (max-width: 768px) {
    #layers-menu:hover #layers-submenu {
      opacity: 0 !important;
      pointer-events: none !important;
      transform: translateY(10px) !important;
    }

    #layers-menu.active #layers-submenu {
      opacity: 1 !important;
      pointer-events: all !important;
      transform: translateY(0) !important;
    }
  }

  #geolocate-btn {
    width: 48px !important;
    height: 48px !important;
    bottom: 20px !important;
    right: 15px !important;
    padding: 10px !important;
  }

  #geolocate-btn img {
    width: 24px !important;
    height: 24px !important;
  }

  .autocomplete-dropdown {
    max-height: 150px !important;
    font-size: 13px !important;
  }

  .autocomplete-item {
    padding: 11px 12px !important;
    min-height: 44px;
  }

  #route-info {
    font-size: 12px !important;
    padding: 10px 0 0 !important;
    max-height: 35vh !important;
    overflow-y: auto !important;
  }

  #route-info .info-item {
    margin: 4px 0 !important;
    font-size: 12px !important;
  }

  #route-info button {
    padding: 10px !important;
    font-size: 13px !important;
    min-height: 40px !important;
  }

  #route-info select {
    font-size: 11px !important;
  }

  .legend-sidebar {
    position: fixed !important;
    bottom: 80px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    min-width: 200px !important;
    z-index: 1001 !important;
    pointer-events: auto !important;
  }

  .modal-content {
    width: 95%;
    padding: 20px;
    max-height: 90vh;
  }

  .modal-content h2 {
    font-size: 20px;
  }

  .priority-selector {
    padding: 10px;
  }

  .priority-options {
    gap: 5px;
  }

  .priority-text {
    padding: 7px 3px;
  }

  .priority-name {
    font-size: 11px;
  }
}
