/*
 * 地图源选择窗口移动设备修复
 * 这个文件包含专门针对移动设备上地图源选择窗口的修复样式
 */

/* 确保模态框在最顶层 */
.map-source-modal {
  z-index: 99999 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
}

.map-source-modal.show {
  display: flex !important;
}

/* 确保内容区域在最顶层 */
.map-source-content {
  z-index: 100000 !important;
  background-color: white !important;
  border-radius: 16px !important;
  width: 90% !important;
  max-width: 480px !important;
  padding: 16px !important;
  position: relative !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
  overflow-y: hidden !important; /* 内容区域不滚动 */
  max-height: 80vh !important;
  display: flex !important;
  flex-direction: column !important;
}

/* 确保头部布局正确 */
.map-source-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 16px !important;
  padding-bottom: 12px !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
  width: 100% !important;
  flex-shrink: 0 !important;
}

/* 确保标题可见 */
.map-source-title {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 18px !important;
  font-weight: bold !important;
  color: #333 !important;
}

/* 确保关闭按钮可点击 */
.map-source-close {
  pointer-events: auto !important;
  touch-action: manipulation !important;
  z-index: 100001 !important;
  background: transparent !important;
  border: none !important;
  font-size: 24px !important;
  cursor: pointer !important;
  padding: 0 !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #666 !important;
  transition: color 0.2s !important;
}

.map-source-close:hover,
.map-source-close:active {
  color: #000 !important;
}

/* 创建一个新的滚动容器 */
.map-source-scroll-wrapper {
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch !important;
  max-height: 60vh !important;
  width: 100% !important;
  touch-action: pan-y !important;
  pointer-events: auto !important;
  padding-right: 4px !important; /* 为滚动条留出空间 */
  position: relative !important;
  z-index: 100000 !important;
  flex-grow: 1 !important;
  margin-top: 0 !important; /* 移除顶部边距 */
}

/* 自定义滚动条样式 */
.map-source-scroll-wrapper::-webkit-scrollbar {
  width: 4px !important;
}

.map-source-scroll-wrapper::-webkit-scrollbar-thumb {
  background-color: #ff69b4 !important;
  border-radius: 4px !important;
}

.map-source-scroll-wrapper::-webkit-scrollbar-track {
  background: transparent !important;
}

/* 确保网格可以接收触摸事件 */
.map-source-grid {
  pointer-events: auto !important;
  touch-action: pan-y !important;
  margin-bottom: 20px !important;
  display: grid !important;
  gap: 10px !important;
}

/* 确保选项可点击 */
.map-source-option {
  pointer-events: auto !important;
  touch-action: manipulation !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  transition: transform 0.2s, box-shadow 0.2s !important;
  border-radius: 10px !important;
  overflow: hidden !important;
}

.map-source-option:active {
  transform: scale(0.98) !important;
}

/* 确保分类标题可见 */
.map-source-category {
  font-weight: bold !important;
  margin-top: 16px !important;
  margin-bottom: 12px !important;
  padding-left: 4px !important;
  color: #ff69b4 !important;
  font-size: 16px !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.map-source-category i {
  font-size: 18px !important;
  color: #ff69b4 !important;
}

/* 移动设备特定样式 */
@media (max-width: 768px) {
  /* 内容区域样式 */
  .map-source-content {
    width: 92% !important;
    padding: 20px !important;
    border-radius: 20px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25) !important;
  }

  /* 标题样式 */
  .map-source-header {
    padding-bottom: 15px !important;
    margin-bottom: 15px !important;
  }

  .map-source-title {
    font-size: 20px !important;
    font-weight: 600 !important;
  }

  /* 关闭按钮样式 */
  .map-source-close {
    width: 36px !important;
    height: 36px !important;
    font-size: 26px !important;
    color: #555 !important;
  }

  /* 网格布局 */
  .map-source-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)) !important;
    gap: 12px !important;
  }

  /* 选项样式 */
  .map-source-option {
    padding: 12px 8px !important;
    border-radius: 12px !important;
    background-color: #f8f9fa !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease-in-out !important;
  }

  .map-source-option:active {
    transform: scale(0.95) !important;
    background-color: #e9ecef !important;
  }

  .map-source-option.active {
    background-color: #ffeef5 !important;
    border: 1.5px solid #ff69b4 !important;
    box-shadow: 0 2px 10px rgba(255, 105, 180, 0.15) !important;
  }

  /* 图标样式 */
  .map-source-icon {
    font-size: 22px !important;
    margin-bottom: 8px !important;
    color: #555 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 32px !important;
  }

  .map-source-option.active .map-source-icon {
    color: #ff69b4 !important;
  }

  /* 名称样式 */
  .map-source-name {
    font-size: 12px !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    width: 100% !important;
    color: #333 !important;
    font-weight: 500 !important;
  }

  .map-source-option.active .map-source-name {
    color: #ff69b4 !important;
  }

  /* 分类标题样式 */
  .map-source-category {
    font-size: 16px !important;
    font-weight: 600 !important;
    margin-top: 20px !important;
    margin-bottom: 12px !important;
    color: #333 !important;
    padding-left: 6px !important;
    border-left: 3px solid #ff69b4 !important;
  }

  .map-source-category i {
    color: #ff69b4 !important;
  }

  /* 确保模态框在移动设备上全屏显示 */
  .map-source-modal.show {
    align-items: center !important;
  }

  /* 滚动容器样式 */
  .map-source-scroll-wrapper {
    padding: 0 4px !important;
    max-height: 65vh !important;
  }

  /* 添加一些视觉提示，表明内容可以滚动 */
  .map-source-scroll-wrapper::after {
    content: "" !important;
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 30px !important;
    background: linear-gradient(to top, white, transparent) !important;
    pointer-events: none !important;
  }

  /* 添加顶部渐变，表明可以向上滚动 */
  .map-source-scroll-wrapper::before {
    content: "" !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 15px !important;
    background: linear-gradient(to bottom, white, transparent) !important;
    pointer-events: none !important;
    z-index: 1 !important;
    opacity: 0 !important;
    transition: opacity 0.3s !important;
  }

  /* 当滚动位置不在顶部时显示顶部渐变 */
  .map-source-scroll-wrapper.scrolled::before {
    opacity: 1 !important;
  }
}
