/* Reset and base styles */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #181a1b;
  color: #222;
}

#map {
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}

/* Responsive container */
.map-container {
  position: relative;
  width: 100%;
  height: 100vh;
}

/* Enhanced Popup Styles */
.maplibregl-popup-content,
.maptiler-popup-content {
  background: #fff !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  padding: 0 !important;
  max-width: 340px !important;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
  overflow: hidden !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.maplibregl-popup-tip,
.maptiler-popup-tip {
  border-top-color: rgba(255, 255, 255, 0.98) !important;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1)) !important;
}

.maplibregl-popup-close-button,
.maptiler-popup-close-button {
  background: rgba(183, 28, 28, 0.9) !important;
  color: white !important;
  border-radius: 50% !important;
  width: 24px !important;
  height: 24px !important;
  font-size: 14px !important;
  line-height: 1 !important;
  top: 8px !important;
  right: 8px !important;
  border: 2px solid white !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  transition: all 0.2s ease !important;
}

.maplibregl-popup-close-button:hover,
.maptiler-popup-close-button:hover {
  background: #b71c1c !important;
  transform: scale(1.1) !important;
}

/* Custom Popup Content */
.grave-popup {
  position: relative;
  overflow: hidden;
  animation: popupFadeIn 0.3s ease-out;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- POPUP HEADER: Darker gradient, text-shadow for sharpness --- */
.grave-popup-header {
  background: linear-gradient(135deg, #8b1818 0%, #b71c1c 100%);
  color: white;
  padding: 16px 20px 12px 20px;
  position: relative;
  margin-bottom: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

.grave-popup-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px 0;
  position: relative;
  z-index: 1;
  line-height: 1.3;
  width: 100%;
  white-space: normal;
  word-break: break-word;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

.grave-popup-subtitle {
  font-size: 13px;
  opacity: 0.9;
  margin: 0;
  position: relative;
  z-index: 1;
  font-weight: 400;
}

.grave-popup-badge {
  margin: 6px 0 0 0;
  position: static;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.18);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

/* --- POPUP CONTENT: Ensure fully opaque background, larger font --- */
.grave-popup-content {
  padding: 18px 22px 22px 22px;
  background: #fff;
  font-size: 16px;
  color: #222;
}

.grave-popup-info {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.grave-popup-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.grave-popup-label {
  font-weight: 600;
  color: #555;
  min-width: 80px;
  flex-shrink: 0;
}

.grave-popup-value {
  color: #333;
  flex: 1;
}

.grave-popup-victims {
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  border-left: 4px solid #b71c1c;
  position: relative;
  overflow: hidden;
}

/* --- VICTIMS SHIMMER: More subtle effect --- */
.grave-popup-victims::before {
  background: linear-gradient(45deg, transparent 30%, rgba(183, 28, 28, 0.025) 50%, transparent 70%);
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.grave-popup-victims .grave-popup-label {
  color: #b71c1c;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.grave-popup-victims .grave-popup-value {
  font-size: 28px;
  font-weight: 800;
  color: #b71c1c;
  text-align: center;
}

.grave-popup-source {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 10px;
  margin-top: 12px;
  border: 1px solid #e9ecef;
  transition: all 0.2s ease;
}

.grave-popup-source:hover {
  background: #e9ecef;
  border-color: #b71c1c;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(183, 28, 28, 0.1);
}

.grave-popup-source a {
  color: #b71c1c;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.grave-popup-source a:hover {
  color: #d32f2f;
  text-decoration: underline;
}

.grave-popup-notes {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 6px;
  padding: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: #856404;
  line-height: 1.4;
  position: relative;
}

.grave-popup-notes::before {
  content: '💡';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  background: white;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border: 1px solid #ffeaa7;
}

.grave-popup-footer {
  background: #f8f9fa;
  padding: 12px 20px;
  border-top: 1px solid #e9ecef;
  font-size: 11px;
  color: #6c757d;
  text-align: center;
  font-style: italic;
}

/* --- HEADER BORDER for separation --- */
.grave-popup-header {
  border-bottom: 2px solid #fff;
}

/* Panel base styles */
.panel {
  position: absolute;
  background: rgba(255,255,255,0.97);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  z-index: 1001;
  font-size: 15px;
  color: #222;
  border: 1px solid rgba(255,255,255,0.2);
}

/* Context panel */
.context-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 24px 20px 20px 20px;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  display: none;
}

.context-panel h2 {
  margin-top: 0;
  font-size: 22px;
  color: #b71c1c;
  font-weight: bold;
}

.context-panel .sources {
  font-size: 12px;
  color: #555;
  margin-top: 12px;
}

/* --- Enhanced Legend Styles --- */
.legend {
  position: absolute;
  bottom: 34px;
  left: 14px;
  padding: 20px 28px 18px 28px;
  background: rgba(255,255,255,0.5); /* slightly more transparent */
  border-radius: 18px;
  box-shadow: 0 6px 32px rgba(44,62,80,0.13), 0 1.5px 6px rgba(44,62,80,0.08);
  border: 1.5px solid #e0e0e0;
  font-size: 15px;
  color: #222;
  z-index: 1100;
  min-width: 240px;
  max-width: 340px;
  transition: box-shadow 0.2s, background 0.2s, border 0.2s;
  cursor: pointer;
  user-select: none;
}
.legend:hover, .legend:focus {
  box-shadow: 0 10px 40px rgba(44,62,80,0.18), 0 2px 8px rgba(44,62,80,0.10);
  background: #f7fafc;
  border-color: #b71c1c;
}
.legend-title {
  font-size: 1.08em;
  font-weight: 700;
  color: #b71c1c;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
  text-align: left;
}
.legend-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 10px;
}
.legend .legend-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 2px rgba(44,62,80,0.10);
  font-size: 1.1em;
}
.legend .primary { background: #d32f2f; }
.legend .secondary { background: #8d5524; }
.legend .tertiary { background: #1976d2; }
.legend .unknown { background: #757575; }
.legend .label {
  font-size: 15px;
  color: #222;
  font-weight: 500;
  letter-spacing: 0.1px;
}
@media (max-width: 768px) {
  .legend {
    bottom: 10px;
    left: 10px;
    padding: 12px 10px 10px 10px;
    min-width: 0;
    max-width: 95vw;
    font-size: 13px;
    background: rgba(255,255,255,0.96);
  }
  .legend-title {
    font-size: 1em;
    margin-bottom: 8px;
  }
  .legend .legend-marker {
    width: 16px;
    height: 16px;
    margin-right: 7px;
    font-size: 1em;
  }
  .legend .label {
    font-size: 13px;
  }
}

/* Stats panel */
.stats-panel {
  position: absolute;
  bottom: 20px;
  right: 20px;
  padding: 14px 20px;
  max-width: 320px;
  margin-bottom: 10px;
  background: rgba(255,255,255,0.5); /* match legend opacity */
  border-radius: 16px;
  box-shadow: 0 6px 32px rgba(44,62,80,0.13), 0 1.5px 6px rgba(44,62,80,0.08);
  border: 1.5px solid #e0e0e0;
  font-size: 15px;
  color: #222;
  z-index: 1100;
  transition: box-shadow 0.2s, background 0.2s, border 0.2s;
}
.stats-panel h3 {
  margin-top: 0;
  font-size: 18px;
  color: #b71c1c;
  font-weight: bold;
  margin-bottom: 10px;
}
.stats-panel .stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* Map controls */
.map-controls {
  position: absolute;
  top: 20px;
  right: 80px;
  background: rgba(30,32,34,0.97);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 1002;
  display: flex;
  gap: 2px;
}

.map-controls button {
  background: #232526;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 6px 12px;
  margin: 0 2px;
  cursor: pointer;
  font-size: 12px;
  color: #eee;
  transition: all 0.2s;
}

.map-controls button:hover {
  background: #333;
  color: #fff;
}

.map-controls button.active {
  background: #444;
  color: #fff;
  border-color: #444;
}

/* Loading indicator */
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 20px;
  border-radius: 8px;
  z-index: 2000;
}

/* Error message */
.error {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #f44336;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 2000;
  display: none;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .context-panel {
    max-width: 90vw;
    max-height: 70vh;
    padding: 16px;
  }
  
  /* Hide legend and stats panels in mobile */
  .legend {
    display: none !important;
  }
  
  .stats-panel {
    display: none !important;
  }
  
  /* Mobile popup adjustments */
  .maplibregl-popup-content,
  .maptiler-popup-content {
    max-width: 280px !important;
    background: #fff !important;
  }
  
  .grave-popup-title {
    font-size: 17px;
  }
  
  .grave-popup-header {
    padding: 12px 16px 8px 16px;
  }
  
  .grave-popup-badge {
    font-size: 10px;
    padding: 3px 7px;
    margin: 4px 0 0 0;
  }
  
  .grave-popup-victims .grave-popup-value {
    font-size: 22px;
  }
  
  .grave-popup-row {
    font-size: 13px;
  }
  
  .grave-popup-label {
    min-width: 70px;
  }
  
  .grave-popup-content {
    font-size: 14px;
    padding: 14px 12px 16px 12px;
  }
  
  /* Move map controls to bottom left */
  .map-controls {
    position: fixed;
    bottom: 16px;
    left: 16px;
    top: auto;
    right: auto;
    padding: 6px;
    z-index: 1000;
  }
  
  .map-controls button {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* Accessibility improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles for keyboard navigation */
button:focus,
.legend:focus {
  outline: 2px solid #007acc;
  outline-offset: 2px;
}

/* Suggestion Button */
.suggestion-button-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

.suggestion-btn {
  background: linear-gradient(135deg, #4a4a4a 0%, #2d2d2d 50%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: inherit;
}

.suggestion-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, #5a5a5a 0%, #3d3d3d 100%);
}

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

.suggestion-icon {
  font-size: 16px;
}

.suggestion-text {
  white-space: nowrap;
}

/* Suggestion Modal */
.suggestion-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

.suggestion-modal.show {
  display: flex;
}

.suggestion-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.suggestion-modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.suggestion-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 0 24px;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 24px;
}

.suggestion-modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #333;
}

.suggestion-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.suggestion-modal-close:hover {
  background: #f5f5f5;
  color: #333;
}

/* Form Styles */
.suggestion-form {
  padding: 0 24px 24px 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  transition: all 0.2s ease;
  background: white;
}

.form-input:focus,
.form-textarea:focus {
  border-color: #b71c1c;
  box-shadow: 0 0 0 3px rgba(183, 28, 28, 0.1);
  outline: none;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-help {
  margin-top: 6px;
  font-size: 12px;
  color: #666;
}

.form-error {
  margin-top: 6px;
  font-size: 12px;
  color: #d32f2f;
  font-weight: 500;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #b71c1c 0%, #8b1818 100%);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #c62828 0%, #b71c1c 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(183, 28, 28, 0.3);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: #f5f5f5;
  color: #333;
  border: 1px solid #ddd;
}

.btn-secondary:hover {
  background: #e8e8e8;
}

.suggestion-message {
  padding: 16px 24px 24px 24px;
  border-radius: 8px;
  margin: 0 24px 24px 24px;
  font-weight: 500;
}

.suggestion-message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.suggestion-message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Loading state */
.btn-loading {
  display: none;
}

.btn.loading .btn-text {
  display: none;
}

.btn.loading .btn-loading {
  display: inline;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .suggestion-button-container {
    bottom: 70px;
    left: 16px;
    transform: none;
  }
  
  .suggestion-btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .suggestion-text {
    display: none;
  }
  
  .suggestion-modal-content {
    width: 95%;
    margin: 20px;
  }
  
  .suggestion-modal-header {
    padding: 20px 20px 0 20px;
  }
  
  .suggestion-form {
    padding: 0 20px 20px 20px;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
} 