/* === Reset & Base Styles === */
html, body {
  margin: 0;
  height: 100%;
  background: #000;
}

/* === Map Container === */
#map {
  width: 100%;
  height: 100%;
  position: relative;
}

/* === Dev Tools Panel === */
.dev-tools-panel {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
  padding: 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dev-tools-button {
  padding: 10px 15px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: background 0.3s ease;
}

.dev-tools-button:hover {
  background: #45a049;
}

.dev-tools-button:active {
  background: #3d8b40;
}

/* === Popup Styles === */
.leaflet-popup-content {
  margin: 0;
}

/* Container utama Leaflet popup */
.leaflet-popup {
  box-shadow: none;
}

/* Hilangkan background putih default Leaflet */
.leaflet-popup-content-wrapper {
  background: linear-gradient(135deg, rgba(139, 90, 43, 0.95) 0%, rgba(101, 67, 33, 0.98) 100%);
  border-radius: 12px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(218, 165, 32, 0.3),
    inset 0 1px 0 rgba(255, 215, 0, 0.2);
  padding: 0;
  border: 2px solid rgba(218, 165, 32, 0.8);
  animation: popupGlow 2s ease-in-out infinite alternate;
}

@keyframes popupGlow {
  0% {
    box-shadow: 
      0 8px 32px rgba(0, 0, 0, 0.4),
      0 0 20px rgba(218, 165, 32, 0.3),
      inset 0 1px 0 rgba(255, 215, 0, 0.2);
  }
  100% {
    box-shadow: 
      0 8px 32px rgba(0, 0, 0, 0.4),
      0 0 30px rgba(218, 165, 32, 0.5),
      inset 0 1px 0 rgba(255, 215, 0, 0.3);
  }
}

/* Popup tip (arrow) */
.leaflet-popup-tip {
  background: rgba(101, 67, 33, 0.98);
  border-top: 2px solid rgba(218, 165, 32, 0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* === Konten marker popup === */
.marker-popup {
  position: relative; /* 🔥 PENTING - untuk absolute positioning button */
  min-width: 280px;
  max-width: 350px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, rgba(139, 90, 43, 0.95) 0%, rgba(101, 67, 33, 0.98) 50%, rgba(139, 90, 43, 0.95) 100%);
  color: #f5f5f5;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
}

/* === Edit Description Icon (pojok kanan atas) === */
.marker-popup-edit-desc-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.3), rgba(184, 134, 11, 0.3));
  border: 1px solid rgba(218, 165, 32, 0.8);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.marker-popup-edit-desc-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(1.2);
}

.marker-popup-edit-desc-icon:hover {
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.5), rgba(184, 134, 11, 0.5));
  box-shadow: 0 0 15px rgba(218, 165, 32, 0.7);
  transform: scale(1.1) rotate(15deg);
  border-color: #FFD700;
}

/* Header dengan judul */
.marker-popup-header {
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  padding-right: 50px; /* Beri ruang untuk button edit description */
  border-bottom: 2px solid rgba(218, 165, 32, 0.6);
  text-align: center; /* <--- bikin semua teks di tengah */
}

/* Judul h3 */
.marker-popup-header h3 {
  margin: 0;
  padding-left: 30px;
  font-size: 18px;
  font-weight: bold;
  color: #FFD700; /* sebelumnya #DAA520 */
  text-shadow: 
    2px 2px 4px rgba(0, 0, 0, 0.7),
    0 0 10px rgba(218, 165, 32, 0.5);
  line-height: 1.4;
}

/* Image section */
.marker-popup-image {
  width: 100%;
  height: 180px;
  overflow: hidden;
  padding: 20px 20px 5px 20px;
  background: rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}

.marker-popup-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.marker-popup-image img:hover {
  transform: scale(1.2);
}

/* Category info section - fully centered */
.marker-popup-category {
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
 background: linear-gradient(135deg, rgba(218, 165, 32, 0.3) 0%, rgba(184, 134, 11, 0.3) 100%);
  border-bottom: 1px solid rgba(218, 165, 32, 0.3);
}

.marker-popup-category-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: none !important; /* Hide icon as requested */
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.marker-popup-category-name {
  color: #f3d59b; /* sebelumnya #FFD700 */
  font-weight: bold;
  font-size: 18px;
  line-height: 32px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* === Coordinates section === */
.marker-popup-coords {
  padding: 10px 15px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid rgba(218, 165, 32, 0.3);
}

.marker-popup-coords-title {
  color: #DAA520;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 6px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.marker-popup-coords-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.marker-popup-coord-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 10px;
  background: rgba(218, 165, 32, 0.1);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid rgba(218, 165, 32, 0.3);
}

.marker-popup-coord-item:hover {
  background: rgba(218, 165, 32, 0.25);
  border-color: rgba(218, 165, 32, 0.6);
  box-shadow: 0 0 10px rgba(218, 165, 32, 0.4);
  transform: translateY(-2px);
}

.marker-popup-coord-label {
  color: #FFD700;
  font-weight: bold;
}

.marker-popup-coord-value {
  color: #f5f5f5;
  font-family: 'Courier New', monospace;
  flex: 1;
}

.marker-popup-copy-icon {
  font-size: 14px;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.marker-popup-coord-item:hover .marker-popup-copy-icon {
  opacity: 1;
}

/* === Coordinate Fallback (empty state) === */
.marker-popup-coords-empty {
  background:   background: rgba(0, 0, 0, 0.15);
  
}

.marker-popup-coords-fallback {
  padding: 12px;
  text-align: center;
  color: #DAA520;
  font-style: italic;
  font-size: 13px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  margin-top: 6px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* === Coordinate Edit Fields === */
.marker-popup-coords-edit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.marker-popup-coord-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.marker-popup-coord-edit-label {
  color: #FFD700;
  font-size: 11px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.marker-popup-coord-edit-input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(218, 165, 32, 0.6);
  background: rgba(0, 0, 0, 0.3);
  color: #f5f5f5;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  outline: none;
  transition: all 0.3s ease;
}

.marker-popup-coord-edit-input:focus {
  border-color: #FFD700;
  box-shadow: 0 0 8px rgba(218, 165, 32, 0.7);
  background: rgba(0, 0, 0, 0.4);
}

/* === Footer Container (Visited + ys_id) === */
.marker-popup-footer {
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid rgba(218, 165, 32, 0.3);
}

/* === Visited Checkbox (Kiri) === */
.marker-popup-visited {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 4px 8px;
  border-radius: 6px;
}

.marker-popup-visited:hover {
  background: rgba(218, 165, 32, 0.1);
}

.marker-popup-visited input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #DAA520;
}

.marker-popup-visited-label {
  color: #e0e0e0;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}

/* === ys_id Display (Kanan) === */
.marker-popup-ysid {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.15), rgba(184, 134, 11, 0.15));
  border: 1px solid rgba(218, 165, 32, 0.5);
  border-radius: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.marker-popup-ysid:hover {
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.25), rgba(184, 134, 11, 0.25));
  border-color: rgba(218, 165, 32, 0.7);
  box-shadow: 0 0 12px rgba(218, 165, 32, 0.4);
  transform: translateY(-1px);
}

.marker-popup-ysid-label {
  color: #FFD700;
  font-size: 13px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.5px;
}

/* Responsive: Stack vertically on small screens */
@media (max-width: 350px) {
  .marker-popup-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .marker-popup-ysid {
    align-self: flex-end;
  }
}

/* === Description section === */
.marker-popup-desc {
  padding: 12px 15px;
  background: rgba(0, 0, 0, 0.1);
}

.marker-popup-desc-title {
  color: #DAA520;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 6px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.marker-popup-desc-text {
  color: #e0e0e0;
  font-size: 13px;
  line-height: 1.6;
  max-height: 100px;
  overflow-y: auto;
}

.marker-popup-desc-text::-webkit-scrollbar {
  width: 6px;
}

.marker-popup-desc-text::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.marker-popup-desc-text::-webkit-scrollbar-thumb {
  background: rgba(218, 165, 32, 0.5);
  border-radius: 3px;
}

.marker-popup-desc-text::-webkit-scrollbar-thumb:hover {
  background: rgba(218, 165, 32, 0.7);
}

/* Empty state */
.marker-popup-empty {
  color: #999;
  font-style: italic;
  font-size: 12px;
}

/* === Input Fields di Popup === */
.marker-popup input[type="number"],
.marker-popup textarea {
  width: 100%;
  padding: 6px 10px;
  margin: 4px 0;
  border-radius: 6px;
  border: 1px solid rgba(218, 165, 32, 0.6);
  background: rgba(0, 0, 0, 0.2);
  color: #f5f5f5;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  outline: none;
  transition: all 0.3s ease;
}

.marker-popup input[type="number"]:focus,
.marker-popup textarea:focus {
  border-color: #FFD700;
  box-shadow: 0 0 8px rgba(218, 165, 32, 0.7);
  background: rgba(0, 0, 0, 0.3);
}

/* === Actions Container === */
.marker-popup-actions {
  padding: 12px 15px;
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.15);
  justify-content: center;
}

/* === Buttons di Popup === */
.marker-popup-edit-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin: 4px 2px;
  border: 1px solid rgba(218, 165, 32, 0.8);
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.3), rgba(184, 134, 11, 0.3));
  color: #FFD700;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.marker-popup-edit-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.marker-popup-edit-btn:hover {
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.5), rgba(184, 134, 11, 0.5));
  box-shadow: 0 0 10px rgba(218, 165, 32, 0.6);
  transform: translateY(-1px);
}

.marker-popup-edit-btn.editing {
  background: linear-gradient(135deg, #fff8e7, #f9e6a9, #f6d97a);  ,
  color: #FFD700;
}

.marker-popup-edit-btn.cancel {
  background: linear-gradient(135deg, #fff8e7, #f9e6a9, #f6d97a);  ,
  border-color: rgba(255,69,0,0.7);
  color: #FFD700;
}

/* === Copy notification === */
.copy-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.95), rgba(56, 142, 60, 0.95));
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(76, 175, 80, 0.4);
  font-size: 14px;
  font-weight: bold;
  opacity: 0;
  transform: translateX(100px);
  transition: all 0.3s ease;
  border: 2px solid rgba(129, 199, 132, 0.8);
}

.copy-notification.show {
  opacity: 1;
  transform: translateX(0);
}

/* === Stop propagation on inputs/buttons === */
.marker-popup input,
.marker-popup textarea,
.marker-popup button {
  cursor: pointer;
}


/* === Section Header with Edit Button === */
/* === Section Header with Edit Button === */
.marker-popup-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

/* Tombol edit tanpa background */
.marker-popup-section-edit-btn {
  position: relative;
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  padding: 4px;
  background: transparent; /* 🚫 Tidak ada background */
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none; /* 🚫 Hilangkan bayangan */
}

.marker-popup-section-edit-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(1.1);
  transition: transform 0.3s ease, filter 0.3s ease;
}

/* Tooltip yang muncul di sebelah kanan saat hover */
.marker-popup-section-edit-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(-10px);
  background: rgba(0, 0, 0, 0.85); /* Tooltip tetap gelap */
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

/* Arrow tooltip */
.marker-popup-section-edit-btn::before {
  content: '';
  position: absolute;
  left: calc(100% + 2px);
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 6px 5px 0;
  border-color: transparent rgba(0, 0, 0, 0.85) transparent transparent;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}

/* Hover: hanya efek ringan pada ikon + tampilkan tooltip */
.marker-popup-section-edit-btn:hover img {
  transform: scale(1.15) rotate(10deg);
  filter: brightness(1.3);
}

.marker-popup-section-edit-btn:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.marker-popup-section-edit-btn:hover::before {
  opacity: 1;
}

/* === Section Actions (Save/Cancel buttons) === */
.marker-popup-section-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

.marker-popup-section-actions .marker-popup-edit-btn {
  flex: 1;
  justify-content: center;
  margin: 0;
}

/* === Coordinate Edit Fields === */
.marker-popup-coords-edit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.marker-popup-coord-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.marker-popup-coord-edit-label {
  color: #FFD700;
  font-size: 11px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.marker-popup-coord-edit-input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(218, 165, 32, 0.6);
  background: rgba(0, 0, 0, 0.3);
  color: #f5f5f5;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  outline: none;
  transition: all 0.3s ease;
  box-sizing: border-box; /* 🔥 Penting agar padding tidak overflow */
}

.marker-popup-coord-edit-input:focus {
  border-color: #FFD700;
  box-shadow: 0 0 8px rgba(218, 165, 32, 0.7);
  background: rgba(0, 0, 0, 0.4);
}

/* Fix untuk Description Textarea */
.marker-popup-desc-edit {
  width: 100%;
  min-height: 80px;
  padding: 8px 10px;
  margin: 8px 0;
  border-radius: 6px;
  border: 1px solid rgba(218, 165, 32, 0.6);
  background: rgba(0, 0, 0, 0.3);
  color: #f5f5f5;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  outline: none;
  transition: all 0.3s ease;
  resize: vertical;
  box-sizing: border-box; /* 🔥 Penting agar padding tidak overflow */
}

.marker-popup-desc-edit:focus {
  border-color: #FFD700;
  box-shadow: 0 0 8px rgba(218, 165, 32, 0.7);
  background: rgba(0, 0, 0, 0.4);
}

/* Update existing styles */
.marker-popup-coords-title,
.marker-popup-desc-title {
  margin-bottom: 0; /* Reset margin karena sudah ada di section-header */
}

/* Responsive */
@media (max-width: 400px) {
  .marker-popup-section-edit-btn {
    width: 20px;
    height: 20px;
  }
  
  .marker-popup-section-edit-btn::after {
    font-size: 11px;
    padding: 4px 8px;
  }
}
/* === Loading Overlay === */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9998;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: none;
}

@media (min-width: 769px) {
  #loadingOverlay {
    background-image: url('https://cdn1.epicgames.com/spt-assets/a55e4c8b015d445195aab2f028deace6/where-winds-meet-1n85i.jpg');
  }
}

@media (max-width: 768px) {
  #loadingOverlay {
    background-image: url('https://cdn1.epicgames.com/spt-assets/a55e4c8b015d445195aab2f028deace6/where-winds-meet-1n85i.jpg');
  }
}

/* === Loading Spinner === */
#loadingSpinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 22px;
  font-family: 'Lato', sans-serif;
  font-weight: bold;
  background: rgba(0, 0, 0, 0.6);
  padding: 16px 28px;
  border-radius: 12px;
  text-align: center;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}