/* ============================================================================
   ANALYSIS HISTORY — painel de histórico persistente de análises
   (separado dos chips de busca recente em search.css / .search-history)

   Cores via tokens semânticos (tokens.css): --off-white (texto principal),
   --off-white-dim/--muted (secundário), --navy-* (superfícies), --gold (ação).
   Esses tokens JÁ invertem sozinhos em [data-theme="light"], então NÃO os
   sobrescrevemos por tema. Só os rgba() estruturais (bordas/hover) hardcoded
   precisam de override claro/escuro.
   ============================================================================ */

/* Botão de abrir o histórico (no header, ao lado de tema/idioma) */
.ah-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 34px;
  padding: 0 0.6rem;
  background: transparent;
  color: var(--off-white-dim);
  border: 1px solid rgba(245,240,232,0.14);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.ah-trigger:hover {
  color: var(--bee);
  border-color: rgba(201,150,62,0.45);
}
.ah-trigger svg { display: block; }
.ah-trigger .ah-trigger-label { display: none; }
@media (min-width: 720px) {
  .ah-trigger .ah-trigger-label { display: inline; }
}
[data-theme="light"] .ah-trigger { border-color: rgba(0,0,0,0.14); }

/* Overlay + modal */
.ah-panel {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.18s ease;
}
.ah-panel.open { display: flex; }

.ah-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5,12,22,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
[data-theme="light"] .ah-backdrop { background: rgba(13,27,42,0.45); }

.ah-modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy-700) 0%, var(--navy-800) 100%);
  border: 1px solid rgba(201,150,62,0.2);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  animation: fadeUp 0.25s var(--transition);
  overflow: hidden;
}

.ah-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.4rem 1rem;
  border-bottom: 1px solid rgba(245,240,232,0.08);
}
[data-theme="light"] .ah-header { border-bottom-color: rgba(0,0,0,0.08); }

.ah-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--off-white);
  margin: 0;
}

.ah-close {
  background: transparent;
  border: none;
  color: var(--off-white-dim);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.4rem;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.ah-close:hover { color: var(--off-white); background: rgba(128,128,128,0.12); }

.ah-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
}

.ah-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.4rem;
  border-bottom: 1px solid rgba(245,240,232,0.05);
  transition: background 0.15s;
}
.ah-item:last-child { border-bottom: none; }
.ah-item:hover { background: rgba(245,240,232,0.04); }
[data-theme="light"] .ah-item { border-bottom-color: rgba(0,0,0,0.06); }
[data-theme="light"] .ah-item:hover { background: rgba(0,0,0,0.03); }

.ah-item-info { min-width: 0; flex: 1; }

.ah-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--off-white);
  margin: 0 0 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ah-item-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}

.ah-item-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

.ah-restore {
  padding: 0.4rem 0.85rem;
  background: var(--gold);
  color: var(--navy-900);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.ah-restore:hover { background: var(--gold-bright); }
.ah-restore:active { transform: translateY(1px); }

.ah-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.ah-delete:hover { color: var(--error); background: rgba(255,69,58,0.12); }
.ah-delete svg { display: block; }

.ah-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}
.ah-empty-icon { font-size: 2.5rem; opacity: 0.5; margin-bottom: 0.75rem; }

.ah-footer {
  padding: 0.85rem 1.4rem;
  border-top: 1px solid rgba(245,240,232,0.08);
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}
[data-theme="light"] .ah-footer { border-top-color: rgba(0,0,0,0.08); }
.ah-count { font-weight: 600; color: var(--off-white); }

@media (max-width: 520px) {
  .ah-modal { max-height: 88vh; }
  .ah-item { flex-direction: column; align-items: stretch; }
  .ah-item-actions { justify-content: flex-end; }
}
