/* Efficient CSS-based map marker icons */

/* Remove default Leaflet divIcon styling */
.custom-css-marker {
  background: transparent !important;
  border: none !important;
}

/* Simple dot marker - most efficient */
.marker-dot {
  width: 18px;
  height: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  z-index: 10;
}

.marker-dot:not(.meshtastic-node)::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  background: white;
  border: 6px solid #dc2626;
  border-radius: 50%;
  box-shadow: 0 0 0 1px black, 0 2px 4px rgba(220, 38, 38, 0.4);
  pointer-events: none;
  z-index: 2;
}

.marker-dot.meshtastic-node {
  background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.6);
}

.marker-dot:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 1500 !important;
}

/* Tooltip Styles - Now handled by global tooltip system */
.marker-tooltip {
  display: none; /* Disabled - using global tooltip */
}

.marker-tooltip:before {
  display: none; /* Disabled - using global tooltip */
}

.marker-dot:hover .marker-tooltip {
  display: none; /* Disabled - using global tooltip */
}

.tooltip-category {
  font-weight: 600;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tooltip-category-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.tooltip-info {
  font-size: 10px;
  opacity: 0.9;
  line-height: 1.2;
}

/* Color Legend */
.color-legend {
  position: fixed;
  top: 75px;
  right: 20px;
  background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 2999;
  color: white;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  min-width: 220px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
}

.legend-header {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
  border-bottom: 1px solid rgba(139, 92, 246, 0.3);
  padding-bottom: 10px;
  color: #a855f7;
  letter-spacing: 0.5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 11px;
  line-height: 1.4;
  padding: 4px 0;
  transition: all 0.2s ease;
}

.legend-item:hover {
  background: rgba(139, 92, 246, 0.1);
  border-radius: 6px;
  padding-left: 6px;
  padding-right: 6px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.color-legend.collapsed {
  transform: translateX(calc(100% + 30px)) scale(0.95);
  opacity: 0;
}

/* Legend Button States */
#legendToggle:hover {
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.6), inset 0 2px 4px rgba(0,0,0,0.3);
  border-color: #a855f7;
}

#legendToggle:active {
  transform: scale(0.98);
}

#legendToggle.active {
  background: linear-gradient(145deg, #5b21b6, #6d28d9);
}

#legendToggle.active > div {
  transform: translateX(30px);
  background: linear-gradient(145deg, #a855f7, #9333ea);
}

@media (max-width: 768px) {
  .color-legend {
    top: auto;
    bottom: 20px;
    right: 10px;
    left: 10px;
    min-width: auto;
    padding: 14px;
  }
  
  .legend-header {
    font-size: 12px;
  }
  
  .legend-item {
    font-size: 10px;
    margin-bottom: 6px;
  }
}

/* Pin-style marker */
.marker-pin {
  width: 20px;
  height: 20px;
  background: #ff4444;
  border: 2px solid #ffffff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  cursor: pointer;
}

.marker-pin::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-radius: 50%;
}

/* All markers now use the same red color - category colors removed */

/* Animated pulse for active markers */
.marker-active::before,
.marker-newest::before,
.marker-dot.marker-newest::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  z-index: -1;
}

.marker-active::before {
  animation: pulse-ring 2s infinite;
}

.marker-newest::before,
.marker-dot.marker-newest::before {
  animation: pulse-ring-newest 2s infinite;
}

@keyframes pulse-ring {
  0% { 
    width: 20px;
    height: 20px;
    opacity: 0.9;
  }
  50% { 
    width: 40px;
    height: 40px;
    opacity: 0.5;
  }
  100% { 
    width: 60px;
    height: 60px;
    opacity: 0;
  }
}

@keyframes pulse-ring-newest {
  0% { 
    width: 20px;
    height: 20px;
    opacity: 0.95;
  }
  50% { 
    width: 35px;
    height: 35px;
    opacity: 0.6;
  }
  100% { 
    width: 50px;
    height: 50px;
    opacity: 0;
  }
}

/* Size variants */
.marker-small { 
  width: 8px; 
  height: 8px; 
  border-width: 1px;
}

.marker-large { 
  width: 16px; 
  height: 16px; 
  border-width: 3px;
}

/* Cluster indicator */
.marker-cluster {
  background: #333;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  min-width: 20px;
  height: 20px;
  padding: 2px;
}

/* Premium Legend Panel Styles - CENTERED */
#legendOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#legendPanel {
  position: fixed;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  z-index: 10000;
  background: linear-gradient(145deg, rgba(35, 39, 43, 0.98), rgba(26, 29, 35, 0.98));
  backdrop-filter: blur(10px);
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(139, 92, 246, 0.2);
  display: block;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 280px;
  max-width: 320px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  pointer-events: none;
}

#legendPanel.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%);
  pointer-events: auto;
}

#legendPanel .legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  transition: all 0.2s;
  cursor: pointer;
  margin-bottom: 0.3rem;
}

#legendPanel .legend-item:hover {
  background: rgba(139, 92, 246, 0.15);
  transform: translateX(3px);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

#legendPanel .legend-item.active {
  background: rgba(139, 92, 246, 0.25);
  border: 1px solid rgba(139, 92, 246, 0.5);
}

/* Visual feedback for selected categories - selected means FILTERED OUT (hidden) */
#legendPanel .legend-item.selected {
  background: rgba(239, 68, 68, 0.25) !important;
  border: 1px solid rgba(239, 68, 68, 0.6) !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3) !important;
}

#legendPanel .legend-item.selected span {
  color: #ef4444 !important;
  font-weight: 600 !important;
  text-decoration: line-through !important;
}

/* Highlighted marker styles */
.marker-highlighted {
  animation: highlight-pulse 1.5s infinite;
  transform: scale(1.3) !important;
  z-index: 3000 !important;
  box-shadow: 0 0 20px currentColor, 0 4px 12px rgba(0,0,0,0.4) !important;
}

@keyframes highlight-pulse {
  0%, 100% { 
    box-shadow: 0 0 20px currentColor, 0 4px 12px rgba(0,0,0,0.4);
  }
  50% { 
    box-shadow: 0 0 30px currentColor, 0 6px 15px rgba(0,0,0,0.5);
  }
}

/* Mobile responsiveness for legend panel */
@media (max-width: 768px) {
  #legendPanel {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(-10px);
    max-width: 90vw;
    min-width: 280px;
    padding: 1.2rem;
  }
  
  #legendPanel.show {
    transform: translate(-50%, -50%) translateY(0);
  }
}