/* 为带图标的下拉选择框添加样式 */

/* 自定义下拉选择框容器 */
select {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px !important; /* 为下拉箭头留出空间 */
}

/* 自定义下拉选择框选项样式 */
select option {
  padding: 10px;
}

/* 为下拉选择框添加图标支持 */
.select-with-icon {
  position: relative;
  display: inline-block;
  z-index: 100; /* 添加z-index确保正确显示 */
}

/* 图标容器 */
.select-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  pointer-events: none; /* 确保点击事件穿透到select */
  z-index: 11; /* 确保图标显示在select之上 */
}

/* 图标样式 */
.select-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 为带图标的select添加左侧padding */
.select-with-icon select {
  padding-left: 40px !important;
  position: relative;
  z-index: 10; /* 确保select本身有合适的z-index */
}

/* 自定义下拉菜单样式 - 使用原生select作为基础，但通过JavaScript添加图标 */
.has-icon select {
  padding-left: 40px !important;
}

/* 为Firefox浏览器添加特殊样式 */
@-moz-document url-prefix() {
  .select-with-icon select {
    text-indent: 25px;
  }
}

/* 为Chrome和Safari添加特殊样式 */
@media screen and (-webkit-min-device-pixel-ratio:0) {
  .select-with-icon select {
    text-indent: 0;
  }
}

/* 自定义下拉菜单的选项样式 - 这部分需要JavaScript支持 */
.custom-select-dropdown {
  position: fixed; /* 使用fixed定位，避免被其他元素遮挡 */
  background: white;
  border: 2px solid var(--primary-color);
  border-radius: var(--radius);
  z-index: 99999; /* 使用非常高的z-index确保显示在最上层 */
  max-height: 300px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  margin-top: 2px; /* 与select之间留出一点间距 */
  opacity: 1;
  transition: opacity 0.2s ease;
  -webkit-overflow-scrolling: touch; /* 为iOS设备提供平滑滚动 */
}

.custom-select-option {
  padding: 10px 15px 10px 40px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

.custom-select-option:hover {
  background-color: #f5f5f5;
}

.custom-select-option:active {
  background-color: #e8e8e8;
}

.custom-select-option.selected {
  background-color: #f0f0f0;
  font-weight: 500;
}

/* 焦点状态样式 */
.select-with-icon.focused select {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(255, 111, 97, 0.2);
}

.custom-select-option-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
}

.custom-select-option-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 移动端响应式优化 */
@media (max-width: 768px) {
  /* 调整下拉选择框在移动端的显示 */
  .select-with-icon {
    margin-bottom: 0;
  }
  
  .select-with-icon select {
    width: 100%;
    font-size: 13px;
    padding: 6px 25px 6px 30px !important;
    height: 32px;
  }
  
  /* 调整图标大小和位置 */
  .select-icon {
    left: 6px;
    width: 16px;
    height: 16px;
  }
  
  /* 自定义下拉菜单在移动端的样式 */
  .custom-select-dropdown {
    max-height: 200px;
    width: calc(100% - 20px) !important;
    left: 10px !important;
    right: 10px !important;
  }
  
  .custom-select-option {
    padding: 6px 8px 6px 28px;
    font-size: 13px;
  }
  
  .custom-select-option-icon {
    left: 6px;
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 480px) {
  /* 超小屏幕设备的优化 */
  .select-with-icon select {
    font-size: 12px;
    padding: 4px 20px 4px 24px !important;
    height: 28px;
  }
  
  .select-icon {
    width: 14px;
    height: 14px;
    left: 4px;
  }
  
  .custom-select-dropdown {
    max-height: 180px;
    /* 移动端的affiliation的下拉选项框的展开后的选择框的宽度 */
    max-width: 200px;
    margin-right: 10px;
    margin-left: auto
  }
  
  .custom-select-option {
    padding: 5px 6px 5px 24px;
    font-size: 12px;
  }
  
  .custom-select-option-icon {
    width: 14px;
    height: 14px;
    left: 4px;
  }
}