/* Mobile detection CSS variables */
.mobile-device {
  --header-height: 32px; /* Same as desktop - was 28px */
  --header-padding: 4px;
  --stats-font-size: 0.75rem;
  --stats-gap: 4px;
  --controls-gap: 4px;
}

/* Desktop-specific CSS variables */
.desktop-device {
  --header-height: 32px;
  --header-padding: 8px;
  --stats-font-size: 0.875rem;
  --stats-gap: 8px;
  --controls-gap: 8px;
}

#bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px; /* Default closed height - will be expanded via JS when needed */
  background-color: var(--bottom-bar-bg);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  /* Removed transition: height 0.3s ease; to prevent hover effects */
}

#bottom-bar.collapsed {
  height: 32px; /* RESTORE: Original working height */
  overflow: visible; /* Changed to visible to prevent toggle button cut-off */
  min-height: 32px; /* Ensure consistent collapsed height */
}

#bottom-bar.collapsed #elevation-profile {
  display: none !important; /* Completely hide elevation profile when collapsed */
}

#bottom-bar.collapsed #elevation-stats .ascent,
#bottom-bar.collapsed #elevation-stats .descent,
#bottom-bar.collapsed #elevation-stats .separator {
  display: none !important; /* Hide ascent/descent stats when collapsed */
}

#bottom-bar.collapsed #elevation-stats .distance {
  display: flex !important; /* Keep distance label visible when collapsed */
}

#bottom-bar-header {
  position: relative;
  height: var(--header-height);
  background-color: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  padding: 0 8px;
  user-select: none;
  font-weight: 500;
  color: #333;
  min-height: var(--header-height);
  flex-shrink: 0;
}

/* Remove the old drag handle styling */
#bottom-bar-header::after {
  display: none;
}

#bottom-bar-header:hover::after {
  display: none;
}

#elevation-stats {
  flex: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.875rem;
  color: var(--text-color);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
  position: relative;
}

#elevation-stats .distance {
  font-weight: 600;
  color: var(--text-color);
}

#elevation-stats .separator {
  color: #999;
  font-size: 0.75rem;
}

#elevation-stats .ascent {
  color: #059669;
  font-weight: 500;
}

#elevation-stats .descent {
  color: #dc2626;
  font-weight: 500;
}

/* New integrated toggle handle */
#integrated-toggle-handle {
  position: absolute;
  left: 50%;
  top: -20px; /* Fixed distance above bar header - always the same */
  transform: translateX(-50%);
  width: 40px; /* RESTORE: Original working size */
  height: 40px; /* RESTORE: Original working size */
  background-color: #ffffff; /* RESTORE: Original working styling */
  border: 1px solid #ddd; /* RESTORE: Original working styling */
  border-radius: 50%; /* Make it completely round */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease; /* RESTORE: Original working transition */
  z-index: 99999; /* High z-index to ensure it's on top */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* RESTORE: Original working shadow */
  touch-action: manipulation; /* RESTORE: Original working touch handling */
  -webkit-tap-highlight-color: transparent; /* RESTORE: Original working touch handling */
  pointer-events: auto; /* Ensure pointer events work */
  max-width: 100vw; /* Prevent overflow */
}

#integrated-toggle-handle:hover {
  background-color: #f8f9fa;
  border-color: #999;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  /* Removed translateY(-2px) as it interferes with click detection */
  transform: translateX(-50%);
}

#integrated-toggle-handle:active {
  background-color: #e9ecef;
  transform: translateX(-50%) scale(0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#integrated-toggle-handle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
  color: #495057;
}

#integrated-toggle-handle.collapsed svg {
  transform: rotate(180deg); /* Point UP when collapsed (to expand) */
}

#integrated-toggle-handle:not(.collapsed) svg {
  transform: rotate(0deg); /* Point DOWN when open (to collapse) */
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
  #integrated-toggle-handle {
    /* Remove width/height changes - keep it round like desktop */
    /* width: 80px; */
    /* height: 40px; */
    /* border-radius: 20px; */
  }
  
  #integrated-toggle-handle svg {
    width: 24px;
    height: 24px;
  }
  
  /* Ensure proper bottom bar height on mobile */
  #bottom-bar {
    min-height: var(--min-bottom-bar-height);
  }
  
  /* Mobile-specific bottom container positioning */
  #bottom-container {
    padding-top: 20px; /* Reduce padding on mobile */
  }
  
  /* Ensure elevation profile has proper height on mobile */
  #elevation-profile {
    min-height: 150px; /* Minimum height for mobile */
  }
}

/* Mobile device specific styles using CSS classes */
.mobile-device #bottom-bar-header {
  padding: 0 var(--header-padding);
}

.mobile-device #elevation-stats {
  font-size: var(--stats-font-size);
  gap: var(--stats-gap);
}

.mobile-device #elevation-stats .separator {
  font-size: 0.65rem; /* Smaller separators */
}

.mobile-device #header-controls {
  gap: var(--controls-gap);
  padding-right: var(--header-padding);
}

.mobile-device #language-selector {
  display: block; /* Show language selector on mobile */
  font-size: 10px; /* Smaller font size for mobile */
  padding: 2px 4px; /* More compact padding */
  height: 20px; /* Smaller height */
  min-width: 60px; /* Ensure minimum width for touch */
}

.mobile-device #unit-toggle {
  padding: 2px 6px; /* More compact padding */
  font-size: 11px; /* Smaller font */
  height: 20px; /* Smaller height */
  min-width: 50px; /* Ensure minimum width for touch */
}

/* Additional mobile optimizations */
.mobile-device #bottom-bar-header {
  min-height: 28px; /* Slightly reduce header height on mobile */
}

.mobile-device #integrated-toggle-handle {
  top: -16px; /* Adjust position for smaller header */
  width: 40px; /* Keep same width as desktop for circular shape */
  height: 40px; /* Keep same height as desktop for circular shape */
}

/* Touch-friendly improvements for mobile */
.mobile-device #integrated-toggle-handle {
  touch-action: manipulation; /* Prevent zoom on double-tap */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
}

.mobile-device #unit-toggle {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border-radius: 6px; /* Slightly more rounded for touch */
}

.mobile-device #language-selector {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border-radius: 6px; /* Slightly more rounded for touch */
}

/* Ensure proper spacing on very small screens */
@media (max-width: 480px) {
  .mobile-device #bottom-bar-header {
    padding: 0 2px; /* Even less padding on very small screens */
  }
  
  .mobile-device #elevation-stats {
    font-size: 0.7rem; /* Even smaller font on very small screens */
    gap: 2px; /* Minimal gap */
  }
  
  .mobile-device #unit-toggle {
    padding: 1px 4px; /* Minimal padding */
    font-size: 10px; /* Smaller font */
    min-width: 45px; /* Ensure it's still touchable */
  }
  
  .mobile-device #language-selector {
    padding: 1px 3px; /* Minimal padding */
    font-size: 9px; /* Smaller font */
    min-width: 50px; /* Ensure it's still touchable */
    height: 18px; /* Smaller height */
  }
  
  /* Very small screen bottom bar adjustments */
  #bottom-bar {
    min-height: 180px; /* Slightly smaller minimum height */
  }
  
  #elevation-profile {
    min-height: 120px; /* Smaller minimum height for very small screens */
  }
  
  #bottom-container {
    padding-top: 16px; /* Even less padding on very small screens */
  }
}

#header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding-right: 8px;
  z-index: 5;
  position: relative;
}

#unit-toggle {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  height: 24px;
  display: flex;
  align-items: center;
  transition: background-color 0.1s ease;
}

#elevation-profile {
  flex: 1;
  width: 100%;
  height: calc(100% - var(--header-height));
  position: relative;
  overflow: hidden;
  padding: 0 16px 0 8px; /* Add right margin for easier hovering, small left padding for balance */
  box-sizing: border-box;
}

/* Hide elevation profile when collapsed but keep header overflow visible */
#bottom-bar.collapsed #elevation-profile {
  display: none;
}

#elevation-profile canvas {
  width: 100% !important;
  height: 100% !important;
  cursor: crosshair !important;
  /* Canvas will respect the container's padding due to box-sizing: border-box */
}

/* Deployment info styling */
.deployment-info {
  position: absolute;
  bottom: 8px;
  right: 16px;
  z-index: 10;
  pointer-events: none; /* Don't interfere with chart interactions */
}

.deployment-info span {
  font-size: 10px;
  color: rgba(128, 128, 128, 0.7);
  background: rgba(255, 255, 255, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Mobile-specific deployment info adjustments */
@media (max-width: 768px) {
  .deployment-info {
    bottom: 4px;
    right: 12px;
  }
  
  .deployment-info span {
    font-size: 9px;
    padding: 1px 4px;
  }
}

@media (max-width: 480px) {
  .deployment-info {
    bottom: 2px;
    right: 8px;
  }
  
  .deployment-info span {
    font-size: 8px;
    padding: 1px 3px;
  }
}

/* Bottom controls positioning */
#bottom-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
  padding-top: 24px; /* Add space for the toggle button that extends above */
}

#bottom-controls {
  /* Positioning now handled by components.css */
}

#bottom-controls > * {
  pointer-events: auto;
}

#geocoder-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Geocoder input styles moved to components.css for collapsible functionality */

#bottom-right-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

#distance-display {
  background: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.toggle-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.toggle-button svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.toggle-button.collapsed svg {
  transform: rotate(180deg);
} 