/* ═══════════════════════════════════════════════════════════════════════════
   UI PRIMITIVES
   Consolidated dropdown/control/choice/feedback primitives.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
   COMPOSE — Components v2
   ONE dropdown. ONE modal. ONE tooltip. ONE button system.
   Used everywhere — never duplicated.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ────────────────────────────────────────────────────────────────────────────
   DROPDOWN MENU
   ──────────────────────────────────────────────────────────────────────────── */
.dropdown-trigger-wrapper {
  position: relative;
  display: inline-flex;
}

.dropdown {
  position: absolute;
  z-index: var(--z-overlay);
  min-width: 190px;
  max-width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  
  padding: var(--sp-1) 0;
  top: calc(100% + 8px);
  left: 0;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  transform-origin: top left;
}

.dropdown[data-anchor="bottom-right"] { left: auto; right: 0; transform-origin: top right; }
.dropdown[data-anchor="top-left"]     { top: auto; bottom: calc(100% + 8px); transform-origin: bottom left; }
.dropdown[data-anchor="top-right"]    { top: auto; bottom: calc(100% + 8px); left: auto; right: 0; transform-origin: bottom right; }

.dropdown.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 7px var(--sp-4);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-sec);
  text-align: left;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  white-space: nowrap;
  min-height: 34px;
  letter-spacing: -0.01em;
}
.dropdown-item:active { background: var(--fill-active); }
.dropdown-item.is-active { background: var(--interactive-selected-bg); color: var(--interactive-selected-fg); font-weight: 600; }
.dropdown-item.is-destructive { color: var(--status-error); }
.dropdown-item svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-muted); opacity: 0.7; }
.dropdown-item-shortcut { font-size: 11px; color: var(--text-disabled); margin-left: auto; padding-left: var(--sp-5); font-variant-numeric: tabular-nums; }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-1) 0;
}

.dropdown-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-4) var(--sp-1);
}

/* ────────────────────────────────────────────────────────────────────────────
   SHARED UI PRIMITIVES
   ──────────────────────────────────────────────────────────────────────────── */
.ui-close {
  flex-shrink: 0;
  width: var(--ui-close-size);
  height: var(--ui-close-size);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.ui-close svg { width: var(--ui-icon-md); height: var(--ui-icon-md); }

.ui-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ui-field-wrap { position: relative; }

.ui-field-icon {
  position: absolute;
  left: var(--ui-field-px);
  top: 50%;
  transform: translateY(-50%);
  width: var(--ui-icon-sm);
  height: var(--ui-icon-sm);
  color: var(--text-muted);
  pointer-events: none;
}

.ui-control {
  width: 100%;
  height: var(--ui-control-h);
  padding: 0 var(--ui-field-px);
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  outline: none;
  min-width: 0;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.ui-control:focus { border-color: var(--accent); }
.ui-control::placeholder { color: var(--text-muted); }
.ui-control.settings-hotkeys-search-input {
  height: 40px;
  font-size: 12.25px;
  font-weight: 450;
  font-family: var(--font-ui);
  letter-spacing: -0.01em;
}
.ui-control.settings-hotkeys-search-input::placeholder {
  font-size: 12.25px;
}
.ui-control--with-leading-icon { padding-left: var(--ui-select-pr); }
.ui-control--with-trailing-action { padding-right: var(--ui-select-pr); }

.ui-field-clear {
  position: absolute;
  right: var(--sp-2);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sec);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.ui-field-clear svg { width: 8px; height: 8px; }
.ui-field-clear:hover { background: var(--text-disabled); }

.ui-select-wrap {
  position: relative;
  display: block;
}
.ui-select {
  cursor: pointer;
  padding-right: var(--ui-select-pr);
}
.ui-select-arrow {
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  color: var(--text-muted);
  pointer-events: none;
}

.ui-action-row {
  display: flex;
  gap: var(--ui-action-gap);
}
.ui-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-width: 0;
  height: 32px;
  padding: 0 var(--ui-action-px);
  border-radius: var(--r-md);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-sec);
  background: var(--fill-muted);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ui-action-btn svg { width: 12px; height: 12px; flex-shrink: 0; }
.ui-action-btn--primary {
  background: rgba(var(--accent-rgb), .1);
  color: var(--accent);
}

/* Shared segmented controls / chips */
.ui-choice-group {
  display: flex;
  background: var(--fill-muted);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}

.ui-choice-group--wrap {
  flex-wrap: wrap;
  background: transparent;
  padding: 0;
  gap: 4px;
}

.ui-choice-btn {
  flex: 1;
  min-width: 0;
  height: var(--ui-control-h-sm);
  padding: 0 var(--ui-action-px);
  border-radius: var(--r-md);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.ui-choice-btn svg { width: 12px; height: 12px; flex-shrink: 0; }
.ui-choice-btn.is-active {
  background: var(--interactive-selected-bg);
  color: var(--interactive-selected-fg);
  border-color: var(--interactive-selected-border);
}
.ui-choice-group--wrap .ui-choice-btn {
  flex: 0 0 auto;
  background: var(--fill-muted);
  border-radius: var(--r-md);
}
.ui-choice-group--wrap .ui-choice-btn.is-active {
  background: var(--interactive-selected-bg);
  border-color: var(--interactive-selected-border);
  color: var(--interactive-selected-fg);
  font-weight: 600;
}

.ui-chip-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.ui-chip {
  height: var(--ui-control-h-sm);
  padding: 0 var(--ui-action-px);
  border-radius: var(--sp-item-r);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sec);
  background: var(--fill-muted);
  border: 1.5px solid transparent;
  transition: all var(--t-fast) var(--ease);
  cursor: pointer;
  white-space: nowrap;
}
.ui-chip.is-active {
  background: var(--interactive-selected-bg);
  border-color: var(--interactive-selected-border);
  color: var(--interactive-selected-fg);
  font-weight: 600;
}

.ui-option-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ui-option-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: var(--sp-item-h);
  padding: 0 12px;
  border-radius: var(--sp-item-r);
  font-size: 14px;
  color: var(--text-sec);
  background: transparent;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  text-align: left;
}
.ui-option-btn.is-active {
  background: var(--interactive-selected-bg);
  border-color: var(--interactive-selected-border);
  color: var(--interactive-selected-fg);
}
.ui-option-meta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-ui) !important;
  margin-left: 8px;
  flex-shrink: 0;
}
.ui-option-btn.is-active .ui-option-meta { color: color-mix(in srgb, var(--interactive-selected-fg) 68%, transparent); }

/* ────────────────────────────────────────────────────────────────────────────
   TOAST
   ──────────────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--toolbar-h) + var(--sp-5));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg-card);
  padding: 9px var(--sp-5);
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 500;
  
  white-space: nowrap;
  pointer-events: auto;
  letter-spacing: -0.01em;
  animation: toast-in var(--t) var(--ease) both;
}

.toast.is-leaving { animation: toast-out var(--t-fast) var(--ease) both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(4px); }
}

/* ────────────────────────────────────────────────────────────────────────────
   EMPTY STATE
   ──────────────────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  gap: var(--sp-2);
}

.empty-state-icon { width: 28px; height: 28px; opacity: 0.3; color: var(--text-muted); margin-bottom: var(--sp-1); }
.empty-state-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.empty-state-sub { font-size: 12px; color: var(--text-disabled); max-width: 180px; line-height: 1.6; }

@media (max-width: 767px) {
  .ui-control.settings-hotkeys-search-input {
    height: 38px;
    font-size: 12px;
    font-weight: 450;
  }

  .ui-control.settings-hotkeys-search-input::placeholder {
    font-size: 12px;
  }
}
