/* Enhanced CE Delivery Map - Pin Styles */

/* Pin Icons */
.cedm-custom-icon {
  background: transparent !important;
  border: none !important;
}

.cedm-pin-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 32px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  transition: transform 0.2s ease;
  /* Fix blurry rendering on high-DPI screens */
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

.cedm-pin-icon:hover {
  transform: scale(1.1) translateZ(0);
}

.cedm-pin-icon svg {
  width: 100%;
  height: 100%;
  /* Crisp SVG rendering */
  shape-rendering: geometricPrecision;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Animated pin drop effect */
@keyframes pinDrop {
  0% {
    transform: translateY(-20px);
    opacity: 0;
  }
  60% {
    transform: translateY(3px);
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.leaflet-marker-icon {
  animation: pinDrop 0.5s ease-out;
}

/* Pin Popups */
.cedm-popup {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.cedm-pin-popup {
  padding: 10px;
}

.cedm-pin-popup h4 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 16px;
  font-weight: 600;
}

.cedm-pin-popup p {
  margin: 0 0 10px 0;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}

.cedm-pin-link {
  display: inline-block;
  color: #4A90E2;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.cedm-pin-link:hover {
  color: #357ABD;
  text-decoration: underline;
}

/* Custom Popup Styling */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.leaflet-popup-tip {
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

/* Loading and Error States */
.cedm-loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
}

.cedm-loading-content {
  text-align: center;
  color: #666;
}

.cedm-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 15px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #4A90E2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.cedm-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 8px;
}

.cedm-error-content {
  text-align: center;
  padding: 20px;
  color: #c53030;
}

.cedm-error-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
}

.cedm-error-message {
  font-size: 14px;
}

/* Enhanced Tooltips */
.cedm-tooltip {
  background: rgba(0, 0, 0, 0.85) !important;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: white !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 8px 12px;
}

.cedm-tooltip.leaflet-tooltip-top:before {
  border-top-color: rgba(0, 0, 0, 0.85);
}

.cedm-tooltip.leaflet-tooltip-bottom:before {
  border-bottom-color: rgba(0, 0, 0, 0.85);
}

.cedm-tooltip.leaflet-tooltip-left:before {
  border-left-color: rgba(0, 0, 0, 0.85);
}

.cedm-tooltip.leaflet-tooltip-right:before {
  border-right-color: rgba(0, 0, 0, 0.85);
}

.cedm-country-tooltip strong,
.cedm-region-tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.cedm-region-tooltip span {
  display: block;
  opacity: 0.9;
}

/* Legend Enhancements */
.cedm-legend {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 15px;
  margin-top: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cedm-legend h4 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.cedm-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cedm-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.cedm-legend-item:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.cedm-legend-item.active {
  background: #4A90E2;
  color: white;
  border-color: #4A90E2;
}

.cedm-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.cedm-legend-item.active .cedm-legend-color {
  border-color: rgba(255, 255, 255, 0.3);
}

/* Country Labels */
.cedm-country-label-icon {
  background: transparent !important;
  border: none !important;
  pointer-events: none;
}

.cedm-country-label {
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-shadow: 
    -1px -1px 0 rgba(255, 255, 255, 0.8),
    1px -1px 0 rgba(255, 255, 255, 0.8),
    -1px 1px 0 rgba(255, 255, 255, 0.8),
    1px 1px 0 rgba(255, 255, 255, 0.8),
    0 0 4px rgba(255, 255, 255, 0.9);
}

.cedm-country-label .mw-value {
  font-size: 14px;
  font-weight: bold;
  color: #2c3e50;
  margin-bottom: 2px;
}

.cedm-country-label .custom-value {
  font-size: 12px;
  color: #555;
  font-weight: 500;
}

/* Adjust label size based on zoom */
.leaflet-zoom-animated .cedm-country-label {
  transition: font-size 0.25s ease;
}

.leaflet-container.leaflet-zoom-anim .cedm-country-label {
  will-change: transform;
}

/* Custom Zoom Controls */
.cedm-zoom-controls {
  box-shadow: 0 1px 5px rgba(0,0,0,0.4) !important;
  border-radius: 4px !important;
  background: white !important;
  border: 2px solid rgba(0,0,0,0.2) !important;
}

.cedm-zoom-controls a {
  cursor: pointer !important;
  transition: background-color 0.2s !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  display: block !important;
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
  text-align: center !important;
  text-decoration: none !important;
  color: #333 !important;
  font-weight: bold !important;
  font-size: 22px !important;
  background: white !important;
}

.cedm-zoom-controls a:hover {
  background-color: #f4f4f4 !important;
}

.cedm-zoom-controls a:active {
  background-color: #e0e0e0 !important;
}

.cedm-zoom-in {
  border-radius: 4px 4px 0 0 !important;
  border-bottom: 1px solid #ccc !important;
}

.cedm-zoom-out {
  border-radius: 0 0 4px 4px !important;
}

/* Ensure zoom controls are always visible */
.leaflet-control-container .leaflet-top.leaflet-left {
  z-index: 1000 !important;
}

.cedm-map .leaflet-control-zoom,
.cedm-map .cedm-zoom-controls {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Map Wrapper Layout */
.cedm-map-wrapper {
  position: relative;
}

.cedm-map-container {
  position: relative;
  overflow: visible !important; /* Ensure controls are visible */
}

/* Ensure Leaflet controls are within the container */
.cedm-map-container .leaflet-control-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.cedm-map-container .leaflet-control {
  pointer-events: auto;
}

/* Custom Zoom Controls specific positioning */
.cedm-map-container .cedm-zoom-controls {
  position: absolute !important;
  top: 10px !important;
  left: 10px !important;
  z-index: 1000 !important;
  margin: 0 !important;
}

/* Ensure zoom controls are always visible and on top */
.cedm-zoom-controls {
  box-shadow: 0 1px 5px rgba(0,0,0,0.4) !important;
  border-radius: 4px !important;
  background: white !important;
  border: 2px solid rgba(0,0,0,0.2) !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Accordion Styling */
.cedm-accordion {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.cedm-accordion-header {
  flex-shrink: 0;
}

.cedm-accordion-content {
  flex: 1;
  min-height: 0;
}

/* Accordion Zoom Controls */
.cedm-accordion-zoom-controls {
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #e0e0e0;
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.cedm-accordion-zoom-controls button {
  width: 35px;
  height: 35px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
  color: #333;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
}

.cedm-accordion-zoom-controls button:hover {
  background-color: #f0f0f0;
  border-color: #999;
  transform: scale(1.05);
}

.cedm-accordion-zoom-controls button:active {
  transform: scale(0.95);
}

.cedm-zoom-display {
  font-size: 14px;
  color: #333;
  font-weight: 500;
  min-width: 40px;
  text-align: center;
  padding: 5px 10px;
  background: #f5f5f5;
  border-radius: 4px;
}

.cedm-offmap-section {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #f9fafb;
}

.cedm-offmap-title {
  font-weight: 700;
  color: #333;
  margin-bottom: 8px;
}

.cedm-offmap-category {
  margin-top: 10px;
}

.cedm-offmap-category-title {
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
  font-size: 14px;
}

.cedm-offmap-item {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.cedm-offmap-item:hover {
  background: #eef2f7;
}

.cedm-offmap-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4a90e2;
  margin-top: 6px;
  flex-shrink: 0;
}

.cedm-offmap-name {
  font-weight: 600;
  color: #222;
}

.cedm-offmap-note {
  font-size: 12px;
  color: #666;
}

/* Ensure accordion items don't overflow */
.cedm-accordion-item:last-child {
  border-bottom: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  /* Stack map and accordion vertically on mobile */
  .cedm-map-wrapper {

  }
  
  .cedm-map-container {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 400px !important;
    margin-bottom: 20px;
  }
  
  .cedm-accordion {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-height: 300px;
    margin-bottom: 20px;
  }
  
  .cedm-accordion-content {
    max-height: 250px !important;
  }
  .cedm-legend {
    padding: 12px;
  }
  
  .cedm-legend h4 {
    font-size: 14px;
    margin-bottom: 10px;
  }
  
  .cedm-legend-items {
    gap: 8px;
  }
  
  .cedm-legend-item {
    padding: 5px 10px;
    font-size: 13px;
  }
  
  .cedm-legend-color {
    width: 14px;
    height: 14px;
  }
  
  .cedm-pin-popup h4 {
    font-size: 15px;
  }
  
  .cedm-pin-popup p {
    font-size: 13px;
  }
}

/* Pin Clustering (if enabled) */
.marker-cluster {
  background-clip: padding-box;
  border-radius: 20px;
}

.marker-cluster div {
  width: 30px;
  height: 30px;
  margin-left: 5px;
  margin-top: 5px;
  text-align: center;
  border-radius: 15px;
  font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}

.marker-cluster-small {
  background-color: rgba(110, 204, 57, 0.6);
}

.marker-cluster-small div {
  background-color: rgba(110, 204, 57, 0.6);
}

.marker-cluster-medium {
  background-color: rgba(240, 194, 12, 0.6);
}

.marker-cluster-medium div {
  background-color: rgba(240, 194, 12, 0.6);
}

.marker-cluster-large {
  background-color: rgba(241, 128, 23, 0.6);
}

.marker-cluster-large div {
  background-color: rgba(241, 128, 23, 0.6);
}

/* =============================================
   Lightbox Styles
   ============================================= */
.cedm-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cedm-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.cedm-lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.cedm-lightbox-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cedm-lightbox-image {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.cedm-lightbox.active .cedm-lightbox-image {
  transform: scale(1);
}

.cedm-lightbox-close {
  position: absolute;
  top: -40px;
  right: -10px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.cedm-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.cedm-lightbox-caption {
  margin-top: 16px;
  color: white;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  max-width: 80%;
  opacity: 0.9;
}

/* Popup image clickable indicator */
.cedm-popup-image {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cedm-popup-image:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* =============================================
   High-DPI / Retina Display Fixes for Pinpoints
   ============================================= */
@media (-webkit-min-device-pixel-ratio: 1.5),
       (min-resolution: 144dpi),
       (min-resolution: 1.5dppx) {
  .cedm-pin-icon {
    /* Ensure crisp rendering on high-DPI screens */
    transform: translateZ(0);
    will-change: transform;
  }

  .cedm-pin-icon svg {
    /* Use larger SVG rendering for high-DPI */
    transform: scale(1);
    transform-origin: center center;
  }

  .leaflet-marker-icon {
    /* Prevent blurry marker icons */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
}

/* Additional fix for 2x and higher pixel ratio screens */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi),
       (min-resolution: 2dppx) {
  .cedm-pin-icon {
    /* Force GPU acceleration for sharper rendering */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-perspective: 1000;
    perspective: 1000;
  }

  .cedm-pin-icon svg {
    /* Ensure vector graphics render crisply */
    shape-rendering: geometricPrecision;
    text-rendering: geometricPrecision;
  }

  .cedm-custom-icon {
    /* Prevent subpixel rendering issues */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Large screen / desktop high-DPI specific */
@media screen and (min-width: 1200px) {
  .cedm-pin-icon {
    /* Slightly larger icons on big screens for better visibility */
    width: 28px;
    height: 37px;
  }

  .cedm-pin-icon svg {
    /* Ensure SVG scales properly */
    width: 100%;
    height: 100%;
    shape-rendering: geometricPrecision;
  }
}

/* Very large screens (4K and above) */
@media screen and (min-width: 2000px) {
  .cedm-pin-icon {
    /* Even larger icons for 4K displays */
    width: 32px;
    height: 42px;
  }
}

/* Lightbox mobile responsive */
@media (max-width: 768px) {
  .cedm-lightbox-container {
    max-width: 95vw;
    max-height: 95vh;
  }

  .cedm-lightbox-image {
    max-height: 80vh;
    border-radius: 4px;
  }

  .cedm-lightbox-close {
    top: -50px;
    right: 0;
    width: 44px;
    height: 44px;
    font-size: 32px;
  }

  .cedm-lightbox-caption {
    font-size: 14px;
    max-width: 90%;
  }
}
