/* Middle-earth Map Component Styles */
@import 'leaflet/dist/leaflet.css';
/* Import markercluster CSS from package (no tilde for CRA) */
@import 'leaflet.markercluster/dist/MarkerCluster.css';

.middle-earth-map-container {
  width: 100%;
  height: 100%;
  min-height: 500px;
  background-color: var(--color-parchment-dark, #E8D5B7);
  border: 2px solid var(--color-earth-brown-medium, #A0522D);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

/* Override Leaflet default styles with LOTR theme */
.middle-earth-map-container .leaflet-container {
  background-color: var(--color-parchment-light, #F4E4BC);
  font-family: 'Lora', serif;
}

.middle-earth-map-container .leaflet-popup-content-wrapper {
  background: var(--color-parchment-light, #F4E4BC);
  border: 2px solid var(--color-earth-brown-medium, #A0522D);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: var(--color-deep-blue-dark, #1A1F2E);
}

.middle-earth-map-container .leaflet-popup-content {
  margin: 12px;
  font-family: 'Lora', serif;
}

.middle-earth-map-container .leaflet-popup-tip {
  background: var(--color-parchment-light, #F4E4BC);
  border: 1px solid var(--color-earth-brown-medium, #A0522D);
}

.middle-earth-map-container .leaflet-control-zoom {
  border: 2px solid var(--color-earth-brown-medium, #A0522D);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.middle-earth-map-container .leaflet-control-zoom a {
  background-color: var(--color-parchment-light, #F4E4BC);
  color: var(--color-earth-brown-dark, #8B4513);
  border-bottom: 1px solid var(--color-earth-brown-medium, #A0522D);
}

.middle-earth-map-container .leaflet-control-zoom a:hover {
  background-color: var(--color-parchment-dark, #E8D5B7);
  color: var(--color-gold-dark, #FFD700);
}

/* Custom marker styling */
.custom-marker-icon {
  background: transparent;
  border: none;
}

/* Location marker with quest count */
.location-marker-icon {
  background: transparent;
  border: none;
}

.location-marker {
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 3px solid var(--color-parchment-light, #F4E4BC);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.location-marker:hover {
  transform: rotate(-45deg) scale(1.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  z-index: 1000;
}

.marker-pin-inner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--color-parchment-light, #F4E4BC);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.8);
}

/* Quest count badge on marker */
.quest-count-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background-color: var(--color-gold-dark, #FFD700);
  color: var(--color-earth-brown-dark, #8B4513);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  border: 2px solid var(--color-parchment-light, #F4E4BC);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
  transform: rotate(45deg); /* Rotate with the marker pin */
  line-height: 1;
}

/* Counter-rotate the text inside the badge to keep it upright */
.quest-count-badge span {
  transform: rotate(-45deg);
  display: inline-block;
}

/* Marker cluster styling */
.marker-cluster-icon {
  background: transparent !important;
  border: none !important;
}

.marker-cluster {
  background-color: var(--color-forest-green-medium, #3D6B1F);
  border: 3px solid var(--color-parchment-light, #F4E4BC);
  border-radius: 50%;
  color: white;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  width: 40px;
  height: 40px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Override default marker cluster styles */
.middle-earth-map-container .marker-cluster-small {
  background-color: var(--color-forest-green-medium, #3D6B1F) !important;
  border: 3px solid var(--color-parchment-light, #F4E4BC) !important;
}

.middle-earth-map-container .marker-cluster-medium {
  background-color: var(--color-forest-green-dark, #2D5016) !important;
  border: 3px solid var(--color-parchment-light, #F4E4BC) !important;
}

.middle-earth-map-container .marker-cluster-large {
  background-color: var(--color-earth-brown-dark, #8B4513) !important;
  border: 3px solid var(--color-parchment-light, #F4E4BC) !important;
}

/* Quest marker cluster styling - aggregates quest markers on zoom out */
.quest-marker-cluster-icon {
  background: transparent !important;
  border: none !important;
}

.quest-marker-cluster {
  background: linear-gradient(135deg, #CD853F, #8B4513);
  border: 2px solid #DAA520;
  border-radius: 50%;
  color: #F4E4BC;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.quest-marker-cluster-small {
  width: 35px;
  height: 35px;
}

.quest-marker-cluster-medium {
  width: 45px;
  height: 45px;
  font-size: 15px;
}

.quest-marker-cluster-large {
  width: 55px;
  height: 55px;
  font-size: 17px;
}

.quest-marker-cluster:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Ensure quest markers are always on top and clickable */
.middle-earth-map-container .leaflet-marker-pane .quest-marker-icon {
  z-index: 2000 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

.middle-earth-map-container .leaflet-marker-pane .quest-marker-icon * {
  pointer-events: auto !important;
  cursor: pointer !important;
}

.middle-earth-map-container .leaflet-interactive {
  pointer-events: auto !important;
}

/* Override Leaflet's default pointer-events for quest markers */
.middle-earth-map-container .leaflet-container .quest-marker-icon,
.middle-earth-map-container .leaflet-container .quest-marker-icon * {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Ensure quest markers are not blocked by other layers */
.middle-earth-map-container .leaflet-marker-pane {
  z-index: 600 !important;
}

.middle-earth-map-container .leaflet-marker-pane .quest-marker-icon {
  z-index: 2600 !important;
}

/* Location popup styling */
.location-popup {
  min-width: 200px;
}

.location-popup h3 {
  font-family: 'Cinzel', serif;
  color: var(--color-earth-brown-dark, #8B4513);
  margin: 0 0 8px 0;
  font-size: 1.2rem;
}

.location-popup .location-region {
  font-size: 0.9rem;
  color: var(--color-earth-brown-medium, #A0522D);
  font-style: italic;
  margin: 0 0 8px 0;
}

.location-popup .location-description {
  font-size: 0.85rem;
  color: var(--color-deep-blue-dark, #1A1F2E);
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.location-popup .quest-count-info {
  font-size: 0.9rem;
  color: var(--color-forest-green-dark, #2D5016);
  margin: 0 0 12px 0;
  font-weight: 500;
}

.location-popup .quest-count-info strong {
  color: var(--color-gold-dark, #FFD700);
  font-size: 1.1rem;
}

.location-popup .btn-view-quests {
  background-color: var(--color-forest-green-medium, #3D6B1F);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Lora', serif;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
  width: 100%;
}

.location-popup .btn-view-quests:hover {
  background-color: var(--color-forest-green-dark, #2D5016);
}


.character-marker-icon {
  background: transparent !important;
  border: none !important;
  z-index: 5000 !important;
}

.character-marker {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, #ffe7a3, #d4a939);
  border: 2px solid #8b4513;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.2s ease;
  z-index: 5001 !important;
  position: relative;
}

.character-marker:hover {
  transform: scale(1.12);
}

.character-popup {
  min-width: 200px;
}

.character-popup h4 {
  margin: 0 0 6px 0;
  color: var(--color-earth-brown-dark, #8B4513);
}

.character-popup p {
  margin: 0 0 10px 0;
  font-size: 0.9rem;
}

.character-popup .btn-bargain-character {
  width: 100%;
  border: none;
  border-radius: 4px;
  padding: 8px 10px;
  background-color: var(--color-forest-green-medium, #3D6B1F);
  color: #fff;
  cursor: pointer;
}

.character-popup .btn-bargain-character:hover {
  background-color: var(--color-forest-green-dark, #2D5016);
}

/* Quest marker styling */
.quest-marker-icon {
  background: transparent !important;
  border: none !important;
  pointer-events: auto !important; /* Ensure markers are clickable */
}

.leaflet-marker-icon.quest-marker-icon {
  pointer-events: auto !important;
  cursor: pointer !important;
}

.quest-marker {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: 2px solid var(--color-parchment-light, #F4E4BC);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 4px rgba(218, 165, 32, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer !important;
  pointer-events: auto !important; /* Critical: make markers clickable */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  z-index: 2000; /* Higher z-index than location markers */
  user-select: none; /* Prevent text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.quest-marker:hover {
  transform: scale(1.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), 0 0 8px rgba(218, 165, 32, 0.5);
  z-index: 3000; /* Even higher on hover */
  cursor: pointer !important;
}

.quest-marker:active {
  transform: scale(1.2);
}

.quest-marker-selected {
  border: 3px solid var(--color-gold-dark, #FFD700);
  box-shadow: 0 0 15px rgba(218, 165, 32, 0.8), 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 2500; /* Higher than normal quest markers */
}

.quest-marker-inner {
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Quest popup styling */
.quest-popup-wrapper .leaflet-popup-content-wrapper {
  max-width: 350px;
}

.quest-popup {
  min-width: 250px;
  max-width: 350px;
}

.quest-popup h4 {
  font-family: 'Cinzel', serif;
  color: var(--color-earth-brown-dark, #8B4513);
  margin: 0 0 10px 0;
  font-size: 1.2rem;
  line-height: 1.3;
}

.quest-popup-type {
  font-size: 0.9rem;
  color: var(--color-gold-dark, #FFD700);
  margin: 0 0 8px 0;
  font-weight: 600;
  font-family: 'Cinzel', serif;
}

.quest-popup-status {
  font-size: 0.85rem;
  color: var(--color-forest-green-dark, #2D5016);
  margin: 0 0 10px 0;
  font-weight: 500;
  padding: 4px 8px;
  background-color: rgba(45, 80, 22, 0.1);
  border-radius: 4px;
  display: inline-block;
}

.quest-popup-description {
  font-size: 0.9rem;
  color: var(--color-deep-blue-dark, #1A1F2E);
  margin: 0 0 12px 0;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}

.quest-popup-location {
  font-size: 0.85rem;
  color: var(--color-earth-brown-medium, #A0522D);
  margin: 0 0 8px 0;
  font-style: italic;
}

.quest-popup-assignee {
  font-size: 0.85rem;
  color: var(--color-deep-blue-dark, #1A1F2E);
  margin: 0 0 12px 0;
}

.quest-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.btn-view-quest,
.btn-complete-quest {
  background-color: var(--color-forest-green-medium, #3D6B1F);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Lora', serif;
  font-size: 0.9rem;
  transition: background-color 0.2s ease, transform 0.1s ease;
  width: 100%;
  font-weight: 500;
}

.btn-view-quest:hover,
.btn-complete-quest:hover {
  background-color: var(--color-forest-green-dark, #2D5016);
  transform: translateY(-1px);
}

.btn-complete-quest {
  background-color: var(--color-gold-dark, #FFD700);
  color: var(--color-earth-brown-dark, #8B4513);
}

.btn-complete-quest:hover {
  background-color: var(--color-gold-light, #DAA520);
  color: var(--color-earth-brown-dark, #8B4513);
}

/* Responsive design */
@media (max-width: 768px) {
  .middle-earth-map-container {
    min-height: 400px;
  }
  
  .location-popup {
    min-width: 150px;
  }
}
