/* AnalysAI — Cards, buttons, badges, forms, tables */

/* Ícones Lucide */
[data-lucide] {
  display: inline-block;
  vertical-align: middle;
  stroke-width: 1.5;
}
.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 16px; height: 16px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.card:hover {
  border-color: rgba(255,255,255,0.1);
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-body { padding: 20px 24px; }
.card-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}
.btn-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #000;
  font-weight: 500;
}
.btn-primary:hover {
  background: var(--amber-light);
}
.btn-danger {
  background: var(--red-dim);
  border-color: rgba(239,68,68,0.3);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(239,68,68,0.2);
}
.btn-sm { padding: 5px 12px; font-size: 11px; }
.btn-lg { padding: 11px 22px; font-size: 13px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  border: 1px solid;
}
.badge-red    { background: var(--red-dim);    color: var(--red);    border-color: rgba(239,68,68,0.2); }
.badge-amber  { background: var(--amber-dim);  color: var(--amber);  border-color: rgba(59, 130, 246, 0.2) }
.badge-green  { background: var(--green-dim);  color: var(--green);  border-color: rgba(34,197,94,0.2); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue);   border-color: rgba(59,130,246,0.2); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border-color: rgba(168,85,247,0.2); }

/* Tabela */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th {
  padding: 10px 16px;
  text-align: left;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}
td {
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text-2);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
tbody tr:hover { background: var(--bg3); }
tbody tr:last-child { border-bottom: none; }

/* Inputs */
.input-wrap { display: flex; flex-direction: column; gap: 6px; }
.input-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.2s;
  outline: none;
  width: 100%;
}
.input:focus { border-color: var(--amber); }
.input::placeholder { color: var(--text-3); }
.select { cursor: pointer; }
select option {
  background: var(--surface);
  color: var(--text);
}

/* Stat card / KPI */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover {
  border-color: rgba(255,255,255,0.1);
  transform: translateY(-2px);
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.02), transparent);
  pointer-events: none;
}
.stat-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}
.stat-value.stat-md { font-size: 22px; font-weight: 700; }
.stat-sub {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state [data-lucide] {
  margin: 0 auto 16px;
  color: var(--text-3);
  opacity: 0.6;
}
.empty-state p { font-size: 13px; margin-bottom: 8px; }
.empty-state p:last-child { margin-bottom: 0; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* Detalhe análise — violações expandíveis */
.violation-item { border-bottom: 1px solid var(--border); }
.violation-item:last-child { border-bottom: none; }
.violation-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px; cursor: pointer; transition: background 0.15s;
}
.violation-head:hover { background: var(--bg3); }
.violation-code { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--amber); }
.violation-name { flex: 1; font-size: 13px; color: var(--text-2); }
.violation-count { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text-3); }
.violation-chevron { font-size: 14px; color: var(--text-3); transition: transform 0.2s; }
.violation-item.is-open .violation-chevron { transform: rotate(90deg); }
.violation-body { display: none; padding: 0 20px 16px; }
.violation-item.is-open .violation-body { display: block; }
.quote-block {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin-top: 10px; font-size: 13px; color: var(--text-2);
}
.quote-block .quote-meta { font-size: 11px; color: var(--text-3); margin-top: 6px; }

/* Botão "Ver na transcrição" dentro da citação */
.btn-ver-trecho {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px; padding: 4px 10px; border-radius: 6px;
  background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.25);
  color: var(--blue, #60A5FA); font-family: 'DM Mono', monospace;
  font-size: 11px; cursor: pointer; transition: all .2s;
}
.btn-ver-trecho:hover { background: rgba(59,130,246,0.2); border-color: rgba(59,130,246,0.4); }

/* Highlight na transcrição */
.trecho-highlight {
  background: rgba(59,130,246,0.3); border-radius: 3px;
  padding: 1px 0; box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
  animation: trecho-pulse 1.5s ease-in-out 2;
}
.trecho-highlight-fade {
  animation: none;
  transition: background .8s, box-shadow .8s;
  background: transparent; box-shadow: none;
}
@keyframes trecho-pulse {
  0%, 100% { background: rgba(59,130,246,0.3); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
  50% { background: rgba(59,130,246,0.5); box-shadow: 0 0 0 4px rgba(59,130,246,0.15); }
}

/* Stats row grid */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1200px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* Content grid 2 colunas */
.content-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .content-grid-2 { grid-template-columns: 1fr; }
}

/* Grid com sidebar estreita (motivos) */
.content-grid-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 960px) {
  .content-grid-sidebar { grid-template-columns: 1fr; }
  .content-grid-sidebar .card[style*="sticky"] { position: static !important; }
}

/* Grid 3 colunas (vendedores) */
.content-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 900px) {
  .content-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .content-grid-3 { grid-template-columns: 1fr; }
}

/* Grid config (nav lateral + conteúdo) */
.config-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .config-grid { grid-template-columns: 1fr; }
  .config-grid > nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .config-grid > nav .nav-item { flex: 0 0 auto; }
}

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 8px; }
.toggle {
  width: 40px; height: 22px;
  background: var(--bg3);
  border-radius: 99px;
  border: 1px solid var(--border);
  position: relative; cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--green-dim); border-color: rgba(34,197,94,0.3); }
.toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-3);
  top: 2px; left: 2px;
  transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(18px); background: var(--green); }

/* ── Utility: card-title ── */
.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

/* ── Nav badge: oculto quando vazio ── */
.nav-badge:empty { display: none; }

/* ── Barra de filtros ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  align-items: flex-end;
}
.filter-bar .input-wrap { flex: 0 0 auto; }
@media (max-width: 600px) {
  .filter-bar { gap: 8px; }
  .filter-bar .input-wrap { flex: 1 1 140px; }
  .filter-bar .input,
  .filter-bar .select { width: 100% !important; }
  .filter-bar .btn { flex: 1 1 auto; justify-content: center; }
}

/* ── Responsividade: stat cards ── */
@media (max-width: 480px) {
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: clamp(22px, 7vw, 32px); }
  .stat-value.stat-md { font-size: clamp(14px, 4vw, 22px); }
}

/* ── Responsividade: cards ── */
@media (max-width: 480px) {
  .card-header { padding: 14px 16px; }
  .card-body   { padding: 14px 16px; }
  .card-footer { padding: 10px 16px; }
}

/* ── Responsividade: tabela ── */
@media (max-width: 640px) {
  th { padding: 8px 10px; font-size: 9px; }
  td { padding: 10px; font-size: 12px; }
  .hide-mobile { display: none; }
}

/* ── Tabela: scroll horizontal com indicador ── */
.table-wrap {
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* ── Responsividade: violation items ── */
@media (max-width: 480px) {
  .violation-head { padding: 12px 14px; gap: 8px; }
  .violation-body { padding: 0 14px 14px; }
  .quote-block { padding: 10px 12px; font-size: 12px; }
}

/* ── Botão verde (aprovar) ── */
.btn-green {
  background: var(--green-dim);
  border-color: rgba(34,197,94,0.3);
  color: var(--green);
}
.btn-green:hover { background: rgba(34,197,94,0.2); }

/* ── Barra de ação em massa ── */
.bulk-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--amber-dim);
  border: 1px solid var(--border-accent);
  border-radius: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--amber);
}
.bulk-bar.is-visible { display: flex; }

/* ── Item de alerta ── */
.alerta-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.alerta-item:hover { background: var(--bg3); }
.alerta-item:last-child { border-bottom: none; }
.alerta-item.is-loading { opacity: 0.6; pointer-events: none; }

/* ── Badge de discordância ── */
.badge-warn {
  background: rgba(245,158,11,0.15);
  color: #f59e0b;
  border-color: rgba(245,158,11,0.3);
}

/* ═══ Toast / Snackbar ═══ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toastIn .3s ease;
  max-width: 380px;
}
.toast.toast-out { animation: toastOut .25s ease forwards; }
.toast-icon { flex-shrink: 0; width: 18px; height: 18px; }
.toast-msg { flex: 1; }
.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
}
.toast-close:hover { color: var(--text); }
.toast-success { border-color: rgba(34,197,94,.3); }
.toast-success .toast-icon { color: var(--green); }
.toast-error { border-color: rgba(239,68,68,.3); }
.toast-error .toast-icon { color: var(--red); }
.toast-warning { border-color: rgba(245,158,11,.3); }
.toast-warning .toast-icon { color: var(--amber); }
.toast-info { border-color: rgba(59,130,246,.3); }
.toast-info .toast-icon { color: var(--blue); }

@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(12px) scale(.9); } }
@media (max-width: 480px) { .toast-container { left: 12px; right: 12px; bottom: 12px; } .toast { max-width: 100%; } }

/* ═══ Confirm Dialog ═══ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .15s ease;
}
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
.confirm-title { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.confirm-msg { font-size: 13px; color: var(--text-2); margin-bottom: 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Responsividade: alerta-item em mobile ── */
@media (max-width: 560px) {
  .alerta-item { flex-wrap: wrap; padding: 14px 16px; gap: 10px; }
  .alerta-item > div:last-child { flex-direction: row; width: 100%; justify-content: flex-end; }
}

/* ── Responsividade: card-header com botões ── */
@media (max-width: 480px) {
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header > div[style*="margin-left:auto"] { margin-left: 0 !important; width: 100%; }
  .card-header .btn { font-size: 10px; padding: 4px 8px; }
}

/* ── Responsividade: filter-bar compacta ── */
@media (max-width: 480px) {
  .filter-bar .input-wrap { min-width: 0 !important; max-width: none !important; }
  .filter-bar .input-wrap[style*="width:180px"],
  .filter-bar .input-wrap[style*="width:160px"],
  .filter-bar .input-wrap[style*="width:150px"],
  .filter-bar .input-wrap[style*="width:140px"] { flex: 1 1 calc(50% - 4px); }
}

/* ── Responsividade: topbar-right ── */
@media (max-width: 360px) {
  .topbar-avatar { display: none; }
}
