/* GEO 波形查看器样式 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica,
    Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei',
    sans-serif;
  background-color: #ffffff;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* 全局容器 */
.android-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 动态视口高度，适配移动端地址栏 */
  width: 100vw;
  background-color: #ffffff;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent; /* 移除点击高亮 */
}

/* 1. 顶部菜单栏 */
.menu-bar {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  height: 44px; /* 移动端推荐最小触摸尺寸 44px */
  min-height: 44px;
  background-color: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.menu-item {
  font-size: 15px;
  color: #333333;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation; /* 优化触摸响应 */
  transition: background-color 0.2s;
  white-space: nowrap;
}

.menu-item:active {
  background-color: #d0d0d0;
  transform: scale(0.95);
}

/* 文件输入隐藏 */
#fileInput {
  display: none;
}

/* 2. 信息显示栏 */
.info-bar {
  padding: 8px 10px;
  background-color: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.info-row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.channel-info {
  flex: 1.2;
  min-width: 0; /* 允许 flex 子项缩小 */
}

.info-group {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.info-cell {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-bottom: 0;
  white-space: nowrap;
}

.label {
  font-size: 13px;
  color: #3d7eff;
  margin-right: 4px;
  flex-shrink: 0;
}

.value {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 颜色高亮类 */
.highlight-blue {
  color: #3d7eff;
}

.highlight-red {
  color: #ff0000;
}

.highlight-purple {
  color: #a020f0;
}

/* 3. 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  position: relative;
}

/* 左侧图表区域 */
.chart-area {
  flex: 1;
  height: 100%;
  position: relative;
}

.canvas-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

#waveCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.no-data-hint {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #999999;
  font-size: 16px;
}


.channel-btn:hover {
  opacity: 0.9;
}

/* 4. 底部控制栏 */
.footer-bar {
  height: 48px; /* 移动端推荐最小触摸尺寸 48px */
  min-height: 48px;
  background-color: #f8f8f8;
  border-top: 1px solid #e0e0e0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  flex-shrink: 0;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.status-text {
  font-size: 13px;
  color: #666666;
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0 10px;
}

.nav-btn {
  width: 44px; /* 最小触摸尺寸 */
  height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  border-radius: 8px;
  transition: background-color 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:active {
  background-color: rgba(61, 126, 255, 0.15);
  transform: scale(0.9);
}

.nav-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* 显示菜单覆盖层 */
.menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.menu-backdrop:not(.hidden) {
  opacity: 1;
}

/* 菜单主体 */
.display-menu {
  position: fixed;
  top: 44px;
  left: 10px;
  right: 10px;
  min-width: unset;
  max-width: 200px;
  background: #fff;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  overflow: hidden;
  transform-origin: top left;
  animation: menuSlideIn 0.2s ease;
}

@keyframes menuSlideIn {
  from {
    opacity: 0;
    transform: scaleY(0.9);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

.display-option {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  text-align: center;
  font-size: 15px;
  color: #333;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background-color 0.15s;
}

.display-option:last-child {
  border-bottom: none;
}

.display-option:hover {
  background-color: #f8f8f8;
}

.display-option:active {
  background-color: #e8e8e8;
}

/* Modal Styles */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  -webkit-tap-highlight-color: transparent;
}

.modal-content {
  width: 90%;
  max-width: 340px;
  background-color: #fff;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 80vh;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: modalFadeIn 0.25s ease;
}

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

.modal-header {
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 600;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
  background: linear-gradient(to bottom, #fafafa, #fff);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 15px 20px;
  max-height: 60vh;
  -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
}

.checkbox-item {
  padding: 14px 0;
  border-bottom: 1px solid #f5f5f5;
  display: flex;
  align-items: center;
  touch-action: manipulation;
}

.checkbox-item:last-child {
  border-bottom: none;
}

.checkbox-item input[type="checkbox"] {
  margin-right: 12px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #3d7eff;
  -webkit-appearance: none;
  appearance: none;
  border: 2px solid #ccc;
  border-radius: 4px;
  position: relative;
  flex-shrink: 0;
}

.checkbox-item input[type="checkbox"]:checked {
  background-color: #3d7eff;
  border-color: #3d7eff;
}

.checkbox-item input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 14px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.checkbox-label {
  font-size: 16px;
  color: #333;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  flex: 1;
}

.modal-footer {
  display: flex;
  border-top: 1px solid #f0f0f0;
}

.modal-btn {
  flex: 1;
  padding: 16px 0;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: #3d7eff;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background-color 0.15s;
}

.modal-btn:hover {
  background-color: #f8f8f8;
}

.modal-btn:active {
  background-color: #f0f0f0;
}

.modal-btn.cancel {
  color: #666;
  border-right: 1px solid #f0f0f0;
}

/* 隐藏类 */
.hidden {
  display: none !important;
}

/* 加载提示 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30000;
}

.loading-content {
  background: white;
  padding: 20px 40px;
  border-radius: 8px;
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3d7eff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

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

  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 14px;
  color: #666;
}

/* 模态框输入框样式 */
.modal-input {
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.modal-input:focus {
  border-color: #3d7eff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(61, 126, 255, 0.15);
}

/* 结果表格样式 */
.result-table {
  width: 100%;
  border-collapse: collapse;
}

.result-table tr {
  border-bottom: 1px solid #f5f5f5;
}

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

.result-table td {
  padding: 14px 16px;
  font-size: 15px;
  color: #333;
}

.result-table .result-label {
  color: #666;
  text-align: left;
  font-weight: 400;
}

.result-table .result-value {
  text-align: right;
  font-weight: 600;
  color: #333;
}

.result-highlight {
  background-color: #f0f8ff;
  color: #3d7eff;
  font-weight: 600;
}

.result-highlight .result-value {
  color: #3d7eff;
}

/* ================= 媒体查询 - 响应式适配 ================= */

/* 小屏手机 (宽度 < 375px) */
@media screen and (max-width: 374px) {
  .menu-bar {
    height: 40px;
    min-height: 40px;
  }

  .menu-item {
    font-size: 13px;
    padding: 6px 8px;
  }

  .info-bar {
    padding: 6px 8px;
  }

  .label {
    font-size: 12px;
  }

  .value {
    font-size: 13px;
  }

  .footer-bar {
    height: 44px;
    min-height: 44px;
    padding: 0 10px;
  }

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

  .nav-btn {
    width: 40px;
    height: 40px;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
  }
}

/* 平板横屏和大屏手机 */
@media screen and (min-width: 768px) {
  .menu-bar {
    height: 48px;
  }

  .menu-item {
    font-size: 16px;
    padding: 10px 16px;
  }

  .info-bar {
    padding: 10px 20px;
  }

  .label {
    font-size: 14px;
  }

  .value {
    font-size: 15px;
  }

  .footer-bar {
    height: 52px;
    padding: 0 30px;
  }

  .status-text {
    font-size: 14px;
  }

  .nav-btn {
    width: 48px;
    height: 48px;
  }

  .display-menu {
    left: auto;
    right: calc(50% - 200px);
    min-width: 180px;
  }
}

/* 横屏模式优化 */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .menu-bar {
    height: 36px;
    min-height: 36px;
  }

  .menu-item {
    font-size: 13px;
    padding: 4px 8px;
  }

  .info-bar {
    padding: 4px 10px;
  }

  .info-row {
    gap: 5px;
  }

  .label {
    font-size: 11px;
    margin-right: 3px;
  }

  .value {
    font-size: 12px;
  }

  .footer-bar {
    height: 40px;
    min-height: 40px;
  }

  .modal-body {
    max-height: 50vh;
  }
}

/* ================= 触摸交互优化 ================= */

/* 禁止长按选中 */
* {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 输入框允许选中 */
input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* Canvas 触摸行为 */
#waveCanvas {
  touch-action: none; /* 禁止默认触摸行为，完全由 JS 控制 */
}

/* 按钮点击反馈优化 */
.menu-item,
.nav-btn,
.display-option,
.modal-btn,
.checkbox-item {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

/* 添加按下效果类 (JS 可控制) */
.pressed {
  transform: scale(0.95);
  opacity: 0.8;
}

/* 滚动条美化 (Webkit 浏览器) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 加载动画优化 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30000;
}

.loading-content {
  background: white;
  padding: 24px 40px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3d7eff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 14px;
  color: #666;
}

/* 无数据提示优化 */
.no-data-hint {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #999999;
  font-size: 15px;
  text-align: center;
  padding: 20px;
  pointer-events: none; /* 让点击事件穿透到 canvas */
}

/* 主内容区优化 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* 图表区域优化 */
.chart-area {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.canvas-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#waveCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* ================= 新增移动端优化样式 ================= */

/* 小模态框 */
.modal-content-small {
  max-height: unset;
  width: 90%;
  max-width: 320px;
}

/* 模态框标签 */
.modal-label {
  display: block;
  font-size: 15px;
  color: #555;
  margin-bottom: 8px;
  font-weight: 500;
}

/* 里程输入行 */
.mileage-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.mileage-prefix,
.mileage-separator {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.mileage-input-row .modal-input {
  width: 80px;
  text-align: center;
}

/* 输入提示 */
.input-hint {
  margin-top: 8px;
  font-size: 13px;
  color: #888;
  line-height: 1.4;
}

/* 结果模态框 */
#resultModal .modal-content {
  max-height: 80vh;
  width: 90%;
  max-width: 360px;
}

#resultModal .modal-body {
  padding: 0;
}

/* 通道设置模态框 */
#channelSettingModal .modal-body {
  padding: 10px 20px;
}

/* 菜单位置调整 - 定位菜单 */
#locationMenu {
  left: auto;
  right: 10px;
}

/* 菜单位置调整 - 测量菜单 */
#measureMenu {
  left: 10px;
  right: auto;
}

/* 适配 iPhone 底部安全区 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer-bar {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .menu-bar {
    padding-top: env(safe-area-inset-top);
  }
}