/**
 * global-search.css
 * ---------------------------------------------------------------
 * Estilos do componente de Busca Global (Sprint 6).
 *
 * Não redefine nenhum token de design — reaproveita as variáveis
 * CSS (--bg-raised, --accent, --radius-md, --font-ui, etc.) já
 * declaradas em :root pelo bloco <style> de cada página. Este
 * arquivo só é responsável pelo próprio componente de busca:
 * o input existente da topbar não é alterado, apenas ganha uma
 * âncora de posicionamento (position: relative) para o painel.
 * ---------------------------------------------------------------
 */

/* a topbar-search já existe em cada página — só precisa virar a
   âncora de posicionamento do painel de resultados */
.topbar-search{
  position: relative;
}

/* ===============================================================
   PAINEL DE RESULTADOS
=============================================================== */
.global-search-panel{
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(420px, 90vw);
  max-height: min(480px, 70vh);
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  padding: 8px;
  z-index: 200;
  display: none;
  flex-direction: column;
  gap: 4px;
}
.global-search-panel.is-open{
  display: flex;
}

.gs-group{
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gs-group-label{
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 8px 10px 4px;
}

.gs-result{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s ease;
}
.gs-result:hover,
.gs-result.is-active{
  background: var(--card-hover, rgba(255,255,255,0.06));
}
.gs-result.gs-flash{
  animation: gs-flash-pulse .5s ease-out;
}
@keyframes gs-flash-pulse{
  0%   { box-shadow: 0 0 0 0 rgba(62,142,255,0.35); }
  100% { box-shadow: 0 0 0 6px rgba(62,142,255,0); }
}

.gs-result-icon{
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.gs-result-icon svg{ width: 15px; height: 15px; color: var(--text-secondary); }

.gs-result-body{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.gs-result-primary{
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-result-secondary{
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gs-result-badge{
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.06);
}
.gs-result-badge.gs-badge-user{   color: var(--accent);      background: rgba(62,142,255,0.12); }
.gs-result-badge.gs-badge-asset{  color: var(--accent-cyan); background: rgba(34,211,238,0.12); }
.gs-result-badge.gs-badge-ticket{ color: var(--ok);          background: rgba(63,185,80,0.12); }

/* ===============================================================
   ESTADOS (hint / loading / vazio / erro)
=============================================================== */
.gs-state{
  padding: 20px 14px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.5;
}
.gs-state strong{ color: var(--text-secondary); }

.gs-loading{
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}
.gs-skeleton-line{
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.14) 37%, rgba(255,255,255,0.06) 63%);
  background-size: 400% 100%;
  animation: gs-skeleton-shimmer 1.4s ease infinite;
}
.gs-skeleton-line:nth-child(2){ width: 80%; }
.gs-skeleton-line:nth-child(3){ width: 60%; }
@keyframes gs-skeleton-shimmer{
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.gs-error{ color: var(--danger); }

/* ===============================================================
   BOTÃO DE BUSCA MOBILE (injetado via JS na .topbar-actions)
=============================================================== */
.global-search-mobile-btn{ display: none; }

@media (max-width: 900px){
  .global-search-mobile-btn{ display: flex; }

  /* quando ativo, a topbar-search vira um overlay de tela cheia —
     a estrutura da topbar em si não é alterada, só o posicionamento
     deste componente específico quando o usuário abre a busca */
  .topbar-search.gs-mobile-active{
    display: flex;
    position: fixed;
    top: 12px;
    left: 12px;
    width: calc(100vw - 24px);
    max-width: none;
    flex: none;
    z-index: 300;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  }
  .topbar-search.gs-mobile-active .global-search-panel{
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 600px){
  .global-search-panel{ width: calc(100vw - 24px); }
}
