@import '../../css/variables.css';
@import '../../css/components.css';


/* Map Only Page Styles */
body.map-only {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-secondary);
}

/* Map Wrapper */
.map-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Map Container */
.map-container {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: var(--bg-tertiary);
  border-radius: var(--border-radius-lg);
}


/* Map Element */
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  border-radius: var(--border-radius-lg);
  pointer-events: auto;
}

/* Control Panel */
.control-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 280px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 10000;
  transition: box-shadow 0.3s ease, transform 0.3s ease, width 0.3s ease, height 0.3s ease;
  max-height: calc(100% - 40px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #e5e7eb;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  min-height: 40px;
  pointer-events: auto !important;
  touch-action: none;
}

.control-panel:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.control-panel.dragging {
  cursor: grabbing;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: none;
  transition: none;
  z-index: 10001;
}

/* Panel Header */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  background-color: #f9fafb;
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
  cursor: move !important;
  min-height: 36px;
  transition: all 0.3s ease;
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  touch-action: none;
  position: relative;
}

.panel-header:hover {
  background-color: #f3f4f6;
}

.panel-header.dragging {
  cursor: grabbing;
}

.panel-header h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.panel-header h3::before {
  content: '⚙️';
  font-size: 12px;
  flex-shrink: 0;
}

/* Header Controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Panel Toggle */
.panel-toggle {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: #6b7280;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.3s ease;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.panel-toggle:hover {
  background-color: #e5e7eb;
  color: #111827;
  transform: rotate(90deg);
}

.panel-toggle:active {
  transform: rotate(90deg) scale(0.9);
}

/* Reset Button */
.reset-button {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  color: #6b7280;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.3s ease;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.reset-button:hover {
  background-color: #e5e7eb;
  color: #3b82f6;
  transform: rotate(180deg);
}

.reset-button:active {
  transform: rotate(180deg) scale(0.9);
}

/* Panel Content */
.panel-content {
  padding: 12px;
  overflow-y: auto;
  flex-grow: 1;
  transition: all 0.3s ease;
  cursor: default;
  user-select: text;
  max-height: calc(100vh - 120px);
}

.panel-content::-webkit-scrollbar {
  width: 4px;
}

.panel-content::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 9999px;
}

.panel-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 9999px;
  transition: background 0.3s ease;
}

.panel-content::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Panel Minimized */
.control-panel.minimized {
  height: 36px;
  width: 200px;
  min-width: 200px;
  max-height: 36px;
}

.control-panel.minimized .panel-content {
  display: none;
  opacity: 0;
  height: 0;
}

.control-panel.minimized .panel-header {
  border-radius: 8px;
  border-bottom: none;
}

.control-panel.minimized .panel-header h3 {
  font-size: 12px;
}

/* Sections */
.user-section,
.data-section,
.risk-section,
.auth-section,
.status-section {
  background-color: #f9fafb;
  border-radius: 6px;
  padding: 8px;
  transition: all 0.3s ease;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.user-section:hover,
.data-section:hover,
.risk-section:hover,
.auth-section:hover,
.status-section:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.user-section h4,
.data-section h4,
.risk-section h4,
.auth-section h4,
.status-section h4 {
  margin: 0 0 8px 0;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.user-section h4::before {
  content: '👤';
  font-size: 11px;
}

.data-section h4::before {
  content: '📊';
  font-size: 11px;
}

.risk-section h4::before {
  content: '⚠️';
  font-size: 11px;
}

.auth-section h4::before {
  content: '🔐';
  font-size: 11px;
}

.status-section h4::before {
  content: '📋';
  font-size: 11px;
}

/* User Section */
.user-section p {
  margin: 0 0 var(--spacing-xs) 0;
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

.user-info-flex {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
}

.user-name-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  font-weight: var(--font-weight-semibold);
}

.user-name-link:hover {
  text-decoration: underline;
}

.user-role {
  display: flex;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-xs);
}

.role-badge {
  padding: 2px var(--spacing-xs);
  border-radius: var(--border-radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--bg-primary);
  background-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.role-badge:nth-child(2) {
  background-color: var(--warning-color);
}

.role-badge:nth-child(3) {
  background-color: var(--error-color);
}

/* Admin Section */
.admin-section {
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius-md);
  padding: var(--spacing-xs);
  transition: all var(--transition-fast);
  margin-bottom: var(--spacing-xs);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.3s ease-out;
  animation-delay: 0.5s;
}

.admin-section:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.admin-section h4 {
  margin: 0 0 var(--spacing-xs) 0;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.admin-section h4::before {
  content: '⚙️';
  font-size: var(--font-size-xs);
}

.admin-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

/* Action Buttons */
.action-buttons,
.risk-buttons,
.auth-buttons,
.admin-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background-color: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background-color: #2563eb;
}

.btn-secondary {
  background-color: #6b7280;
  color: white;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.btn-error {
  background-color: #ef4444;
  color: white;
}

.btn-error:hover {
  background-color: #dc2626;
}

.btn-outline {
  background-color: transparent;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-outline:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 11px;
}

.btn-icon {
  font-size: 12px;
  flex-shrink: 0;
}

/* Status Views */
#progress-view,
#stats-view,
#error-view {
  transition: all 0.3s ease;
  padding: 8px;
  border-radius: 6px;
  background-color: #ffffff;
}

#progress-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#progress-text {
  font-size: 12px;
  color: #111827;
  font-weight: 500;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.progress {
  margin: 0;
  height: 6px;
  background-color: #f3f4f6;
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 9999px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

#progress-stats {
  font-size: 11px;
  color: #6b7280;
  text-align: right;
  font-weight: 500;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* Stats View */
#stats-view {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

#stats-view p {
  margin: 0;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background-color: #f3f4f6;
  border-radius: 6px;
  transition: all 0.3s ease;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

#stats-view p:hover {
  background-color: #e5e7eb;
  transform: translateX(2px);
}

#stats-view p span:first-child {
  color: #6b7280;
  font-weight: 500;
}

#stats-view p span:last-child {
  color: #111827;
  font-weight: 600;
}

#stats-view .text-sm {
  font-size: 11px;
  grid-column: 1 / -1;
  text-align: center;
  color: #9ca3af;
  padding: 8px;
  background-color: transparent;
  border-top: 1px solid #e5e7eb;
  margin-top: 8px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* Error View */
#error-view {
  background-color: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 8px;
}

#error-message {
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

#error-message::before {
  content: '❌';
  font-size: 12px;
}

#error-detail {
  font-size: 11px;
  color: #6b7280;
  white-space: pre-wrap;
  background-color: #f3f4f6;
  padding: 8px;
  border-radius: 6px;
  border-left: 2px solid #dc2626;
  line-height: 1.3;
  max-height: 100px;
  overflow-y: auto;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* Hidden Class */
.hidden {
  display: none !important;
  opacity: 0;
  transform: translateY(-10px);
}

.text-xs {
  font-size: 11px;
}

.text-sm {
  font-size: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .control-panel {
    width: 260px;
    right: 10px;
    top: 10px;
  }

  .panel-content {
    padding: 10px;
  }

  .user-actions {
    flex-direction: column;
  }

  .control-panel.minimized {
    width: 180px;
    min-width: 180px;
  }
}

@media (max-width: 480px) {
  .control-panel {
    width: calc(100% - 20px);
    max-width: 280px;
    top: 10px;
    right: 10px;
    left: 10px;
    margin: 0 auto;
  }

  .panel-content {
    max-height: 50vh;
  }

  .control-panel.minimized {
    width: 160px;
    min-width: 160px;
    left: auto;
    margin: 0;
  }
}

@media (max-height: 600px) {
  .control-panel {
    max-height: calc(100% - 20px);
    top: 10px;
    right: 10px;
  }

  .panel-content {
    padding: 10px;
    max-height: 40vh;
  }
}

/* Leaflet Overrides */
.leaflet-popup-content {
  margin: 0;
  padding: 0;
  border-radius: 6px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.leaflet-popup-content-wrapper {
  border-radius: 6px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border: none;
  background-color: #ffffff;
}

.leaflet-popup-tip {
  background-color: #ffffff;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.leaflet-popup {
  transition: all 0.3s ease;
}

.leaflet-popup:hover {
  transform: scale(1.02);
}

/* Map Markers */
.risk-marker {
  transition: all 0.3s ease;
  cursor: pointer;
}

.risk-marker:hover {
  z-index: 1000 !important;
}

.risk-marker-pulse {
  transition: all 1s ease;
  pointer-events: none;
}

/* Risk Level Marker Styles */
.risk-红色 {
  animation: pulse-red 2s infinite;
}

.risk-橙色 {
  animation: pulse-orange 2s infinite;
}

.risk-黄色 {
  animation: pulse-yellow 2s infinite;
}

.risk-蓝色 {
  animation: pulse-blue 2s infinite;
}

.risk-无预警 {
  animation: pulse-gray 2s infinite;
}

/* Pulse Animations */
@keyframes pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
}

@keyframes pulse-orange {
  0% {
    box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(234, 88, 12, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(234, 88, 12, 0);
  }
}

@keyframes pulse-yellow {
  0% {
    box-shadow: 0 0 0 0 rgba(202, 138, 4, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(202, 138, 4, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(202, 138, 4, 0);
  }
}

@keyframes pulse-blue {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

@keyframes pulse-gray {
  0% {
    box-shadow: 0 0 0 0 rgba(107, 114, 128, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(107, 114, 128, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(107, 114, 128, 0);
  }
}

/* Popup Card */
.popup-card {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  padding: 12px;
  min-width: 260px;
  max-width: 320px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.popup-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.popup-location {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.risk-badge {
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  color: #ffffff;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.risk-badge.risk-red {
  background-color: #dc2626;
}

.risk-badge.risk-orange {
  background-color: #ea580c;
}

.risk-badge.risk-yellow {
  background-color: #ca8a04;
}

.risk-badge.risk-blue {
  background-color: #2563eb;
}

.risk-badge.risk-gray {
  background-color: #6b7280;
}

.popup-warning {
  font-size: 12px;
  margin-bottom: 10px;
  padding: 8px;
  background-color: rgba(234, 88, 12, 0.1);
  border-radius: 6px;
  border-left: 3px solid #ea580c;
  color: #9a3412;
  line-height: 1.4;
  font-weight: 500;
}

.popup-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.popup-grid div {
  background-color: #f9fafb;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.popup-grid div::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.popup-grid div:hover {
  background-color: #f3f4f6;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.popup-grid div:hover::before {
  transform: scaleX(1);
}

.popup-grid div strong {
  display: block;
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 2px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.popup-grid div span {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
}

.popup-meta {
  font-size: 11px;
  color: #9ca3af;
  display: flex;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
}

.popup-meta span {
  flex: 1;
  text-align: center;
  padding: 0 8px;
  line-height: 1.2;
}

.popup-meta span:first-child {
  border-right: 1px solid #e5e7eb;
}

/* Popup Actions */
.popup-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
}

.popup-action-btn {
  flex: 1;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background-color: #f3f4f6;
  color: #374151;
}

.popup-action-btn:hover {
  background-color: #e5e7eb;
  transform: translateY(-1px);
}

.popup-action-btn.primary {
  background-color: #3b82f6;
  color: white;
}

.popup-action-btn.primary:hover {
  background-color: #2563eb;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 硬件加速动画 */
.control-panel {
  animation: slideIn 0.5s ease-out;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-will-change: transform, box-shadow;
  will-change: transform, box-shadow;
}

.user-section,
.data-section,
.risk-section,
.auth-section,
.status-section,
.admin-section {
  animation: fadeIn 0.3s ease-out;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-will-change: transform, box-shadow;
  will-change: transform, box-shadow;
}

.user-section { animation-delay: 0.1s; }
.data-section { animation-delay: 0.2s; }
.risk-section { animation-delay: 0.3s; }
.status-section { animation-delay: 0.4s; }
.admin-section { animation-delay: 0.5s; }

/* 可访问性改进 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 键盘导航支持 */
.btn:focus,
.popup-action-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  z-index: 10;
}

.control-panel:focus-within {
  box-shadow: 0 0 0 2px #3b82f6, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ARIA属性支持 */
/* 注意：ARIA属性应在HTML元素上设置，而非CSS中 */
.risk-marker {
  /* 建议在HTML中添加: aria-label="风险标记" */
}

.popup-card {
  /* 建议在HTML中添加: aria-labelledby="popup-location" */
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  .control-panel {
    border: 2px solid #000000;
  }

  .btn {
    border: 2px solid #000000;
  }

  .risk-badge {
    border: 2px solid currentColor;
  }

  .popup-card {
    border: 2px solid #000000;
  }
}

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

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
}

.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--border-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 1;
}

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

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: dark) {
  /* 控制面板 */
  .control-panel {
    background-color: #1f2937;
    border-color: #374151;
  }

  .control-panel:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  }

  /* 面板头部 */
  .panel-header {
    background-color: #374151;
    border-bottom-color: #4b5563;
  }

  .panel-header:hover {
    background-color: #4b5563;
  }

  .panel-header h3 {
    color: #f3f4f6;
  }

  /* 头部控件 */
  .panel-toggle {
    color: #9ca3af;
  }

  .panel-toggle:hover {
    background-color: #4b5563;
    color: #f3f4f6;
  }

  .reset-button {
    color: #9ca3af;
  }

  .reset-button:hover {
    background-color: #4b5563;
    color: #60a5fa;
  }

  /* 功能区域 */
  .user-section,
  .data-section,
  .risk-section,
  .auth-section,
  .status-section,
  .admin-section {
    background-color: #374151;
    border-color: #4b5563;
  }

  .user-section:hover,
  .data-section:hover,
  .risk-section:hover,
  .auth-section:hover,
  .status-section:hover,
  .admin-section:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  }

  /* 区域标题 */
  .user-section h4,
  .data-section h4,
  .risk-section h4,
  .auth-section h4,
  .status-section h4,
  .admin-section h4 {
    color: #9ca3af;
  }

  /* 用户信息 */
  .user-section p {
    color: #f3f4f6;
  }

  .user-name-link {
    color: #f3f4f6;
  }

  .role-badge {
    color: #1f2937;
  }

  /* 按钮样式 */
  .btn {
    color: #f3f4f6;
  }

  .btn-primary {
    background-color: #2563eb;
  }

  .btn-primary:hover {
    background-color: #1d4ed8;
  }

  .btn-secondary {
    background-color: #6b7280;
  }

  .btn-secondary:hover {
    background-color: #4b5563;
  }

  .btn-error {
    background-color: #dc2626;
  }

  .btn-error:hover {
    background-color: #b91c1c;
  }

  .btn-outline {
    color: #d1d5db;
    border-color: #4b5563;
  }

  .btn-outline:hover {
    background-color: #4b5563;
    border-color: #6b7280;
  }

  /* 状态视图 */
  #progress-view,
  #stats-view,
  #error-view {
    background-color: #1f2937;
  }

  #progress-text {
    color: #f3f4f6;
  }

  .progress {
    background-color: #374151;
  }

  .progress-bar {
    background: linear-gradient(90deg, #2563eb, #3b82f6);
  }

  #progress-stats {
    color: #9ca3af;
  }

  #stats-view p {
    background-color: #374151;
  }

  #stats-view p:hover {
    background-color: #4b5563;
  }

  #stats-view p span:first-child {
    color: #9ca3af;
  }

  #stats-view p span:last-child {
    color: #f3f4f6;
  }

  #stats-view .text-sm {
    color: #9ca3af;
    border-top-color: #4b5563;
  }

  #error-view {
    background-color: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.3);
  }

  #error-message {
    color: #fca5a5;
  }

  #error-detail {
    background-color: #374151;
    color: #d1d5db;
    border-left-color: #dc2626;
  }

  #progress-view {
    background-color: #111827;
  }

  .progress {
    background-color: #374151;
  }

  .progress-bar {
    background: linear-gradient(90deg, #2563eb, #3b82f6);
  }

  #progress-text {
    color: #f3f4f6;
  }

  #progress-stats {
    color: #9ca3af;
  }

  /* 滚动条 */
  .panel-content::-webkit-scrollbar-track {
    background: #374151;
  }

  .panel-content::-webkit-scrollbar-thumb {
    background: #4b5563;
  }

  .panel-content::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
  }

  /* 弹窗 */
  .leaflet-popup-content-wrapper {
    background-color: #1f2937;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  }

  .leaflet-popup-tip {
    background-color: #1f2937;
  }

  .popup-card {
    background-color: #1f2937;
    border-color: #374151;
  }

  .popup-location {
    color: #f3f4f6;
  }

  .popup-warning {
    background-color: rgba(234, 88, 12, 0.1);
    border-left-color: #ea580c;
    color: #fdba74;
  }

  .popup-grid div {
    background-color: #374151;
    border-color: #4b5563;
  }

  .popup-grid div:hover {
    background-color: #4b5563;
  }

  .popup-grid div strong {
    color: #9ca3af;
  }

  .popup-grid div span {
    color: #f3f4f6;
  }

  .popup-meta {
    color: #9ca3af;
    border-top-color: #4b5563;
  }

  .popup-action-btn {
    background-color: #374151;
    color: #d1d5db;
  }

  .popup-action-btn:hover {
    background-color: #4b5563;
  }

  .popup-action-btn.primary {
    background-color: #2563eb;
  }

  .popup-action-btn.primary:hover {
    background-color: #1d4ed8;
  }

  /* 加载状态 */
  .loading::after {
    background-color: rgba(31, 41, 55, 0.8);
  }

  /* 高对比度模式 */
  @media (prefers-contrast: high) {
    .control-panel {
      border-color: #f3f4f6;
    }

    .btn {
      border-color: #f3f4f6;
    }

    .risk-badge {
      border-color: #f3f4f6;
    }

    .popup-card {
      border-color: #f3f4f6;
    }
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .control-panel {
    border: 2px solid var(--text-primary);
  }

  .panel-toggle,
  .reset-button {
    border: 1px solid var(--text-primary);
  }

  .risk-badge {
    border: 1px solid currentColor;
  }
}

@media (prefers-color-scheme: dark) {
  body.map-only {
    background-color: var(--bg-secondary);
  }

  .map-container {
    background-color: #101820;
  }

  .control-panel {
    background-color: var(--map-control-bg);
    border-color: var(--map-control-border);
    box-shadow: var(--shadow-map-panel);
    color: var(--text-primary);
    backdrop-filter: blur(16px);
  }

  .control-panel.dragging,
  .control-panel:focus-within,
  .control-panel:hover {
    box-shadow: var(--shadow-map-panel);
  }

  .panel-header {
    background-color: rgba(28, 38, 53, 0.94);
    border-bottom-color: var(--border-light);
  }

  .panel-header:hover {
    background-color: var(--bg-quaternary);
  }

  .panel-header h3,
  #progress-text,
  #stats-view p span:last-child,
  .popup-location,
  .popup-grid div span {
    color: var(--text-primary);
  }

  .panel-toggle,
  .reset-button,
  .user-section h4,
  .data-section h4,
  .risk-section h4,
  .auth-section h4,
  .status-section h4,
  .admin-section h4,
  #progress-stats,
  #stats-view p span:first-child,
  #stats-view .text-sm,
  .popup-grid div strong,
  .popup-meta {
    color: var(--text-secondary);
  }

  .panel-toggle:hover,
  .reset-button:hover {
    background-color: var(--bg-quaternary);
    color: var(--primary-hover);
  }

  .panel-content::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
  }

  .panel-content::-webkit-scrollbar-thumb {
    background: var(--border-medium);
  }

  .panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
  }

  .user-section,
  .data-section,
  .risk-section,
  .auth-section,
  .status-section,
  .admin-section {
    background-color: rgba(28, 38, 53, 0.82);
    border: 1px solid var(--border-light);
    box-shadow: none;
  }

  .user-section:hover,
  .data-section:hover,
  .risk-section:hover,
  .auth-section:hover,
  .status-section:hover,
  .admin-section:hover {
    background-color: rgba(39, 51, 71, 0.92);
    box-shadow: var(--shadow-sm);
  }

  .user-section p,
  .user-name-link {
    color: var(--text-primary);
  }

  .role-badge,
  .btn-primary,
  .btn-secondary,
  .btn-error,
  .popup-action-btn.primary {
    color: var(--on-accent);
  }

  .btn-primary,
  .popup-action-btn.primary {
    background-color: var(--primary-color);
  }

  .btn-primary:hover,
  .popup-action-btn.primary:hover {
    background-color: var(--primary-hover);
  }

  .btn-secondary {
    background-color: var(--secondary-color);
  }

  .btn-secondary:hover {
    background-color: var(--secondary-hover);
  }

  .btn-error {
    background-color: var(--error-color);
  }

  .btn-error:hover {
    background-color: var(--error-hover);
  }

  .btn-outline,
  .popup-action-btn {
    background-color: rgba(28, 38, 53, 0.7);
    border-color: var(--border-medium);
    color: var(--text-primary);
  }

  .btn-outline:hover,
  .popup-action-btn:hover {
    background-color: var(--bg-quaternary);
    border-color: var(--primary-color);
    color: var(--primary-hover);
  }

  #progress-view,
  #stats-view,
  #error-view,
  .popup-card,
  .leaflet-popup-content-wrapper {
    background-color: var(--map-popup-bg);
    border-color: var(--map-popup-border);
    color: var(--text-primary);
  }

  .leaflet-popup-tip {
    background-color: var(--map-popup-bg);
  }

  .progress,
  #stats-view p,
  #error-detail,
  .popup-grid div {
    background-color: var(--bg-tertiary);
  }

  #stats-view p:hover,
  .popup-grid div:hover {
    background-color: var(--bg-quaternary);
  }

  .progress-bar,
  .popup-card::before,
  .popup-grid div::before {
    background: linear-gradient(90deg, var(--primary-color), var(--info-color));
  }

  #stats-view .text-sm,
  .popup-header,
  .popup-meta,
  .popup-actions {
    border-color: var(--border-light);
  }

  .popup-grid div {
    border-color: var(--border-light);
  }

  .popup-warning {
    background-color: var(--warning-soft);
    border-left-color: var(--warning-color);
    color: var(--warning-hover);
  }

  #error-view {
    background-color: var(--error-soft);
    border-color: rgba(248, 113, 113, 0.32);
  }

  #error-message {
    color: var(--error-hover);
  }

  #error-detail {
    color: var(--text-secondary);
    border-left-color: var(--error-color);
  }

  .loading::after {
    background-color: rgba(18, 26, 39, 0.82);
  }
}
