/* Modern Map Styling */
.map-container {
  height: 400px;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
}

/* Mapbox specific styling */
.mapboxgl-map {
  border-radius: 16px;
  overflow: hidden;
}

.mapboxgl-ctrl-geocoder {
  min-width: 200px;
  max-width: 100%;
  font-size: 14px;
  flex: 1;
}

.mapboxgl-ctrl-geocoder input {
  height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.mapboxgl-ctrl-geocoder--suggestion {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.mapboxgl-ctrl-geocoder--suggestion:last-child {
  border-bottom: none;
}

.mapboxgl-ctrl-geocoder--suggestion-title {
  font-weight: 600;
  color: #374151;
}

.mapboxgl-ctrl-geocoder--suggestion-address {
  font-size: 12px;
  color: #6b7280;
}

/* Hide the clear button in Mapbox geocoder inputs */
.mapboxgl-ctrl-geocoder--button {
  display: none !important;
}

.mapboxgl-ctrl-geocoder--pin-right {
  display: none !important;
}

/* Hide the search icon in Mapbox geocoder inputs */
.mapboxgl-ctrl-geocoder--icon-search {
  display: none !important;
}

/* Constrain geocoder width to prevent overflow */
#pickup-geocoder-container {
  max-width: calc(100% - 80px); /* Leave space for the Find button */
  min-width: 200px;
}

#dest-geocoder-container {
  max-width: 100%;
  min-width: 200px;
}

/* Mapbox marker styling */
.mapboxgl-marker {
  transition: all 0.3s ease;
  cursor: pointer;
  z-index: 1000 !important;
}

.mapboxgl-marker:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.4));
}

/* Ensure Mapbox markers are visible */
.mapboxgl-marker-anchor-center {
  z-index: 1000 !important;
}

.mapboxgl-marker-anchor-top {
  z-index: 1000 !important;
}

.mapboxgl-marker-anchor-bottom {
  z-index: 1000 !important;
}

/* Mapbox marker animation */
@keyframes mapbox-marker-appear {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.mapboxgl-marker {
  animation: mapbox-marker-appear 0.3s ease-out;
}

/* Modern Map Controls */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  border: none !important;
  color: #374151 !important;
  font-weight: 600 !important;
  transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
  background: rgba(59, 130, 246, 0.1) !important;
  color: #1d4ed8 !important;
}

.leaflet-control-zoom a:active {
  background: rgba(59, 130, 246, 0.2) !important;
}

/* Modern Map Attribution */
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.9) !important;
  backdrop-filter: blur(10px);
  border-radius: 8px !important;
  font-size: 11px !important;
  color: #6b7280 !important;
  padding: 4px 8px !important;
  margin: 8px !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

/* Custom Map Tiles - Cleaner Look */
.leaflet-tile {
  filter: brightness(1.05) contrast(1.1) saturate(1.1);
}

/* Modern Markers - Enhanced Visibility */
.leaflet-marker-icon {
  transition: all 0.3s ease;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.25));
  z-index: 1000 !important;
  cursor: pointer !important;
}

.leaflet-marker-icon:hover {
  transform: scale(1.2);
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.35));
  z-index: 1001 !important;
}

/* Enhanced marker visibility with outer glow */
.leaflet-marker-icon::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
}

/* Pickup Marker - Much Bigger and More Visible */
.pickup-marker {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  border: 4px solid white !important;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4) !important;
  animation: pulse-green 2s infinite, marker-appear 0.5s ease-out;
  border-radius: 50% !important;
  width: 48px !important;
  height: 48px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 20px !important;
}

@keyframes marker-appear {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(-90deg);
    opacity: 0.8;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.pickup-marker i,
.pickup-marker div {
  color: white !important;
  font-size: 20px !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

@keyframes pulse-green {
  0%, 100% {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.6);
    transform: scale(1.05);
  }
}

/* Destination Marker - Much Bigger and More Visible */
.dest-marker {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  border: 4px solid white !important;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4) !important;
  animation: pulse-red 2s infinite, marker-appear 0.5s ease-out;
  border-radius: 50% !important;
  width: 48px !important;
  height: 48px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 20px !important;
}

.dest-marker i,
.dest-marker div {
  color: white !important;
  font-size: 20px !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

@keyframes pulse-red {
  0%, 100% {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.6);
    transform: scale(1.05);
  }
}

/* Driver Markers - Much Bigger and More Visible */
.driver-marker {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  border: 4px solid white !important;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4) !important;
  transition: all 0.3s ease;
  animation: marker-appear 0.5s ease-out;
  border-radius: 50% !important;
  width: 44px !important;
  height: 44px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 18px !important;
}

.driver-marker i,
.driver-marker div {
  color: white !important;
  font-size: 18px !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.driver-marker:hover {
  transform: scale(1.2);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5) !important;
}

/* Route Line Styling */
.leaflet-routing-container {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  border-radius: 12px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  margin: 8px !important;
  padding: 12px !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

.leaflet-routing-container h2 {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #374151 !important;
  margin-bottom: 8px !important;
}

.leaflet-routing-alt {
  max-height: 200px !important;
  overflow-y: auto !important;
}

.leaflet-routing-alt h3 {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #6b7280 !important;
  margin: 4px 0 !important;
}

.leaflet-routing-alt tr {
  font-size: 11px !important;
  color: #374151 !important;
}

/* Map Instructions */
.map-instruction {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
  font-weight: 500 !important;
  z-index: 1000;
}

/* Modern Popup Styling */
.leaflet-popup-content-wrapper {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  padding: 16px !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  color: #374151 !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
}

.leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

/* Map Loading State */
.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 16px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 1000;
}

.map-loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Map Container Enhancements */
.map-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.02), rgba(16, 185, 129, 0.02));
  pointer-events: none;
  z-index: 1;
}

/* Responsive Map Controls */
@media (max-width: 768px) {
  .map-container {
    height: 300px;
    border-radius: 12px;
  }
  
  .leaflet-control-zoom {
    transform: scale(0.9);
  }
  
  .map-instruction {
    font-size: 12px !important;
    padding: 8px 12px !important;
  }
  
  .map-legend {
    font-size: 10px;
    padding: 6px 8px;
    gap: 12px;
  }
  
  .map-legend-item {
    gap: 4px;
  }
  
  .map-legend-dot {
    width: 8px;
    height: 8px;
  }
  
  /* Ensure markers remain visible on mobile */
  .pickup-marker,
  .dest-marker,
  .driver-marker {
    width: 40px !important;
    height: 40px !important;
    font-size: 16px !important;
  }
  
  .pickup-marker i,
  .pickup-marker div,
  .dest-marker i,
  .dest-marker div,
  .driver-marker i,
  .driver-marker div {
    font-size: 16px !important;
  }
  
  /* Adjust icon sizes for mobile */
  .leaflet-marker-icon {
    width: 40px !important;
    height: 40px !important;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .leaflet-control-zoom a {
    background: rgba(31, 41, 55, 0.95) !important;
    color: #d1d5db !important;
  }
  
  .leaflet-control-zoom a:hover {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
  }
  
  .leaflet-control-attribution {
    background: rgba(31, 41, 55, 0.9) !important;
    color: #9ca3af !important;
  }
  
  .leaflet-popup-content-wrapper {
    background: rgba(31, 41, 55, 0.95) !important;
    color: #d1d5db !important;
  }
  
  .leaflet-popup-tip {
    background: rgba(31, 41, 55, 0.95) !important;
  }
}

/* Map Interaction Enhancements */
.leaflet-interactive {
  transition: all 0.2s ease;
}

.leaflet-interactive:hover {
  stroke-width: 3 !important;
  stroke-opacity: 0.8 !important;
}

/* Custom Map Tile Overlay */
.map-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.03) 0%,
    rgba(16, 185, 129, 0.03) 100%
  );
  pointer-events: none;
  z-index: 2;
}

/* Map Legend */
.map-legend {
  position: static;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 11px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.map-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid white;
  flex-shrink: 0;
}

.map-legend-dot.pickup {
  background: linear-gradient(135deg, #10b981, #059669);
}

.map-legend-dot.destination {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.map-legend-dot.driver {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
} 