/* ════════════════════════════════════════════════════════════════
   QUICK PICKER DE TEMPLATES
   Popover compacto sob o botão "Templates" da topbar.
   Click em card = copia direto pra clipboard + toast.
   ════════════════════════════════════════════════════════════════ */

/* ─── Botão na topbar ─────────────────────────────────────────────
   A topbar do sistema tem fundo bege claro (--bege). Por isso o botão
   usa o mesmo padrão visual do .topbar-user: borda preta translúcida
   sobre fundo transparente. NÃO usa --bg-elev-2 (preto) — ficaria
   um quadrado preto destoando do bege. */
.tpl-btn {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--bg-deep);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--dur-fast, 150ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}
.tpl-btn:hover {
  border-color: var(--bg-deep);
  background: rgba(0, 0, 0, 0.06);
}
/* Estado "popover aberto": fundo escuro contrasta com o bege da topbar
   (mesma lógica do .topbar-user quando logado — fica sólido sobre bege).
   Borda gold pra sinalizar "ativo". */
.tpl-btn.active {
  background: var(--bg-deep);
  border-color: var(--gold);
  color: var(--gold);
}
/* Remove o outline padrão do browser (anel branco/azul ao receber focus
   após click). O estado .active já dá feedback visual suficiente. Mantém
   focus-visible pra acessibilidade via teclado. */
.tpl-btn:focus { outline: none; }
.tpl-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
}
.tpl-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ─── Popover ─────────────────────────────────────────────────── */
.tpl-popover {
  position: fixed;
  background: var(--bg-elev-1);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55),
              0 0 0 1px rgba(212, 184, 118, 0.08);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 180ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)),
              transform 180ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  max-width: calc(100vw - 32px);
}
.tpl-popover.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.tpl-popover.above.active {
  transform: translateY(0);
}
.tpl-popover.above {
  transform: translateY(6px);
}

/* Faixinha gold no topo (mesma identidade dos modals do sistema) */
.tpl-popover::before {
  content: '';
  position: absolute;
  top: 0;
  left: 14px;
  width: 60px;
  height: 1px;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}
.tpl-popover.above::before {
  top: auto;
  bottom: 0;
}

/* ─── Estados de loading / vazio ──────────────────────────────── */
.tpl-popover-loading,
.tpl-popover-empty {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-muted);
  text-align: center;
  padding: 28px 16px;
}

/* ─── Item (card de template) ─────────────────────────────────── */
.tpl-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-family: var(--font-body);
  color: var(--ink);
  transition: all var(--dur-fast, 150ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  margin-bottom: 2px;
}
.tpl-item:last-child {
  margin-bottom: 0;
}
.tpl-item:hover {
  background: var(--bg-elev-2);
  border-color: var(--line-strong);
}
.tpl-item:focus-visible {
  outline: none;
  border-color: var(--gold);
  background: var(--gold-faint);
}
.tpl-item.copied {
  border-color: var(--salvia);
  background: rgba(122, 140, 106, 0.08);
}

.tpl-item-body {
  flex: 1;
  min-width: 0;
}
.tpl-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-pure);
  margin-bottom: 2px;
}
.tpl-item-desc {
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.4;
}

.tpl-item-icon {
  /* Ícone "copiar" no card de template — visual decorativo no estado
     normal, gold no hover (sinaliza ação). PADROES §1.5: ink-muted pra
     ícone visível, NÃO ink-faint (que ficaria invisível). */
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  transition: all var(--dur-fast, 150ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}
.tpl-item:hover .tpl-item-icon {
  color: var(--gold);
  background: var(--gold-faint);
}
.tpl-item.copied .tpl-item-icon {
  color: var(--salvia);
  background: rgba(122, 140, 106, 0.12);
}
.tpl-item-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ─── Toast de "copiado" ──────────────────────────────────────── */
.tpl-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: var(--bg-elev-2);
  border: 1px solid var(--salvia);
  border-radius: 8px;
  padding: 10px 18px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--salvia);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all 250ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  display: flex;
  align-items: center;
  gap: 8px;
}
.tpl-toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.tpl-toast svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
}
