/* app/styles/map.css */
/* Load this after Leaflet’s CSS and your Tailwind layers */

/* 1) Remove Leaflet’s default popup styling */
.leaflet-popup-content-wrapper {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
}

/* 2) Hide the popup arrow */
.leaflet-popup-tip-container {
  display: none !important;
}

/* 2b) Reset popup content margin */
.leaflet-popup-content {
  margin: 0 !important;
}

/* 2c) Hide any Leaflet close button - popup closes by tapping map */
.leaflet-popup-close-button {
  display: none !important;
}

/* Mobile: compact popup */
@media (max-width: 768px) {

  /* Force smaller popup container */
  .spot-popup-modern .leaflet-popup-content-wrapper {
    padding: 0 !important;
  }

  .spot-popup-modern .leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 160px !important;
  }

  /* Shrink popup card */
  .spot-popup-modern .spot-popup-card {
    width: 160px !important;
    border-radius: 10px !important;
  }

  /* Hide image on mobile to save height */
  .spot-popup-modern .spot-popup-card > div:first-child {
    display: none !important;
  }

  /* Compact content */
  .spot-popup-modern .spot-popup-card > div:last-child {
    padding: 8px !important;
  }

  /* Smaller fonts */
  .spot-popup-modern .spot-popup-card h3 {
    font-size: 12px !important;
  }

  /* Smaller button */
  .spot-popup-modern .spot-popup-card a {
    padding: 5px 8px !important;
    font-size: 10px !important;
    border-radius: 6px !important;
  }
}

/* 3a) Reset plain links (non-buttons) */
.leaflet-popup--shadcn .leaflet-popup-content-wrapper a:not(.inline-flex) {
  color: inherit !important;
  text-decoration: none !important;
}

/* 3b) Force white text on primary buttons */
.leaflet-popup--shadcn .leaflet-popup-content-wrapper a.inline-flex.bg-primary {
  color: hsl(var(--primary-foreground)) !important;
}

/* 3c) Force black text on outline buttons */
.leaflet-popup--shadcn
  .leaflet-popup-content-wrapper
  a.inline-flex:not(.bg-primary) {
  color: hsl(var(--foreground)) !important;
}

/* ============================================= */
/* Bottom Sheet (Vaul Drawer) Overrides         */
/* ============================================= */

/* Ensure drawer content has proper touch handling */
[vaul-drawer] {
  touch-action: none;
}

/* Remove vaul's default overlay */
[vaul-drawer]::after {
  content: none !important;
}

/* Ensure backdrop blur works on all browsers */
[vaul-drawer] > div {
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

/* Safe area padding for notched phones */
[vaul-drawer] .pb-safe {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Smooth snap transitions */
[vaul-drawer-content] {
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Handle drag state */
[vaul-drawer-content][data-dragging="true"] {
  transition: none;
}

/* ============================================= */
/* Leaflet Zoom Controls - Glassmorphism Style  */
/* ============================================= */

.leaflet-control-zoom {
  border: none !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  margin-bottom: 120px !important; /* Space for FABs */
  margin-right: 70px !important; /* Space from right edge for visibility */
}

.leaflet-control-zoom a {
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #374151 !important;
  border: none !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
  font-weight: 300 !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.leaflet-control-zoom a:first-child {
  border-radius: 12px 12px 0 0 !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
}

.leaflet-control-zoom a:last-child {
  border-radius: 0 0 12px 12px !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(255, 255, 255, 0.95) !important;
  color: #111827 !important;
}

.leaflet-control-zoom a:active {
  transform: scale(0.95);
}

/* Hide zoom controls on mobile (pinch to zoom) */
@media (max-width: 768px) {
  .leaflet-control-zoom {
    display: none !important;
  }
}

/* Attribution styling */
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.7) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 6px !important;
  padding: 2px 8px !important;
  font-size: 10px !important;
  color: #6b7280 !important;
  margin: 8px !important;
}

.leaflet-control-attribution a {
  color: #6b7280 !important;
}

/* Mobile: Move attribution to top-left corner */
@media (max-width: 768px) {
  .leaflet-control-attribution {
    position: fixed !important;
    top: 12px !important;
    left: 12px !important;
    bottom: auto !important;
    right: auto !important;
    z-index: 999 !important;
    font-size: 9px !important;
    padding: 2px 6px !important;
    max-width: 150px;
  }
}

/* ============================================= */
/* Spot Marker Styling - Apple Maps Style       */
/* ============================================= */

/* Remove default Leaflet marker styles */
.spot-marker-container {
  background: transparent !important;
  border: none !important;
}

/* Hover effect for markers */
.spot-marker-container:hover .spot-marker {
  transform: scale(1.15) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.15) !important;
}

/* Selected marker pulse animation */
@keyframes marker-pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0,0,0,0.25), 0 0 0 0 rgba(239,68,68,0.4);
  }
  50% {
    box-shadow: 0 4px 12px rgba(0,0,0,0.25), 0 0 0 8px rgba(239,68,68,0);
  }
}

.spot-marker.selected {
  animation: marker-pulse 2s ease-in-out infinite;
}

/* Marker label styling (adaptive labels) - desktop only */
.spot-marker-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  padding: 2px 6px;
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  font-size: 10px;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  line-height: 1.2;
}

.spot-marker-label.visible {
  opacity: 1;
}

/* Mobile label adjustments - slightly smaller */
@media (max-width: 768px) {
  .spot-marker-label {
    font-size: 9px;
    padding: 2px 5px;
    max-width: 80px;
  }
}

/* Cluster marker styling */
.marker-cluster {
  background: rgba(107, 114, 128, 0.9) !important;
  border: 2.5px solid white !important;
  border-radius: 50% !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

.marker-cluster div {
  background: transparent !important;
  color: white !important;
  font-weight: 700 !important;
  font-size: 13px !important;
}

.marker-cluster:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25) !important;
}
