/* ========== Map View Styles ========== */

.map-view {
  display: none;
  width: 100%;
  height: calc(100vh - 300px);
  min-height: 500px;
  position: relative;
  z-index: 1;
}

.map-view.active {
  display: block;
}

#map {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1;
}

/* View Toggle Button - Modern Pill Design */
.view-toggle-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 2px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  z-index: 10;
  color: var(--ink-700);
  font-family: 'Noto Sans Thai', sans-serif;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.view-toggle-btn:hover {
  transform: translateY(-50%) translateY(-2px);
  border-color: rgba(0,0,0,0.12);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  background: #FAFAFA;
}

.view-toggle-btn:active {
  transform: translateY(-50%) translateY(0);
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.view-toggle-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink-700);
}

.status-line {
  position: relative;
  padding-right: 140px;
}

.view-icon {
  transition: all 0.25s var(--ease);
  flex-shrink: 0;
  display: block;
  color: var(--ink-600);
}

.view-icon-map {
  display: none;
}

/* When map view is active */
body.map-view-active .view-icon-list {
  display: none;
}

body.map-view-active .view-icon-map {
  display: block;
}

body.map-view-active .view-toggle-label:first-of-type {
  display: none;
}

body.map-view-active .view-toggle-label:last-of-type {
  display: block;
}

body:not(.map-view-active) .view-toggle-label:first-of-type {
  display: block;
}

body:not(.map-view-active) .view-toggle-label:last-of-type {
  display: none;
}

body.map-view-active #resultsArea {
  display: none;
}

body.map-view-active .map-view {
  display: block;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  font-family: 'Noto Sans Thai', sans-serif;
  padding: 0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  border: 1px solid #E5E7EB;
}

.leaflet-popup-content {
  margin: 0;
  line-height: 1.5;
  width: auto !important;
  min-width: 240px;
}

.leaflet-popup-tip {
  border-top-color: #FFFFFF;
}

/* Custom Marker Styles */
.custom-marker {
  background: transparent !important;
  border: none !important;
}

.custom-marker img {
  display: block;
  border-radius: 50%;
  overflow: hidden;
  clip-path: circle(50%);
  -webkit-clip-path: circle(50%); /* Safari compatibility */
}

/* Map Popup Container */
.map-popup-container {
  padding: 16px;
}

.map-popup-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
  line-height: 1.4;
}

.map-popup-category {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 12px;
}

.map-popup-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #6B7280;
  margin-bottom: 12px;
}

.map-popup-info svg {
  flex-shrink: 0;
  color: #9CA3AF;
}

.map-popup-info span {
  line-height: 1.4;
}

.map-popup-btn {
  width: 100%;
  padding: 10px 16px;
  background: #3B82F6;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Noto Sans Thai', sans-serif;
}

.map-popup-btn:hover {
  background: #2563EB;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.map-popup-btn:active {
  transform: translateY(0);
}

.map-popup-btn svg {
  flex-shrink: 0;
}

/* Marker Clusters */
.custom-cluster {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  cursor: pointer;
}

.custom-cluster:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.cluster-pie {
  position: absolute;
  top: 0;
  left: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

/* Animation for cluster interaction */
.custom-cluster-small {
  animation: pulse-small 2s ease-in-out infinite;
}

.custom-cluster-medium {
  animation: pulse-medium 2s ease-in-out infinite;
}

.custom-cluster-large {
  animation: pulse-large 2s ease-in-out infinite;
}

@keyframes pulse-small {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.4);
  }
}

@keyframes pulse-medium {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 2px 12px rgba(251, 146, 60, 0.4);
  }
}

@keyframes pulse-large {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.4);
  }
}

.marker-cluster {
  background-clip: padding-box;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.marker-cluster:hover {
  transform: scale(1.1);
}

/* Responsive */
@media (max-width: 768px) {
  .map-view {
    height: calc(100vh - 250px);
    min-height: 400px;
  }

  #map {
    border-radius: 8px;
  }

  .view-toggle-btn {
    height: 36px;
    padding: 0 12px;
    gap: 6px;
  }

  .view-toggle-label {
    font-size: 13px;
  }

  .view-icon {
    width: 18px;
    height: 18px;
  }

  .status-line {
    padding-right: 120px;
  }
}

/* User Location Marker */
.user-location-marker {
  background: transparent !important;
  border: none !important;
}

.user-location-icon {
  position: relative;
  width: 24px;
  height: 24px;
}

.user-location-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #3B82F6;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
  z-index: 2;
}

.user-location-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  background: #3B82F6;
  border-radius: 50%;
  opacity: 0;
  animation: pulse-location 2s ease-out infinite;
}

@keyframes pulse-location {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

/* Locate button styling */
.locate-btn {
  transition: all 0.2s ease;
}

.locate-btn:hover {
  background: #F3F4F6;
  transform: scale(1.1);
}

.locate-btn:active {
  transform: scale(0.95);
}

.locate-btn svg {
  display: block;
}

/* Rotating animation for loading state */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.rotating {
  animation: rotate 1s linear infinite;
}

/* Hide Leaflet attribution */
.leaflet-control-attribution {
  display: none !important;
}

