/**
 * Map Styles
 */

.map-container {
  position: relative;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.map-controls {
  padding: 1rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.map-mode-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-btn i {
  font-size: 0.875rem;
}

.mode-btn:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mode-btn.active {
  background: var(--color-primary, #4CAF50);
  color: white;
  border-color: var(--color-primary, #4CAF50);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.map-filters {
  margin-bottom: 1rem;
}

.map-filter-toggle__hint a {
  color: var(--color-primary, #4CAF50);
  font-weight: 600;
}

.map-interests-warning {
  display: block;
  margin-top: 0.35rem;
  color: #b45309;
}

.map-filter-toggle {
  margin: 1rem 0;
  padding: 0.75rem;
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.map-filter-toggle label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.map-filter-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.map-filter-toggle p {
  font-size: 0.75rem;
  color: var(--color-text-secondary, #666);
  margin: 0.5rem 0 0 0;
  padding-left: 2rem;
}

.map-filters label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.map-filters input[type="range"] {
  flex: 1;
  max-width: 200px;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.checkbox-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.checkbox-filter:hover {
  background: #f3f4f6;
}

.checkbox-filter input[type="checkbox"] {
  margin: 0;
}

.map-search {
  display: flex;
  gap: 0.5rem;
}

.map-search input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.875rem;
}

.map-search button {
  padding: 0.75rem 1.5rem;
  background: var(--color-primary, #10b981);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.map-search button:hover {
  background: var(--color-primary-dark, #059669);
}

.community-map {
  width: 100%;
  height: 600px;
  min-height: 400px;
}

/* Popup Styles */
.popup-card {
  min-width: 200px;
  padding: 1rem;
}

.popup-card img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.5rem;
}

.popup-card h4 {
  margin: 0.5rem 0;
  font-size: 1rem;
}

.popup-card p {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary, #666);
}

.rating {
  color: #f59e0b;
  font-size: 0.875rem;
  margin: 0.5rem 0;
}

.distance {
  font-size: 0.75rem;
  color: var(--color-text-secondary, #666);
}

.place-type {
  text-transform: capitalize;
  color: var(--color-primary, #10b981);
  font-weight: 500;
}

.members {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #666);
}

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

.leaflet-popup-content {
  margin: 0;
}

/* Marker Clusters */
.marker-cluster-small {
  background-color: rgba(16, 185, 129, 0.6);
}

.marker-cluster-medium {
  background-color: rgba(16, 185, 129, 0.7);
}

.marker-cluster-large {
  background-color: rgba(16, 185, 129, 0.8);
}

.marker-cluster div {
  background-color: var(--color-primary, #10b981);
  color: white;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  .community-map {
    height: 400px;
  }

  .map-controls {
    padding: 0.75rem;
  }

  .map-mode-toggle {
    flex-wrap: wrap;
  }

  .category-filters {
    flex-direction: column;
  }
}

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

.marker-icon {
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  border: 3px solid white;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transform: rotate(-45deg);
  transition: all 0.2s ease;
  cursor: pointer;
}

.marker-icon:hover {
  transform: rotate(-45deg) scale(1.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Rotate emoji back to normal */
.marker-icon::before {
  content: attr(data-icon);
  transform: rotate(45deg);
  display: block;
}

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

.user-location-pulse {
  width: 20px;
  height: 20px;
  background: #2196F3;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 0 0 rgba(33, 150, 243, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(33, 150, 243, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
  }
}

/* Custom Popup Styles */
.custom-popup .leaflet-popup-content-wrapper {
  border-top: 3px solid var(--color-primary, #4CAF50);
  padding: 0;
}

.custom-popup .popup-card {
  padding: 1rem;
}

.custom-popup .popup-card h4 {
  margin: 0 0 0.5rem 0;
  color: var(--color-text-primary, #1a1a1a);
  font-size: 1.1rem;
}

.custom-popup .popup-card .place-type {
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary, #4CAF50);
  margin-bottom: 0.5rem;
}

.custom-popup .popup-card p {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

.custom-popup .popup-card .distance {
  color: #666;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* Loading State */
.community-map.loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.community-map.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid var(--color-primary, #4CAF50);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 1000;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Center on Me Button */
.center-on-me-btn {
  position: absolute;
  bottom: 2rem;
  right: 1rem;
  z-index: 1000;
  background: white;
  border: 2px solid #ccc;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.center-on-me-btn:hover {
  background: var(--color-primary, #4CAF50);
  color: white;
  border-color: var(--color-primary, #4CAF50);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Marker Cluster Custom Colors */
.marker-cluster-small {
  background-color: rgba(76, 175, 80, 0.5);
}

.marker-cluster-small div {
  background-color: rgba(76, 175, 80, 0.8);
}

.marker-cluster-medium {
  background-color: rgba(129, 199, 132, 0.5);
}

.marker-cluster-medium div {
  background-color: rgba(129, 199, 132, 0.8);
}

.marker-cluster-large {
  background-color: rgba(102, 187, 106, 0.5);
}

.marker-cluster-large div {
  background-color: rgba(102, 187, 106, 0.8);
}

/* Map results panel (below map) */
.map-results-panel {
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.map-results-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.map-results-panel__scope {
  font-size: 0.75rem;
  font-weight: 600;
  color: #166534;
  background: #ecfdf3;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
}

.map-results-list {
  max-height: 360px;
  overflow-y: auto;
}

.map-results-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: #9ca3af;
}

.map-results-empty i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
  display: block;
}

.map-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.map-result-item:hover,
.map-result-item:focus-visible {
  background: #f9fafb;
  outline: none;
}

.map-result-item__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.map-result-item__body {
  flex: 1;
  min-width: 0;
}

.map-result-item__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.map-result-item__title {
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-result-item__badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.map-result-item__meta {
  font-size: 0.8rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.map-result-item__meta span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-result-item__chevron {
  color: #9ca3af;
  flex-shrink: 0;
}

.map-result-item--group .map-result-group__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: #166534;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.map-result-group__members {
  display: none;
  padding: 0 1rem 0.75rem 4.5rem;
  background: #fafafa;
  border-bottom: 1px solid #f3f4f6;
}

.map-result-group__members.is-open {
  display: block;
}

.map-result-group__member {
  padding: 0.35rem 0;
  font-size: 0.82rem;
  color: #374151;
  cursor: pointer;
}

.map-result-group__member:hover {
  color: #166534;
}

.map-category-section {
  margin-top: 0.75rem;
}

.map-category-section__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0.4rem;
}

.map-category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.map-category-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.map-category-chip:hover {
  border-color: var(--color-primary, #4CAF50);
}

.map-category-chip.is-active {
  background: var(--color-primary, #4CAF50);
  border-color: var(--color-primary, #4CAF50);
  color: #fff;
}

.map-category-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.map-category-section__link {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--color-primary, #4CAF50);
  font-weight: 600;
  text-decoration: none;
}

.map-category-section__link:hover {
  text-decoration: underline;
}

.marker-icon--with-count {
  position: relative;
}

.marker-icon__count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  transform: rotate(45deg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.marker-person {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #166534;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.marker-person__avatar,
.popup-card__avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.marker-person__avatar,
.marker-person .map-avatar-fallback {
  width: 38px;
  height: 38px;
}

.marker-person__label {
  position: absolute;
  left: 50%;
  top: 46px;
  transform: translateX(-50%);
  max-width: 120px;
  background: rgba(17, 24, 39, 0.86);
  color: #fff;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.marker-person:hover .marker-person__label {
  opacity: 1;
}

.map-result-item__avatar-link {
  display: block;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  line-height: 0;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.map-result-item__avatar-link:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 12px rgba(22, 101, 52, 0.25);
}

.map-result-item__avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 2px solid #e5e7eb;
  background: #166534;
}

.map-result-item__location {
  color: #166534;
  font-weight: 600;
}

.map-result-item__settings-link,
.map-result-group__member-link {
  color: var(--color-primary, #4CAF50);
  font-weight: 600;
  text-decoration: none;
}

.map-result-item__settings-link:hover,
.map-result-group__member-link:hover {
  text-decoration: underline;
}

.map-result-group__member-location {
  color: #64748b;
  font-weight: 500;
}

.marker-person,
.marker-person__avatar,
.map-popup-avatar-link {
  cursor: pointer;
}

.map-popup-avatar-link {
  display: inline-block;
  line-height: 0;
}

.map-popup-location {
  color: #166534;
  font-weight: 600;
}

.map-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.map-result-item--unavailable {
  background: #f8fafc;
  cursor: default;
}

.map-result-item--unavailable .map-result-item__title,
.map-result-item--unavailable .map-result-item__meta {
  color: #64748b;
}

.popup-card__avatar {
  width: 58px;
  height: 58px;
  border: 2px solid #e5e7eb;
  margin: 0 0 0.55rem;
}

.map-popup-link {
  display: inline-flex;
  align-items: center;
  color: #166534;
  font-weight: 700;
  text-decoration: none;
}

.map-popup-link:hover {
  text-decoration: underline;
}
