
/* ==========================================
   Premium VanillaSelect Custom Styles
   ========================================== */
.vselect {
  position: relative;
  width: 100%;
  font-family: inherit;
}

.vselect-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 6px 36px 6px 12px;
  background-color: var(--wa-panel, #111b21);
  border: 1px solid var(--wa-border, #2a3942);
  border-radius: var(--radius-xl, 12px);
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  position: relative;
}

/* Hover and focus states */
.vselect-control:hover {
  border-color: var(--wa-text-secondary, #8696a0);
}

.vselect.is-open .vselect-control {
  border-color: var(--wa-green, #21C063);
  box-shadow: 0 0 0 3px rgba(33, 192, 99, 0.15);
  background-color: var(--wa-panel, #111b21);
}

/* Caret Icon */
.vselect-control::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-top-color: var(--wa-text-secondary, #8696a0);
  pointer-events: none;
  transition: transform 200ms ease, border-top-color 200ms ease;
}

.vselect.is-open .vselect-control::after {
  transform: translateY(-50%) rotate(180deg);
  border-top-color: var(--wa-green, #25D366);
}

/* Placeholder and Selected Values */
.vselect-placeholder {
  color: var(--wa-text-secondary, #8696a0);
  font-size: 13.5px;
  font-weight: 500;
  user-select: none;
}

.vselect-value {
  color: var(--wa-text-primary, #e9edef);
  font-size: 13.5px;
  font-weight: 500;
}

/* Clear Button */
.vselect-clear {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  color: var(--wa-text-secondary, #8696a0);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  transition: all 150ms ease;
  line-height: 1;
  padding: 0;
  z-index: 2;
}

.vselect-clear:hover {
  background-color: var(--wa-surface, #202c33);
  color: var(--wa-text-primary, #e9edef);
}

/* Dropdown Container */
.vselect-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: min(90vw, 550px);
  z-index: 99999;
  background-color: var(--wa-surface, #202c33);
  border: 1px solid var(--wa-border, #2a3942);
  border-radius: var(--radius-2xl, 14px);
  box-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.6), 0 8px 12px -6px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 320px;
  padding: 6px;
  animation: vselect-fade-in 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

.vselect.is-open .vselect-dropdown {
  display: flex;
}

@keyframes vselect-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dropdown Search Input */
.vselect-input {
  width: calc(100% - 12px);
  margin: 6px;
  padding: 8px 12px;
  background-color: var(--wa-panel, #111b21);
  border: 1px solid var(--wa-border, #2a3942);
  border-radius: var(--radius-lg, 8px);
  outline: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--wa-text-primary, #e9edef);
  transition: all 150ms ease;
}

.vselect-input:focus {
  background-color: var(--wa-panel, #111b21);
  border-color: var(--wa-green, #21C063);
  box-shadow: 0 0 0 2px rgba(33, 192, 99, 0.1);
}

/* Option List Styling with Clean Borders */
.vselect-option {
  padding: 9px 14px;
  border-radius: var(--radius-lg, 8px);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--wa-text-primary, #e9edef);
  transition: all 150ms ease;
  margin: 3px 0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background-color: rgba(255, 255, 255, 0.02);
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

/* Highlighted / Hover option */
.vselect-option:hover,
.vselect-option.is-active {
  background-color: var(--wa-panel, #111b21);
  border-color: rgba(33, 192, 99, 0.4);
  color: var(--wa-text-primary, #e9edef);
}

/* Selected option */
.vselect-option[aria-selected="true"] {
  background-color: var(--wa-dark-green, #128C7E);
  border-color: var(--wa-green, #25D366);
  color: #ffffff;
  font-weight: 600;
}

/* Disabled option */
.vselect-option[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: transparent;
}

/* No Results Label */
.vselect-no-results {
  padding: 16px;
  text-align: center;
  color: var(--wa-text-secondary, #8696a0);
  font-size: 13px;
  font-weight: 500;
}

/* Multiple Selection Tags (Chips) */
.vselect-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--wa-surface, #202c33);
  border: 1px solid var(--wa-border, #2a3942);
  border-radius: var(--radius-lg, 8px);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--wa-text-primary, #e9edef);
  transition: all 150ms ease;
}

.vselect-tag button {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  color: var(--wa-text-secondary, #8696a0);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 14px;
  width: 14px;
  border-radius: 50%;
  padding: 0;
  transition: all 150ms ease;
}

.vselect-tag button:hover {
  background-color: var(--wa-panel, #111b21);
  color: var(--wa-danger, #f15c6d);
}

/* Scrollbar styling for dropdown */
.vselect-dropdown::-webkit-scrollbar {
  width: 6px;
}

.vselect-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.vselect-dropdown::-webkit-scrollbar-thumb {
  background-color: var(--wa-border, #2a3942);
  border-radius: 3px;
}

.vselect-dropdown::-webkit-scrollbar-thumb:hover {
  background-color: var(--wa-text-secondary, #8696a0);
}

/* Custom fix for double caret inside list filters container */
.relative:has(.vselect) > .pointer-events-none {
  display: none !important;
}

/* Actions select custom alignment and sizing */
.actions .vselect {
  min-width: 240px;
  width: auto;
  display: inline-block;
  vertical-align: middle;
  margin: 0 10px;
}

/* Top filters container custom layout to ensure multi-column row alignment */
#wa-top-filters-container .vselect {
  min-width: 160px;
  width: auto;
  flex: 0 1 auto;
}

/* Forcefully hide view and delete icons next to ForeignKey/select widgets */
.related-widget-wrapper-link.view-related,
.related-widget-wrapper-link.delete-related {
  display: none !important;
}

/* Prevent clipping of dropdown menus in admin card containers, table headers, actions and fieldsets */
.inline-group[data-inline-type="stacked"],
fieldset.module,
.module,
.form-row,
.bg-white.border.border-gray-200.rounded-xl,
.actions,
.bg-wa-panel:has(.vselect.is-open) {
  overflow: visible !important;
}

/* Ensure open dropdowns are stacked on top of subsequent form rows */
.vselect.is-open {
  z-index: 99999 !important;
}

.form-row:has(.vselect.is-open),
.actions:has(.vselect.is-open) {
  z-index: 99999 !important;
  position: relative !important;
}
