/* ===== SELECT DROPDOWN COMPONENT ===== */

.ri-dropdown {
  position: relative;
  width: 100%;
}

/* Single outer frame - matches glow-input; trigger stays borderless inside */
.ri-dropdown-shell {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  background: var(--bg-elevated, #0f0f23);
  padding: 0 12px;
  position: relative;
  z-index: 0;
  overflow: hidden;
}

.ri-dropdown-shell::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -2;
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(400px circle at var(--gx, 50%) var(--gy, 50%), rgba(var(--glow-rgb), 0.3), transparent 40%);
}

.ri-dropdown-shell::after {
  content: '';
  position: absolute;
  inset: 1px;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background: var(--bg-elevated, #0f0f23);
}

.ri-dropdown-shell:hover::before,
.ri-dropdown-shell:has(.ri-dropdown-trigger.open)::before,
.ri-dropdown-shell:focus-within::before {
  opacity: 1;
}

.ri-dropdown-shell:focus-within {
  border-color: rgba(var(--glow-rgb), 0.4);
  box-shadow: 0 0 0 3px rgba(var(--glow-rgb), 0.08);
}

[data-theme="light"] .ri-dropdown-shell::before,
[data-theme="light"] .ri-dropdown-shell::after {
  display: none;
}

[data-theme="light"] .ri-dropdown-shell:focus-within {
  border-color: var(--border);
  box-shadow: none;
}

[data-theme="light"] .ri-dropdown-shell {
  background: var(--bg-white);
}

/* --- Trigger (match rexuikeyframes .glow-input input: 10px vertical, 13px type) --- */
.ri-dropdown-trigger {
  position: relative;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 10px 0;
  min-height: 0;
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  text-align: left;
  background: transparent;
  border: none;
  outline: none;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  color: var(--text-primary);
}

/* Glow lives on shell - disable trigger layers to avoid double box */
.ri-dropdown-shell .ri-dropdown-trigger::before,
.ri-dropdown-shell .ri-dropdown-trigger::after {
  display: none;
}

.ri-dropdown-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
  transition: transform 0.2s ease;
}

.ri-dropdown-trigger.open .ri-dropdown-chevron {
  transform: rotate(180deg);
}

.ri-dropdown-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-primary);
}

/* --- Menu --- */
.ri-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--bg-dropdown, var(--bg-white));
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  margin-top: 4px;
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  animation: dropdownSlideIn 0.15s ease;
}

.ri-dropdown-search-wrap {
  position: sticky;
  top: -4px;
  z-index: 2;
  margin: -4px -4px 4px -4px;
  padding: 6px 8px 8px 8px;
  background: var(--bg-dropdown, var(--bg-elevated, #0f0f23));
  border-radius: calc(var(--radius-md, 10px) - 2px) calc(var(--radius-md, 10px) - 2px) 0 0;
}

.ri-dropdown-search {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-primary);
  background: var(--bg-elevated, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  outline: none;
}

.ri-dropdown-search::placeholder {
  color: var(--text-muted);
}

.ri-dropdown-search:focus {
  border-color: rgba(var(--glow-rgb), 0.45);
}

[data-theme="light"] .ri-dropdown-search-wrap {
  background: var(--bg-white);
}

[data-theme="light"] .ri-dropdown-search {
  background: var(--bg, #f9fafb);
  color: var(--text-primary);
}

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

.ri-dropdown-menu.open--above {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 4px;
}

/* Portal: under body, fixed coords + stacking from JS */
.ri-dropdown-menu.ri-dropdown-menu--portal {
  position: fixed !important;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  margin: 0 !important;
  width: auto;
  z-index: 30000;
  box-sizing: border-box;
}

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

/* --- Items --- */
.ri-dropdown-item {
  padding: 8px 12px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, padding-left 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ri-dropdown-item:hover {
  padding-left: 18px;
  background: rgba(var(--glow-rgb), 0.1);
  color: var(--primary);
}

.ri-dropdown-item.active {
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-weight: 500;
}

.ri-dropdown-item.disabled-item {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

[data-theme="light"] .ri-dropdown-menu {
  background: var(--bg-white);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .ri-dropdown-item:hover {
  background: var(--primary-bg-dark);
  color: var(--text-primary);
  padding-left: 12px;
}

/* --- Multi-select --- */
.ri-multi-item {
  padding: 8px 12px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ri-multi-item:hover {
  background: var(--primary-bg-dark);
}

.ri-multi-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ri-multi-dot.checked {
  background: var(--primary);
  border-color: var(--primary);
}

.ri-multi-dot.checked::after {
  content: '';
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 1px;
}

/* --- Scrollbar for dropdown --- */
.ri-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .08) transparent;
}

.ri-scroll::-webkit-scrollbar {
  width: 4px;
}

.ri-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 4px;
}

[data-theme="light"] .ri-scroll {
  scrollbar-color: rgba(0, 0, 0, .12) transparent;
}

[data-theme="light"] .ri-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .12);
}
