.dropdown {
  position: relative;
}

.dropdown__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.dropdown__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
}

.dropdown__chevron {
  display: flex;
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform 0.15s ease;
}

.dropdown__trigger[aria-expanded="true"] .dropdown__chevron {
  transform: rotate(180deg);
}

.dropdown__trigger--icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: transparent;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.dropdown__trigger--icon:hover {
  color: var(--color-text);
}

.dropdown__trigger--icon svg {
  width: 18px;
  height: 18px;
}

.dropdown__panel {
  position: fixed;
  z-index: 260;
  width: max-content;
  min-width: 220px;
  max-width: 280px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
}

.dropdown__panel[hidden] {
  display: none;
}

.dropdown__handle {
  display: none;
}

.dropdown__backdrop {
  position: fixed;
  inset: 0;
  z-index: 259;
  background-color: rgba(23, 23, 23, 0.5);
}

.dropdown__backdrop[hidden] {
  display: none;
}

@media (max-width: 991px) {
  .dropdown__panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    min-width: 0;
    max-height: 70vh;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: var(--space-sm) var(--space-lg) var(--space-lg);
  }

  .dropdown__handle {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background-color: var(--color-border);
    margin: 0 auto var(--space-sm);
    flex-shrink: 0;
  }

  .dropdown__list {
    max-height: none;
  }
}

.dropdown__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}

.dropdown__item-form {
  display: contents;
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  color: var(--color-text);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.dropdown__item:hover {
  background-color: var(--color-bg);
}

.dropdown__item--current {
  background-color: color-mix(in srgb, var(--color-brand) 8%, transparent);
  font-weight: 600;
}

.dropdown__item--current:hover {
  background-color: color-mix(in srgb, var(--color-brand) 12%, transparent);
}

.dropdown__item--danger {
  color: var(--color-danger-text);
}

.dropdown__item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dropdown__item-sublabel {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.dropdown__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dropdown__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-hover));
  color: #ffffff;
  font-size: 0.625rem;
  font-weight: 700;
}

.dropdown__avatar--sm {
  width: 20px;
  height: 20px;
  font-size: 0.5625rem;
}

.dropdown__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dropdown__icon[hidden] {
  display: none;
}

.dropdown__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.dropdown__icon svg {
  width: 16px;
  height: 16px;
}
