/**
 * Custom Dropdown Styles
 * Fully styleable dropdown component with dark theme
 * Replaces native <select> OS-rendered popups
 */

/* Container */
.custom-dropdown-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* Trigger (looks like the original select) */
.custom-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: all 0.3s ease;
}

.custom-dropdown-trigger:hover {
  border-color: rgba(255, 255, 255, 0.35) !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15) !important;
}

.custom-dropdown-trigger:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15) !important;
}

/* Trigger text */
.custom-dropdown-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: white;
}

/* Dropdown arrow */
.custom-dropdown-arrow {
  width: 16px;
  height: 16px;
  margin-left: 8px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.6);
  transition: transform 0.2s ease;
}

.custom-dropdown-container.open .custom-dropdown-arrow {
  transform: rotate(180deg);
}

/* Dropdown menu - DARK & OPAQUE */
.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(10, 10, 10, 0.98) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 99999;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  animation: dropdownFadeIn 0.2s ease;
  /* Smooth scrolling */
  scroll-behavior: smooth;
  /* Better touch scrolling on mobile */
  -webkit-overflow-scrolling: touch;
  /* Enable momentum scrolling */
  overscroll-behavior: contain;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dropdown items - COMPACT */
.custom-dropdown-item {
  padding: 8px 16px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  outline: none;
  font-size: 0.85rem;
  background: transparent;
  border-left: 3px solid transparent;
}

.custom-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  color: white !important;
  border-left-color: rgba(255, 255, 255, 0.3);
  padding-left: 18px;
}

.custom-dropdown-item:focus {
  background: rgba(255, 255, 255, 0.12) !important;
  color: white !important;
  border-left-color: rgba(255, 255, 255, 0.3);
}

.custom-dropdown-item.selected {
  background: rgba(255, 255, 255, 0.15) !important;
  color: white !important;
  font-weight: 600;
  border-left-color: rgba(255, 255, 255, 0.8);
  position: relative;
}

.custom-dropdown-item.selected::after {
  content: '✓';
  position: absolute;
  right: 16px;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.9);
}

.custom-dropdown-item.selected:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  border-left-color: white;
}

.custom-dropdown-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Scrollbar styling for dropdown menu */
.custom-dropdown-menu::-webkit-scrollbar {
  width: 8px;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Mobile optimization */
@media (max-width: 768px) {
  .custom-dropdown-menu {
    max-height: 220px;
  }
  
  .custom-dropdown-item {
    padding: 10px 14px;
    font-size: 0.88rem;
  }
  
  .custom-dropdown-item:hover {
    padding-left: 16px;
  }
}

/* Small dropdowns (text-xs) */
.custom-dropdown-trigger.text-xs .custom-dropdown-text {
  font-size: 0.75rem;
}

.custom-dropdown-trigger.text-xs + .custom-dropdown-menu .custom-dropdown-item {
  padding: 6px 14px;
  font-size: 0.78rem;
}

.custom-dropdown-trigger.text-xs + .custom-dropdown-menu .custom-dropdown-item:hover {
  padding-left: 16px;
}

/* Prevent body scroll when dropdown is open */
body:has(.custom-dropdown-container.open) {
  overflow: hidden;
}

/* Ensure dropdown stays on top */
.custom-dropdown-container {
  z-index: 1000;
}

.custom-dropdown-container.open {
  z-index: 999999;
}

/* When inside modal, ensure even higher z-index */
[class*="modal"] .custom-dropdown-container.open,
[id*="modal"] .custom-dropdown-container.open {
  z-index: 9999999;
}

[class*="modal"] .custom-dropdown-menu,
[id*="modal"] .custom-dropdown-menu {
  z-index: 9999999;
}

/* Dark theme enforcement - OPAQUE DARK BACKGROUND */
.custom-dropdown-menu {
  background: rgba(10, 10, 10, 0.98) !important;
}

/* Ensure visibility */
.custom-dropdown-item {
  color: white !important;
}

/* Active state visibility */
.custom-dropdown-item:active {
  background: rgba(255, 255, 255, 0.18) !important;
  transform: scale(0.98);
}
