body {
  font-family: "Inter", sans-serif;
  margin-top: 64px;
}

@media screen and (max-width: 768px) {
  .leaflet-control-container .leaflet-left:has(.leaflet-control-zoom) {
    bottom: 60px;
    top: auto;
  }
}

.filter-panel {
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.filter-panel.collapsed {
  transform: translateX(-100%);
}

.filter-toggle {
  position: fixed;
  z-index: 501;
  top: 32%;
  left: 4px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 0 0.5rem 0.5rem 0;
  padding: 12px 8px;
  cursor: pointer;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.15);
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.filter-toggle:hover {
  background: rgba(255, 255, 255, 1);
}

.filter-toggle.panel-open {
  opacity: 0;
  visibility: hidden;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.filter-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #6b7280;
  transition: color 0.2s ease;
}

.filter-collapse-btn:hover {
  color: #374151;
}

.crash-marker-fatal {
  background-color: #dc2626;
  border: 3px solid #ffffff;
  box-shadow:
    0 0 0 2px #dc2626,
    0 2px 6px rgba(220, 38, 38, 0.4);
}

.crash-marker-serious {
  background-color: #f97316;
  border: 3px solid #ffffff;
  box-shadow:
    0 0 0 2px #f97316,
    0 2px 6px rgba(249, 115, 22, 0.4);
}

.crash-marker-moderate {
  background-color: #16a34a;
  border: 3px solid #ffffff;
  box-shadow:
    0 0 0 2px #16a34a,
    0 2px 6px rgba(22, 163, 74, 0.4);
}

.crash-marker-minor {
  background-color: #3b82f6;
  border: 3px solid #ffffff;
  box-shadow:
    0 0 0 2px #3b82f6,
    0 2px 6px rgba(59, 130, 246, 0.4);
}

.crash-marker-noncasualty {
  background-color: #6b7280;
  border: 3px solid #ffffff;
  box-shadow:
    0 0 0 2px #6b7280,
    0 2px 6px rgba(107, 114, 128, 0.4);
}

.crash-marker {
  border-radius: 50%;
  opacity: 0.95;
  transition: all 0.2s ease;
  cursor: pointer;
}

.crash-marker:hover {
  opacity: 1;
  transform: scale(1.4);
  box-shadow:
    0 0 0 3px #ffffff,
    0 4px 12px rgba(0, 0, 0, 0.3);
}

.legend {
  background: white;
  padding: 8px;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  max-width: 180px;
  transition: transform 0.3s ease;
}

.legend.collapsed .legend-content {
  display: none;
}

.legend.collapsed .legend-header {
  margin-bottom: 0;
}

.legend.collapsed .legend-toggle::before {
  content: "+";
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
  gap: 8px;
}

.legend-title {
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  text-align: center;
  flex: 1;
}

.legend-toggle {
  font-size: 16px;
  color: #6b7280;
  line-height: 1;
  font-weight: bold;
  flex-shrink: 0;
}

.legend-toggle::before {
  content: "−";
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  font-size: 10px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  border: 2px solid #ffffff;
  box-shadow:
    0 0 0 1px currentColor,
    0 1px 2px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Tooltip styling for crash cards */
.leaflet-tooltip {
  background: #ffffff !important;
  border: 1px solid #dcdcdc !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
  padding: 0 !important;
  font-family: "Inter", sans-serif !important;
  white-space: normal !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  z-index: 10000 !important;
  cursor: move !important;
}

.leaflet-tooltip.dragging {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
  cursor: grabbing !important;
}

.leaflet-tooltip-left::before,
.leaflet-tooltip-right::before,
.leaflet-tooltip-top::before,
.leaflet-tooltip-bottom::before {
  display: none !important;
}

.crash-tooltip-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 32px;
  height: 32px;
  background: white;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
  color: #6b7280;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transition: all 0.2s ease;
}

.crash-tooltip-close:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #dc2626;
  transform: scale(1.15);
}

/* Thin line connecting marker to tooltip */
.crash-connector-line {
  stroke: #475569;
  stroke-width: 3;
  fill: none;
  pointer-events: none;
  opacity: 0.9;
}

/* RUM Legend Panel */
.rum-legend-panel {
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.rum-legend-panel.collapsed {
  transform: translateX(100%);
}

.rum-legend-toggle {
  position: fixed;
  z-index: 501;
  top: 32%;
  right: 4px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 0.5rem 0 0 0.5rem;
  padding: 12px 8px;
  cursor: pointer;
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.15);
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.rum-legend-toggle:hover {
  background: rgba(255, 255, 255, 1);
}

.rum-legend-toggle.panel-open {
  opacity: 0;
  visibility: hidden;
}

.rum-symbol-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
  padding: 4px;
  border-radius: 4px;
  background: #f9fafb;
}

.rum-symbol-item:hover {
  background: #f3f4f6;
}

/* Polygon selection button */
#mapButtonsContainer {
  position: fixed;
  z-index: 1000;
  top: 80px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media screen and (max-width: 768px) {
  #mapButtonsContainer {
    top: 120px;
    right: 25px;
  }
}

.polygon-select-btn {
  background: white;
  border: 2px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media screen and (max-width: 768px) {
  .polygon-select-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
}

.polygon-select-btn:hover {
  background: #f3f4f6;
  border-color: #3b82f6;
}

.polygon-select-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.polygon-select-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.clear-selection-btn {
  background: #ef4444;
  border: 2px solid #dc2626;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 12px;
  font-weight: 600;
  color: white;
  transition: all 0.2s ease;
  display: none;
}

@media screen and (max-width: 768px) {
  .clear-selection-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
}

.clear-selection-btn:hover {
  background: #dc2626;
}

.export-crash-btn {
  background: white;
  border: 2px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  transition: all 0.2s ease;
  display: none;
  align-items: center;
  gap: 6px;
}

@media screen and (max-width: 768px) {
  .export-crash-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
}

.export-crash-btn:hover {
  background: #f3f4f6;
  border-color: #3b82f6;
}

.hide-leaflet-controls .leaflet-control-container .leaflet-right {
  display: none;
}

/* Terms and Conditions Modal */
.terms-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.terms-modal {
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.terms-header {
  background: #059669;
  color: white;
  padding: 16px 24px;
  font-size: 18px;
  font-weight: 600;
}

.terms-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.terms-content h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1f2937;
}

.terms-content p {
  margin-bottom: 12px;
  color: #374151;
  font-size: 14px;
}

.terms-content a {
  color: #2563eb;
  text-decoration: underline;
}

.terms-content a:hover {
  color: #1d4ed8;
}

.terms-footer {
  padding: 20px 24px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.terms-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}

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

.terms-checkbox label {
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}

.terms-buttons {
  display: flex;
  gap: 12px;
}

.terms-button {
  padding: 8px 24px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.terms-button-accept {
  background: #059669;
  color: white;
}

.terms-button-accept:hover:not(:disabled) {
  background: #047857;
}

.terms-button-accept:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.terms-button-decline {
  background: #6b7280;
  color: white;
}

.terms-button-decline:hover {
  background: #4b5563;
}

.terms-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

@media screen and (max-width: 640px) {
  .terms-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .terms-checkbox {
    min-width: 100%;
  }

  .terms-buttons {
    width: 100%;
    justify-content: stretch;
  }

  .terms-button {
    flex: 1;
  }
}
