/**
 * 语言设置样式
 */

/* 语言图标 */
.ios-icon-language {
  background-color: #5856d6;
}

/* 语言设置值 */
.ios-settings-value {
  font-size: 0.9rem;
  color: var(--bs-secondary-color);
  margin-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

/* 深色模式适配 */
.dark-mode .ios-settings-value {
  color: var(--bs-secondary-color);
}

/* 语言选项容器 */
.language-options-container {
  max-height: 400px;
  overflow-y: auto;
  border-radius: 8px;
  background-color: transparent;
  margin: 0;
  -webkit-overflow-scrolling: touch; /* 提供iOS流畅滚动 */
  overscroll-behavior: contain; /* 防止滚动传播 */
  touch-action: pan-y; /* 允许垂直滑动 */
  position: relative;
  transform: translateZ(0); /* 启用GPU加速 */
  -webkit-transform: translateZ(0);
  will-change: scroll-position; /* 提示浏览器滚动位置将会变化，优化性能 */
  backface-visibility: hidden; /* 减少渲染问题 */
  -webkit-backface-visibility: hidden;
}

/* 语言选项 */
.language-option {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

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

.language-option:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.language-option.selected {
  background-color: rgba(0, 0, 0, 0.03);
}

/* 语言信息 - 使用iOS设置样式 */
.language-name {
  margin: 0;
}

.language-english-name {
  margin: 2px 0 0 0;
}

/* 选中图标 */
.language-option .bi-check-lg {
  color: #007aff;
  font-size: 1.2rem;
}

/* 深色模式适配 */
.dark-mode .language-options-container {
  background-color: transparent;
}

.dark-mode .language-option:hover,
.dark-mode .language-option.selected {
  background-color: rgba(255, 255, 255, 0.03);
}

.dark-mode .language-option .bi-check-lg {
  color: #0a84ff;
}

/* RTL语言支持 */
[dir="rtl"] .language-option {
  flex-direction: row-reverse;
}

[dir="rtl"] .ios-settings-arrow {
  transform: scaleX(-1);
}

/* 移动设备适配 */
@media (max-width: 576px) {
  .language-options-container {
    max-height: 50vh; /* 使用视口高度的50%，确保在小屏幕上也有足够空间 */
    overflow-y: auto !important; /* 使用auto而不是scroll，只在需要时显示滚动条 */
    -webkit-overflow-scrolling: touch !important; /* 提供iOS流畅滚动 */
    overscroll-behavior: contain !important; /* 防止滚动传播 */
    touch-action: pan-y !important; /* 允许垂直滑动 */
    transform: translateZ(0) !important; /* 启用GPU加速 */
    -webkit-transform: translateZ(0) !important;
    will-change: scroll-position !important; /* 提示浏览器滚动位置将会变化，优化性能 */
    backface-visibility: hidden !important; /* 减少渲染问题 */
    -webkit-backface-visibility: hidden !important;
    pointer-events: auto !important; /* 确保可以接收触摸事件 */
    position: relative !important;
    z-index: 10 !important; /* 确保在其他元素之上 */
  }

  /* 自定义滚动条样式 */
  .language-options-container::-webkit-scrollbar {
    width: 4px !important;
  }

  .language-options-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color, #007aff) !important;
    border-radius: 4px !important;
  }

  .language-options-container::-webkit-scrollbar-track {
    background: transparent !important;
  }

  /* 语言选项样式 */
  .language-option {
    padding: 12px 16px;
    margin-bottom: 2px; /* 添加间距，使选项更容易点击 */
    border-radius: 8px; /* 圆角边框 */
    position: relative; /* 确保定位正确 */
    z-index: 5; /* 确保在容器内可点击 */
    pointer-events: auto !important; /* 强制启用点击事件 */
    cursor: pointer !important; /* 确保显示为可点击状态 */
  }

  /* 语言选项文本样式 */
  .language-name {
    font-size: 0.95rem;
    pointer-events: none; /* 防止文本干扰点击 */
  }

  .language-english-name {
    font-size: 0.8rem;
    pointer-events: none; /* 防止文本干扰点击 */
  }

  /* 确保模态框内容区域可滚动 */
  #language-settings-modal .modal-body {
    overflow-y: auto !important;
    max-height: 70vh !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* 平板设备适配 */
@media (min-width: 577px) and (max-width: 768px) {
  .language-options-container {
    max-height: 350px;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
  }

  /* 自定义滚动条样式 */
  .language-options-container::-webkit-scrollbar {
    width: 4px !important;
  }

  .language-options-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color, #007aff) !important;
    border-radius: 4px !important;
  }

  .language-options-container::-webkit-scrollbar-track {
    background: transparent !important;
  }
}

/* 语言设置模态框 */
#language-settings-modal .modal-content {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

#language-settings-modal .modal-header {
  border-bottom: none;
  padding: 15px 20px;
}

#language-settings-modal .modal-title {
  font-weight: 600;
  font-size: 1.1rem;
}

#language-settings-modal .modal-body {
  padding: 0 20px 20px;
}

#language-settings-modal .modal-footer {
  border-top: none;
  padding: 0 20px 20px;
  justify-content: space-between;
}

#language-settings-modal .btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  border-radius: 8px;
  font-weight: 500;
  padding: 8px 20px;
}

#language-settings-modal .btn-secondary {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-color);
  border: none;
  border-radius: 8px;
  font-weight: 500;
  padding: 8px 20px;
}

#language-settings-modal .btn-secondary:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

.dark-mode #language-settings-modal .btn-secondary {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
}

.dark-mode #language-settings-modal .btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

/* 语言选项基础样式 */
.language-option {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent; /* 禁用默认的触摸高亮效果 */
  user-select: none; /* 防止文本被选中 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* 移动设备上的触摸反馈效果 */
@media (max-width: 768px) {
  .language-option {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important; /* 禁用默认的蓝色触摸高亮 */
  }

  .language-option:active {
    background-color: rgba(0, 0, 0, 0.05) !important; /* 使用轻微的灰色背景作为触摸反馈 */
  }

  /* 深色模式下的触摸反馈 */
  .dark-mode .language-option:active {
    background-color: rgba(255, 255, 255, 0.05) !important;
  }
}

/* 无障碍支持 */
.language-option:focus {
  outline: 2px solid #007aff;
  outline-offset: -2px;
}

.language-option:focus:not(:focus-visible) {
  outline: none;
}

.language-option:focus-visible::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px solid #007aff;
  border-radius: 4px;
  pointer-events: none;
}
