/* ============================================================
   全局重置与基础样式
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #1a1a2e;
  color: #eaeaea;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ========== 应用主容器 ========== */
.app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ========== 画布容器 ========== */
.canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#antCanvas {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0f0f1a;
  cursor: grab;
}

#antCanvas:active {
  cursor: grabbing;
}

/* ========== 步数显示 (左上角) ========== */
.step-display {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 8px 16px;
  background: rgba(20, 20, 35, 0.85);
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #64c8ff;
  letter-spacing: 0.5px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 20;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* ========== 编辑模式提示 ========== */
.mode-hint {
  position: absolute;
  top: 60px;
  left: 16px;
  padding: 6px 12px;
  background: rgba(255, 170, 0, 0.2);
  border: 1px solid #ffaa00;
  border-radius: 6px;
  color: #ffaa00;
  font-size: 14px;
  z-index: 20;
  pointer-events: none;
  display: none;
}

/* ========== 数据模块 (悬浮于地图右上角) ========== */
.data-module {
  position: absolute;
  top: 16px;
  right: 330px; /* 避开PC端右侧操作栏 */
  width: 320px;
  max-height: 250px;
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 8px;
  background: rgba(18, 18, 32, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: right 0.3s;
}

.data-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(40, 60, 100, 0.4);
  border-bottom: 1px solid rgba(100, 200, 255, 0.1);
  font-size: 13px;
  font-weight: 600;
  color: #64c8ff;
}

.data-table-container {
  overflow-y: auto;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  background: rgba(20, 30, 50, 0.95);
  padding: 6px;
  font-weight: 500;
  color: #8899aa;
  border-bottom: 1px solid rgba(100, 200, 255, 0.15);
}

.data-table td {
  padding: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-variant-numeric: tabular-nums;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.status-free {
  color: #ffaa00;
}

.status-highway {
  color: #00ff88;
  font-weight: bold;
}

.highlight-text {
  color: #64c8ff;
  font-weight: bold;
  font-size: 15px;
}

/* 滚动条 */
.data-table-container::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
.data-table-container::-webkit-scrollbar-thumb {
  background: rgba(100, 200, 255, 0.2);
  border-radius: 2px;
}

/* ========== 移动端设置按钮 ========== */
.mobile-settings-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(100, 200, 255, 0.3);
  background: rgba(20, 20, 35, 0.85);
  color: #64c8ff;
  font-size: 22px;
  cursor: pointer;
  z-index: 30;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s, transform 0.15s;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.mobile-settings-btn:active {
  transform: scale(0.92);
  background: rgba(40, 40, 65, 0.95);
}

/* ========== 右侧操作面板 ========== */
.control-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: rgba(18, 18, 32, 0.95);
  border-left: 1px solid rgba(100, 200, 255, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(100, 200, 255, 0.1);
}

.panel-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #64c8ff;
  letter-spacing: 1px;
}

.close-panel-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #aaa;
  font-size: 16px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.close-panel-btn:active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.panel-content {
  padding: 16px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  flex: 1;
}

/* ========== 控制组 ========== */
.control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #ccc;
}

.control-group label {
  font-size: 13px;
  color: #999;
  white-space: nowrap;
}

/* ========== 按钮通用样式 ========== */
.ctrl-btn {
  flex: 1;
  min-width: 80px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(100, 200, 255, 0.25);
  background: rgba(40, 60, 100, 0.4);
  color: #cce5ff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  text-align: center;
  white-space: nowrap;
}

.ctrl-btn:hover {
  background: rgba(60, 90, 150, 0.55);
  border-color: rgba(100, 200, 255, 0.5);
}

.ctrl-btn:active {
  transform: scale(0.96);
  background: rgba(70, 110, 180, 0.7);
}

.active-btn {
  background: rgba(255, 255, 255, 0.15) !important;
  border-color: #64c8ff !important;
}

.active-mode {
  border-color: #ffaa00 !important;
  box-shadow: 0 0 8px rgba(255, 170, 0, 0.5);
  color: #ffaa00 !important;
}

.reset-btn {
  border-color: rgba(255, 100, 100, 0.35);
  background: rgba(120, 40, 40, 0.4);
  color: #ffcccc;
}

.reset-btn:hover {
  background: rgba(160, 50, 50, 0.55);
  border-color: rgba(255, 120, 120, 0.6);
}

.small-btn {
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(100, 200, 255, 0.25);
  background: rgba(40, 60, 100, 0.4);
  color: #cce5ff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
  padding: 0 12px;
}

.small-btn:hover {
  background: rgba(60, 90, 150, 0.55);
}

.small-btn:active {
  transform: scale(0.9);
  background: rgba(70, 110, 180, 0.7);
}

.color-picker {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(100, 200, 255, 0.25);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.warning-text {
  color: #ff6b6b;
  font-size: 13px;
  text-align: center;
  display: block;
  margin-bottom: 8px;
}

/* ========== 输入控件 ========== */
input[type="range"] {
  flex: 1;
  min-width: 100px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(100, 200, 255, 0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #64c8ff;
  border: 2px solid #1a1a2e;
  cursor: pointer;
}

input[type="number"] {
  width: 70px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(100, 200, 255, 0.2);
  background: rgba(10, 10, 20, 0.6);
  color: #eaeaea;
  font-size: 14px;
  outline: none;
  text-align: center;
}

input[type="number"]:focus {
  border-color: #64c8ff;
}

#speedValue {
  min-width: 32px;
  text-align: center;
  font-weight: 600;
  color: #64c8ff;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

/* ========== 浮层背景 (移动端) ========== */
.panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  z-index: 35;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.panel-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 滚动条美化 */
.panel-content::-webkit-scrollbar {
  width: 5px;
}
.panel-content::-webkit-scrollbar-thumb {
  background: rgba(100, 200, 255, 0.2);
  border-radius: 3px;
}

/* ============================================================
   PC端样式 (屏幕宽度 >= 769px)
   ============================================================ */
@media (min-width: 769px) {
  .mobile-settings-btn {
    display: none !important;
  }

  .control-panel {
    transform: translateX(0) !important;
  }

  .close-panel-btn {
    display: none !important;
  }

  .panel-overlay {
    display: none !important;
  }

  .canvas-container {
    width: calc(100% - 300px);
  }

  #antCanvas {
    left: calc(50% - 150px);
    transform: translate(-50%, -50%);
  }
}

/* ============================================================
   移动端样式 (屏幕宽度 <= 768px)
   ============================================================ */
@media (max-width: 768px) {
  .mobile-settings-btn {
    display: flex;
  }

  .control-panel {
    transform: translateX(100%);
    width: 280px;
    border-left: none;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
  }

  .control-panel.open {
    transform: translateX(0);
  }

  .close-panel-btn {
    display: flex;
  }

  .canvas-container {
    width: 100%;
  }

  #antCanvas {
    left: 50%;
  }

  /* 移动端数据模块位置 */
  .data-module {
    right: 16px;
    top: 68px;
    width: calc(100% - 32px);
    max-width: 300px;
  }

  .panel-content {
    padding: 14px 16px 28px;
    gap: 16px;
  }

  .ctrl-btn {
    padding: 12px 14px;
    font-size: 14px;
  }

  .step-display {
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    font-size: 14px;
  }

  .mobile-settings-btn {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
  
  .mode-hint {
    top: 56px;
    left: 12px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .control-panel {
    width: 260px;
  }
  .ctrl-btn {
    min-width: 60px;
    font-size: 13px;
  }
  .control-group {
    gap: 8px;
  }
}

/* ============================================================
   底部备案信息 (Footer)
   ============================================================ */
.footer {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #667;
  z-index: 15; /* 低于操作面板和数据模块，高于画布 */
  pointer-events: auto;
  background: rgba(15, 15, 26, 0.6);
  padding: 6px 16px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  white-space: nowrap;
}

.footer .dim {
  color: #556;
}

.footer .beian {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer .beian a {
  color: #778;
  text-decoration: none;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer .beian a:hover {
  color: #64c8ff;
}

.beian-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  opacity: 0.8;
}

/* 适配移动端 (避免和悬浮数据面板或按钮重叠) */
@media (max-width: 768px) {
  .footer {
    bottom: 8px;
    padding: 4px 12px;
    font-size: 11px;
    width: 90%;
    text-align: center;
  }
  
  .footer .beian {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* PC 端画布宽度补偿，确保 Footer 在画布可视区居中 */
@media (min-width: 769px) {
  .footer {
    /* 减去右侧 300px 面板宽度后的居中点 */
    left: calc(50% - 150px);
  }
}

/* ============================================================
   左上角控制区 (返回按钮 + 步数)
   ============================================================ */
.top-left-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
}

.home-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(20, 20, 35, 0.85);
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 8px;
  color: #64c8ff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s;
  width: fit-content;
}

.home-btn:hover {
  background: rgba(40, 50, 80, 0.9);
  border-color: rgba(100, 200, 255, 0.6);
}

.home-btn svg {
  opacity: 0.8;
}

/* 覆盖原来的绝对定位，让步数跟随在按钮下方 */
.step-display {
  position: static !important;
  /* 保留原有的背景、边框等样式 */
}

/* 适配移动端 */
@media (max-width: 768px) {
  .top-left-controls {
    top: 12px;
    left: 12px;
    gap: 8px;
  }
  
  .home-btn {
    padding: 6px 12px;
    font-size: 13px;
  }
}