/* Custom dropdown (public/js/ui/dropdown.js). The trigger matches .input, the menu matches .popover. */

.dd {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--text);
  font: 400 14px/1.4 var(--font), var(--emoji);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

:root[data-theme='light'] .dd {
  background-color: var(--panel);
}

.dd:hover {
  border-color: var(--line-3);
}

.dd:focus,
.dd.open {
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.dd:disabled {
  opacity: 0.55;
  cursor: default;
  border-color: var(--line-2);
  box-shadow: none;
}

.dd.small {
  width: auto;
  min-height: 28px;
  gap: 6px;
  padding: 3px 8px;
  font-size: 12.5px;
}

.dd-value {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.dd-label,
.dd-sizer {
  grid-area: 1 / 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dd-sizer {
  display: grid;
  visibility: hidden;
}

.dd-sizer > span {
  grid-area: 1 / 1;
}

.dd-placeholder {
  color: var(--faint);
}

.dd-lead {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.dd-caret {
  flex: none;
  color: var(--muted);
  font-size: 10px;
  transition: transform 0.18s var(--ease), color 0.15s;
}

.dd.small .dd-caret {
  font-size: 9px;
}

.dd:hover .dd-caret,
.dd.open .dd-caret {
  color: var(--text-2);
}

.dd.open .dd-caret {
  transform: rotate(180deg);
}

.dd-tile {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

/* Menu */

.dd-menu {
  position: fixed;
  z-index: 280;
  display: flex;
  flex-direction: column;
  max-width: calc(100vw - 16px);
  border-radius: 10px;
  background: var(--elev);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top center;
  transition: opacity 0.12s, transform 0.16s var(--ease);
}

.dd-menu.up {
  transform: translateY(4px) scale(0.98);
  transform-origin: bottom center;
}

.dd-menu.open {
  opacity: 1;
  transform: none;
}

.dd-search {
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  transition: color 0.15s;
}

.dd-search:focus-within {
  color: var(--accent-text);
}

.dd-input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 400 13.5px/1.3 var(--font), var(--emoji);
  outline: none;
}

.dd-input::placeholder {
  color: var(--faint);
}

.dd-list {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  outline: none;
}

.dd-item {
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  padding: 5px 9px;
  border-radius: 6px;
  color: var(--text);
  font: 500 13.5px/1.3 var(--font), var(--emoji);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.dd-item.active {
  background: var(--panel-3);
}

.dd-item.selected,
.dd-item.selected > .dd-lead {
  color: var(--accent-text);
}

.dd-item.disabled {
  opacity: 0.45;
  cursor: default;
}

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

.dd-hint {
  flex: none;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
}

.dd-check {
  flex: none;
  margin-left: 2px;
  font-size: 11px;
}

.dd-group {
  flex: none;
  padding: 8px 9px 3px;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 500;
}

.dd-group:first-child {
  padding-top: 3px;
}

.dd-empty {
  padding: 12px 9px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

@media (pointer: coarse) {
  .dd-item {
    min-height: 40px;
  }

  .dd-input {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dd-menu,
  .dd-caret {
    transition-duration: 0.01s !important;
  }
}
