/* Custom Dropdown Styles */
.custom-dropdown {
  position: relative;
  width: 100%;
  max-width: 200px;
  font-size: 0.85rem;
}

.dropdown-toggle {
  width: 100%;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.25rem 1.5rem 0.25rem 0.75rem;
  text-align: left;
  cursor: pointer;
  transition: border 0.2s, box-shadow 0.2s;
  position: relative;
  font-size: 0.85rem;
  color: #374151;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 移除重复的箭头，使用HTML中的FontAwesome图标 */
.custom-dropdown .dropdown-toggle i {
  margin-left: auto;
  transition: transform 0.2s ease-in-out;
}

/* Styles for mobile dropdowns */
@media (max-width: 768px) {
  .custom-dropdown .dropdown-toggle {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .custom-dropdown .dropdown-menu li {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }
}

.dropdown-toggle.open i {
  transform: rotate(180deg);
}

.dropdown-toggle:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  outline: none;
}

.dropdown-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: 110%;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 2000;
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  min-width: 100%;
  animation: fadeIn 0.2s;
  display: none;
  pointer-events: auto;
}

.dropdown-menu.open {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-menu li {
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  color: #374151;
  background: transparent;
  user-select: none;
}

.dropdown-menu li:hover,
.dropdown-menu li.active {
  background-color: #e0e7ff !important;
  color: #3730a3 !important;
}

/* 深色模式适配 */
html.dark .custom-dropdown {
  background: transparent;
}

html.dark .dropdown-toggle {
  background: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
}

html.dark .dropdown-toggle i {
  color: #818cf8;
}

html.dark .dropdown-menu {
  background: #1f2937;
  border-color: #374151;
  box-shadow: 0 8px 24px rgba(30, 41, 59, 0.25);
}

html.dark .dropdown-menu li {
  color: #f3f4f6;
  background: transparent;
}

html.dark .dropdown-menu li:hover,
html.dark .dropdown-menu li.active {
  background: #312e81;
  color: #a5b4fc;
}

/* 移动端优化 */
@media (max-width: 600px) {

  .custom-dropdown,
  .dropdown-menu {
    max-width: 100vw;
    min-width: 0;
  }

  .dropdown-toggle {
    font-size: 0.8rem !important;
    padding: 0.2rem 1.25rem 0.2rem 0.5rem;
    height: 1.75rem;
  }

  .dropdown-menu li {
    font-size: 0.75rem !important;
    padding: 0.2rem 0.5rem;
  }
}

html.dark .dropdown-menu li.active,
html.dark .dropdown-menu li:hover,
html.dark .dropdown-menu li.active[class*="text-gray"],
html.dark .dropdown-menu li:hover[class*="text-gray"] {
  color: #a5b4fc !important;
  background: #312e81 !important;
  opacity: 1 !important;
  filter: none !important;
}