/* Global search popover (Asana-style command palette) */

.admin-header__search {
  position: relative;
}

.admin-header__search.is-open .input {
  background: var(--color-surface-elevated);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 35%, transparent);
}

.global-search-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 80;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.global-search-panel[hidden] {
  display: none;
}

/* Entrance lives on __surface: opacity + a small lift + a *uniform*
   scale, so no single axis is stretched and the text never distorts.
   It restarts on every open because the panel goes display:none → block. */
.global-search-panel__surface {
  display: flex;
  flex-direction: column;
  max-height: min(72vh, 520px);
  overflow: hidden;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  transform-origin: top center;
  animation: global-search-open 190ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes global-search-open {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.global-search-panel__motion {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.global-search-panel__chips {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-2);
  /* Never let the scrolling body squeeze the chips row: the scroll
     container below drops this row's flex min-size to 0, so without
     flex-shrink:0 it collapses ~10px (clipping the pills) when the
     results list overflows the panel. */
  flex-shrink: 0;
  /* Chips that don't fit horizontally scroll instead of being clipped. */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.global-search-panel__chips::-webkit-scrollbar {
  display: none;
}

/* "Preguntar a IA" sits apart from the type filters. */
.global-search-panel__chips .global-search-chip--ai {
  margin-left: auto;
}

.global-search-panel__chips .global-search-chip--ai [data-lucide],
.global-search-panel__chips .global-search-chip--ai svg {
  color: var(--color-accent);
}

.global-search-panel__chips .filter-pill {
  box-sizing: border-box;
  flex-shrink: 0;
  height: 34px;
  padding: 0 var(--space-4);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.global-search-panel__chips .filter-pill [data-lucide],
.global-search-panel__chips .filter-pill svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* No ring on pointer focus, but keyboard focus must stay visible. */
.global-search-panel__chips .filter-pill:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

.global-search-panel__chips .filter-pill:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.global-search-panel__chips .filter-pill--active,
.global-search-panel__chips .filter-pill--neutral.filter-pill--active {
  height: 34px;
  padding: 0 var(--space-4);
  font-weight: var(--font-weight-medium);
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.global-search-scope {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-accent);
  background: var(--color-accent-muted);
  color: var(--color-text);
  flex-shrink: 0;
}

.global-search-scope__label {
  white-space: nowrap;
}

.global-search-scope__dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.global-search-scope__dismiss:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.global-search-scope__dismiss [data-lucide],
.global-search-scope__dismiss svg {
  width: 14px;
  height: 14px;
}

.global-search-panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-2) 0 var(--space-3);
  /* Content swaps animate opacity + translate only, never height. */
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  color-scheme: inherit;
  /* Scrollbar styling is global (base.css) — nothing to override here. */
}

/* Held on the body only while its old content fades out; dropping the
   class replays the same transition to fade the new content in.
   Negative Y so the new content settles downward into place, matching
   the panel's own top-to-bottom entrance. */
.global-search-panel__body.is-swapping {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  will-change: opacity, transform;
}

@media (prefers-reduced-motion: reduce) {
  .global-search-panel__surface {
    animation: none;
  }

  .global-search-panel__body {
    transition: none;
  }

  .global-search-panel__body.is-swapping {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

.global-search-section-label {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  text-transform: none;
}

.global-search-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.global-search-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: none;
  background: transparent;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.global-search-item:hover,
.global-search-item.is-active {
  background: var(--color-surface-hover);
}

.global-search-item__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface-hover);
  color: var(--color-text-secondary);
}

.global-search-item__icon [data-lucide],
.global-search-item__icon svg {
  width: 16px;
  height: 16px;
}

.global-search-item__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.global-search-item__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.global-search-item__subtitle {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Query match: no highlighter bar — just weight + full-strength colour. */
.global-search-item__mark {
  background: transparent;
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
}

.global-search-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.global-search-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: global-search-spin 0.7s linear infinite;
}

@keyframes global-search-spin {
  to {
    transform: rotate(360deg);
  }
}

.global-search-empty,
.global-search-ai-stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
}

.global-search-empty__title,
.global-search-ai-stub__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

.global-search-empty__text,
.global-search-ai-stub__text {
  font-size: var(--font-size-xs);
  max-width: 280px;
}

.global-search-empty__ai {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.global-search-empty__ai:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

.global-search-empty__ai:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.global-search-empty__ai [data-lucide],
.global-search-empty__ai svg {
  width: 14px;
  height: 14px;
  color: var(--color-accent);
}

.global-search-empty__ai[hidden] {
  display: none;
}

.global-search-hint {
  padding: var(--space-2) var(--space-4) var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.global-search-panel__chips[hidden],
.global-search-section[hidden],
.global-search-loader[hidden],
.global-search-empty[hidden],
.global-search-ai-stub[hidden],
.global-search-hint[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .global-search-panel {
    max-height: min(60vh, 420px);
  }
}
