/* map-interactive.css */

/* Default Map Paths (World Map) */
#ams-map-svg {
  width: 100% !important;
  height: auto !important;
  display: block;
  max-width: none !important;
  margin: 0;
}

#ams-interactive-map-wrapper {
  position: relative;
  z-index: 1; /* Creates styling context so markers don't overlap sticky header */
}

#ams-map-svg path {
  fill: #eaeaea;
  cursor: pointer;

  stroke: #d1d1d1;
  stroke-width: 0.5px;
  transition: fill 0.3s ease;
}

/* Specific country hovered highlight (Optimized) */
/* svg path:hover {
    fill: #FFD700 !important;
    stroke: none !important;
} */

/* Bangladesh Flag Style - Permanently Visible */
.bangladesh-map {
  fill: url(#bdFlagGradient) !important;
  stroke: #004d38 !important;
  stroke-width: 0.5px !important;
  transform: scale(2.5);
  transform-origin: center;
  transform-box: fill-box;
  filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
}


.bangladesh-map:hover {
  fill: url(#bdFlagGradient) !important;
  stroke: #004d38 !important;
}

.bangladesh-map.active-country {
  fill: url(#bdFlagGradient) !important;
  stroke: #004d38 !important;
}

/* Canada Custom Style */
.canada-map:hover {
  fill: #e50304 !important;
  stroke: none !important;
}

.canada-map.active-country {
  fill: #e50304 !important;
  stroke: none !important;
}

/* USA Custom Style */
.usa-map:hover {
  fill: #123766 !important;
  stroke: none !important;
}

.usa-map.active-country {
  fill: #123766 !important;
  stroke: none !important;
}

/* Colombia Custom Style */
.colombia-map:hover {
  fill: #08368b !important;
  stroke: none !important;
}

.colombia-map.active-country {
  fill: #08368b !important;
  stroke: none !important;
}

/* South Korea Custom Style */
.south-korea-map:hover {
  fill: #084da3 !important;
  stroke: none !important;
}

.south-korea-map.active-country {
  fill: #084da3 !important;
  stroke: none !important;
}

/* China Custom Style */
.china-map:hover {
  fill: #df3017 !important;
  stroke: none !important;
}

.china-map.active-country {
  fill: #df3017 !important;
  stroke: none !important;
}

/* Japan Custom Style */
.japan-map:hover {
  fill: #d7d7d7 !important;
  stroke: none !important;
}

.japan-map.active-country {
  fill: #d7d7d7 !important;
  stroke: none !important;
}

/* Australia Custom Style */
.australia-map:hover {
  fill: #09286e !important;
  stroke: none !important;
}

.australia-map.active-country {
  fill: #09286e !important;
  stroke: none !important;
}

/* Italy Custom Style */
.italy-map:hover {
  fill: #089645 !important;
  stroke: none !important;
}

.italy-map.active-country {
  fill: #089645 !important;
  stroke: none !important;
}

/* UK Custom Style */
.uk-map:hover {
  fill: #d22a34 !important;
  stroke: none !important;
}

.uk-map.active-country {
  fill: #d22a34 !important;
  stroke: none !important;
}

/* Germany Custom Style */
.germany-map:hover {
  fill: #d59d0a !important;
  stroke: none !important;
}

.germany-map.active-country {
  fill: #d59d0a !important;
  stroke: none !important;
}

/* Malaysia Custom Style */
.malaysia-map:hover {
  fill: #08086b !important;
  stroke: none !important;
}

.malaysia-map.active-country {
  fill: #08086b !important;
  stroke: none !important;
}

/* Thailand Custom Style */
.thailand-map:hover {
  fill: #343150 !important;
  stroke: none !important;
}

.thailand-map.active-country {
  fill: #343150 !important;
  stroke: none !important;
}

/* Denmark Custom Style */
.denmark-map:hover {
  fill: #f63f2e !important;
  stroke: none !important;
}

.denmark-map.active-country {
  fill: #f63f2e !important;
  stroke: none !important;
}

/* Albania Custom Style */
.albania-map:hover {
  fill: #e4272d !important;
  stroke: none !important;
}

.albania-map.active-country {
  fill: #e4272d !important;
  stroke: none !important;
}

/* Cambodia Custom Style */
.cambodia-map:hover {
  fill: #090f70 !important;
  stroke: none !important;
}

.cambodia-map.active-country {
  fill: #090f70 !important;
  stroke: none !important;
}

/* Saudi Arabia Custom Style */
.saudi-arabia-map:hover {
  fill: #085936 !important;
  stroke: none !important;
}

.saudi-arabia-map.active-country {
  fill: #085936 !important;
  stroke: none !important;
}

/* Oman Custom Style */
.oman-map:hover {
  fill: #0a840a !important;
  stroke: none !important;
}

.oman-map.active-country {
  fill: #0a840a !important;
  stroke: none !important;
}

/* Dubai Custom Style */
.dubai-map:hover {
  fill: #ca1735 !important;
  stroke: none !important;
}

.dubai-map.active-country {
  fill: #ca1735 !important;
  stroke: none !important;
}

/* Singapore Custom Style */
.singapore-map:hover {
  fill: #fe2a3d !important;
  stroke: none !important;
}

.singapore-map.active-country {
  fill: #fe2a3d !important;
  stroke: none !important;
}

/* Quwait Custom Style */
.quwait-map:hover {
  fill: #087e43 !important;
  stroke: none !important;
}

.quwait-map.active-country {
  fill: #087e43 !important;
  stroke: none !important;
}

/* Portugal Custom Style */
.portugal-map:hover {
  fill: #086b08 !important;
  stroke: none !important;
}

.portugal-map.active-country {
  fill: #086b08 !important;
  stroke: none !important;
}

/* Cyprus Custom Style */
.cyprus-map:hover {
  fill: #e9a324 !important;
  stroke: none !important;
}

.cyprus-map.active-country {
  fill: #e9a324 !important;
  stroke: none !important;
}

/* Lebanon Custom Style */
.lebanon-map:hover {
  fill: #d41d2b !important;
  stroke: none !important;
}

.lebanon-map.active-country {
  fill: #d41d2b !important;
  stroke: none !important;
}

/* Default Active Style for other countries */
.active-country:not(.bangladesh-map):not(.canada-map):not(.usa-map):not(
    .colombia-map
  ):not(.south-korea-map):not(.china-map):not(.japan-map):not(
    .australia-map
  ):not(.italy-map):not(.uk-map):not(.germany-map):not(.malaysia-map):not(
    .thailand-map
  ):not(.denmark-map):not(.albania-map):not(.cambodia-map):not(
    .saudi-arabia-map
  ):not(.oman-map):not(.dubai-map):not(.singapore-map):not(.quwait-map):not(
    .portugal-map
  ):not(.cyprus-map):not(.lebanon-map) {
  fill: #3b82f6 !important;
  stroke: none !important;
}

/* Location Marker Pin Style (Inside map-interactive.css) */
.location-marker {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  z-index: 9999;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  transform: translate(-50%, -100%);
  animation: markerPop 0.3s cubic-bezier(0.2, 1, 0.3, 1);
  z-index: 10 !important;
}

/* Explicitly style the location marker elements to prevent overrides */
.location-marker path {
  fill: #ff3131 !important;
  stroke: white !important;
  stroke-width: 1.5px !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.location-marker circle {
  fill: white !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Exclude background utility groups from interaction */
#ams-map-background,
#ams-map-shadow {
  pointer-events: none !important;
}

/* Redesigned Popup Style */
.ams-map-popup {
  position: absolute;
  background: rgba(15, 15, 20, 0.541);
  /* backdrop-filter: blur(12px); Removed for performance */
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 20px;
  border-radius: 8px;
  font-family: "Inter", sans-serif;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  z-index: 20;
  pointer-events: auto;
  transform: translate(-50%, -110%);
  will-change: opacity, transform;
  animation: amsPopupFade 0.3s cubic-bezier(0.2, 1, 0.3, 1);
  min-width: 120px;
  max-width: 220px;
}

@keyframes amsPopupFade {
  from {
    opacity: 0;
    transform: scale(0.9) translate(-50%, -120%);
  }
  to {
    opacity: 1;
    transform: scale(1) translate(-50%, -110%);
  }
}

.popup-header {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.popup-body {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

/* Location Marker Pin Style */
.marker-container,
.marker-container * {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Ensure the pin tip is the anchor point */
.location-marker {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  z-index: 9999;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  transform: translate(
    -50%,
    -92%
  ); /* 92% matches the tip of the pin in the 24x24 viewbox */
  will-change: transform;
}

/* .marker-container svg filter removed for performance */

@keyframes markerPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -120%) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1);
  }
}

.marker-container {
  position: relative;
  width: 60px; /* Reduced default size */
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: flex-end; /* Align tip to the bottom */
}

/* Specific scale for temporary marker */
.location-marker .marker-container {
  transform-origin: bottom center;
}

/* Permanent markers fade in sequentially */
.location-marker.permanent {
  opacity: 0;
  animation: markerFadeIn 0.5s cubic-bezier(0.2, 1, 0.3, 1) forwards;
  z-index: 16 !important; /* Above connection lines */
  position: absolute;
}

@keyframes markerFadeIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -100%) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -92%) scale(1);
  }
}

.pulse-ring {
  position: absolute;
  width: 20px;
  height: 20px;
  background: rgba(255, 49, 49, 0.6);
  border-radius: 50%;
  bottom: 5px; /* Position at the tip */
  left: 50%;
  transform: translateX(-50%);
  z-index: -1;
  pointer-events: none;
}

.ring-1 {
  animation: markerRipple 2s infinite ease-out !important;
}
.ring-2 {
  animation: markerRipple 2s infinite ease-out 0.6s !important;
}
.ring-3 {
  animation: markerRipple 2s infinite ease-out 1.2s !important;
}

@keyframes markerRipple {
  0% {
    transform: translateX(-50%) scale(0.5);
    opacity: 0.8;
  }
  100% {
    transform: translateX(-50%) scale(4);
    opacity: 0;
  }
}

/* New continuous bounce animation for the pin */
.marker-container svg {
  animation: bounceContinuous 2s infinite ease-in-out !important;
}

@keyframes bounceContinuous {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Connection Line Styles */
.connection-line-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  background: transparent !important;
  /* Reveal effect from Bangladesh - will be re-triggered on scroll */
  clip-path: circle(0% at 74% 48%);
  animation: expandMap 5s cubic-bezier(0.2, 1, 0.3, 1) forwards 0.5s;
}

.ams-markers-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15 !important; /* Above connection lines */
  background: transparent !important;
  /* Reveal effect from Bangladesh - will be re-triggered on scroll */
  clip-path: circle(0% at 74% 48%);
  animation: expandMap 5s cubic-bezier(0.2, 1, 0.3, 1) forwards 0.5s;
}

@keyframes expandMap {
  from {
    clip-path: circle(0% at 74% 48%);
  }
  to {
    clip-path: circle(150% at 74% 48%);
  }
}

.connection-line {
  fill: none !important;
  stroke: #eb202a !important;
  stroke-width: 2.5 !important;
  stroke-linecap: round;
  /* First draw the line solid, then switch to dashed and animate */
  animation: lineDraw 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards,
    switchToDashed 0.01s linear forwards 1.5s,
    dashMove 35s linear infinite 1.51s;
  animation-delay: inherit; /* Will be set via JS */
}

@keyframes lineDraw {
  from {
    stroke-dashoffset: var(--line-length, 500);
  }
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes switchToDashed {
  to {
    stroke-dasharray: 8, 5;
    stroke-dashoffset: 0;
  }
}

@keyframes dashMove {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -500;
  }
}

.connection-endpoint {
  fill: #eb202a;
  stroke: white;
  stroke-width: 1;
}

/* Redesigned Premium Tooltip */
.ams-map-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.95) !important;
  color: #f8fafc !important;
  padding: 8px 16px !important;
  border-radius: 8px !important;
  font-family: "Inter", sans-serif !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  pointer-events: none;
  z-index: 20 !important;
  will-change: transform;
}

/* Marker Hover Effect - Scale Up */
.marker-hover-effect .marker-container,
.location-marker:hover .marker-container {
  transform: scale(1.1) !important; /* Scale up slightly less */
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 15; /* Bring to front of other markers but below header */
}

.marker-hover-effect .marker-container svg {
  animation: none !important; /* Pause bounce on hover for clarity */
}

/* Country Name Labels (Light rectangular style) */
.marker-label {
  position: absolute;
  top: -15px; /* Relative to the marker container tip */
  left: 50%;
  transform: translate(-50%, -100%);
  background: #ffffff;
  color: #000000;
  padding: 4px 12px;
  border-radius: 4px;
  font-weight: 900;
  font-size: 11px;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 20;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: "Inter", sans-serif;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Ensure the label shows up above the pin even when scaled */
.marker-container {
  overflow: visible !important;
}

/* Special adjustment for Bangladesh label */
.location-marker[data-marker-index="23"] .marker-label {
  top: 0;
  transform: translate(-50%, -50%); /* Centered on Bangladesh map */
  background: #ffffff;
  color: #000000;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 4px;
  border: 2px solid #006a4e; /* Bangladesh Green border for focus */
}

/* --- Country List Box Section Styles --- */
.ams-main-map-layout {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  margin-top: 40px;
  width: 100%;
}

.ams-country-list-box.left-sidebar {
  width: fit-content;
  min-width: 170px;
  flex-shrink: 0;
  max-height: 500px;
  overflow-y: auto;
  padding: 15px 5px; /* Reduced two sides padding */
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  color: #333;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 65, 108, 0.3) transparent;
}

.ams-country-list-box.left-sidebar::-webkit-scrollbar {
  width: 4px;
}

.ams-country-list-box.left-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 65, 108, 0.3);
  border-radius: 10px;
}

.ams-list-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #ff416c;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.ams-list-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 5px;
}

.ams-list-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 12px;
  background: #f8f9fa;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  transition: all 0.3s ease;
  cursor: pointer;
  width: auto; /* Fits container width in column mode */
}

.ams-list-item:hover, .ams-list-item.active {
  background: linear-gradient(90deg, rgba(255, 65, 108, 0.05), transparent);
  border-color: #ff416c;
  transform: translateX(5px);
  color: #ff416c;
}

.ams-list-country-icon {
  margin-right: 8px;
  color: #ff416c;
  display: flex;
  align-items: center;
}

.ams-list-country-icon svg {
  width: 14px;
  height: 14px;
}

.ams-list-country-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: inherit;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsiveness */
@media (max-width: 1024px) {
  .ams-main-map-layout {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }
  
  .ams-country-list-box.left-sidebar {
    width: 100%;
    max-width: 100%; 
    max-height: 400px;
    order: 2;
    padding: 15px 5px;
  }

  .ams-list-grid {
    display: grid; /* Use grid for mobile */
    grid-template-columns: repeat(2, 1fr); /* 2 columns on phone/mobile */
    gap: 5px;
  }
  
  .ams-list-item {
    width: 100%;
    justify-content: flex-start;
  }
}


@media (max-width: 768px) {
  .ams-country-list-box.left-sidebar {
    padding: 15px 5px;
  }
  
  .ams-list-item {
    padding: 6px 10px;
  }
  
  .ams-list-country-name {
    font-size: 0.75rem;
  }
}
