/* ===========================================================================
   Atende AI — painel self-service
   Estilo base do produto (NÃO confundir com as cores por tenant do widget).
   Mobile-first; expande em telas maiores via media queries.
   =========================================================================== */

/* --- Reset enxuto -------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--texto);
  background: var(--fundo);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--azul); }

/* --- Tema (variáveis) ---------------------------------------------------- */
:root {
  --azul: #4f46e5;          /* indigo-600 — primária da marca */
  --azul-escuro: #3730a3;   /* indigo-800 — hover/foco */
  --azul-claro: #eef2ff;    /* indigo-50 — fundos sutis */
  --violeta: #7c3aed;       /* destaque do painel de marca */
  --verde: #16a34a;         /* sucesso / WhatsApp */
  --vermelho: #dc2626;      /* erro */
  --amarelo: #d97706;       /* aviso / trial */

  --texto: #1e293b;         /* slate-800 */
  --texto-suave: #64748b;   /* slate-500 */
  --borda: #e2e8f0;         /* slate-200 */
  --fundo: #f8fafc;         /* slate-50 */
  --branco: #ffffff;

  --raio: 12px;
  --raio-sm: 8px;
  --sombra: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
  --foco: 0 0 0 3px rgba(79, 70, 229, .35);
}

/* --- Layout de autenticação (login/cadastro) ----------------------------- */
.auth {
  display: grid;
  grid-template-columns: 1fr;     /* mobile: só o formulário */
  min-height: 100vh;
}

/* Painel de marca — escondido no mobile pra priorizar o formulário. */
.auth__marca {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  color: var(--branco);
  background: linear-gradient(150deg, var(--azul) 0%, var(--violeta) 100%);
}

.auth__marca-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

/* Símbolo "AS" sobre chip branco — lê bem no gradiente do painel. */
.auth__marca-simbolo {
  width: 2.4rem;
  height: 2.4rem;
  padding: 4px;
  background: var(--branco);
  border-radius: 9px;
}

.auth__marca-pitch h2 {
  font-size: clamp(1.6rem, 1rem + 1.6vw, 2.4rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin-bottom: 1rem;
}

.auth__marca-pitch p { color: rgba(255, 255, 255, .85); max-width: 36ch; }

.auth__marca-rodape { font-size: .85rem; color: rgba(255, 255, 255, .7); }

/* Coluna do formulário */
.auth__form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem 1.25rem;
}

.auth__card {
  width: 100%;
  max-width: 30rem;
}

.auth__logo-mobile {
  display: block;
  width: auto;
  height: 4.25rem;
  margin: 0 auto .75rem;   /* centralizado horizontalmente */
}

/* Tagline curta sob a logo — só no mobile (no desktop o painel de marca
   já traz o pitch completo). */
.auth__tagline {
  text-align: center;
  color: var(--texto-suave);
  font-size: .95rem;
  margin: 0 auto 1.75rem;
  max-width: 32ch;
}

.auth h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: .35rem;
}

.auth__sub { color: var(--texto-suave); margin-bottom: 2rem; }

.auth__troca {
  margin-top: 1.75rem;
  text-align: center;
  color: var(--texto-suave);
  font-size: .95rem;
}

.auth__troca a { font-weight: 600; text-decoration: none; }
.auth__troca a:hover { text-decoration: underline; }

/* --- Formulário ---------------------------------------------------------- */
.campo { margin-bottom: 1.1rem; }

.campo label {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .4rem;
}

.campo .opcional { font-weight: 400; color: var(--texto-suave); }

.campo input,
.campo textarea,
.campo select {
  width: 100%;
  padding: .7rem .85rem;
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: var(--raio-sm);
  transition: border-color .15s, box-shadow .15s;
}

.campo textarea { resize: vertical; min-height: 4.5rem; }

.campo input:focus,
.campo textarea:focus,
.campo select:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: var(--foco);
}

.campo input[aria-invalid="true"],
.campo textarea[aria-invalid="true"] { border-color: var(--vermelho); }

.campo__dica { font-size: .8rem; color: var(--texto-suave); margin-top: .35rem; }

.campo__erro {
  font-size: .8rem;
  color: var(--vermelho);
  margin-top: .35rem;
  min-height: 1rem;
}

/* Linha com 2 colunas em telas médias (ex.: nicho + whatsapp) */
.linha { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }

/* --- Botões -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  padding: .8rem 1.25rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--raio-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}

.btn:active { transform: translateY(1px); }

.btn:focus-visible { outline: none; box-shadow: var(--foco); }

.btn--primario { background: var(--azul); color: var(--branco); }
.btn--primario:hover { background: var(--azul-escuro); }

.btn--secundario {
  background: var(--branco);
  color: var(--texto);
  border-color: var(--borda);
}
.btn--secundario:hover { background: var(--azul-claro); }

.btn[disabled] { opacity: .6; cursor: not-allowed; }

.btn--bloco { width: 100%; }

/* --- Seções do cadastro (fieldsets) -------------------------------------- */
fieldset {
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

legend {
  padding: 0 .5rem;
  font-weight: 700;
  font-size: .95rem;
  color: var(--azul);
}

.secao__hint {
  font-size: .85rem;
  color: var(--texto-suave);
  margin: -.25rem 0 1rem;
}

/* --- Lista de serviços (repetível) --------------------------------------- */
.servico {
  position: relative;
  padding: 1rem;
  border: 1px dashed var(--borda);
  border-radius: var(--raio-sm);
  margin-bottom: 1rem;
  background: var(--azul-claro);
}

.servico__num { font-weight: 600; font-size: .85rem; color: var(--azul); }

.servico__remover {
  position: absolute;
  top: .6rem;
  right: .6rem;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 50%;
  color: var(--vermelho);
  cursor: pointer;
  line-height: 1;
}
.servico__remover:hover { background: var(--vermelho); color: var(--branco); }
.servico__remover:focus-visible { outline: none; box-shadow: var(--foco); }

/* --- Alertas (erro/sucesso/aviso) ---------------------------------------- */
.alerta {
  padding: .8rem 1rem;
  border-radius: var(--raio-sm);
  font-size: .92rem;
  margin-bottom: 1.25rem;
}
.alerta[hidden] { display: none; }
.alerta--erro { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alerta--ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* --- Bloco de script copiável (sucesso do cadastro) ---------------------- */
.script-box {
  display: flex;
  gap: .5rem;
  align-items: stretch;
  background: #0f172a;
  border-radius: var(--raio-sm);
  padding: .75rem;
  margin: 1rem 0;
}
.script-box code {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .82rem;
  color: #e2e8f0;
  word-break: break-all;
  align-self: center;
}
.script-box button {
  flex-shrink: 0;
  padding: .4rem .8rem;
  font-size: .85rem;
  font-weight: 600;
  background: var(--azul);
  color: var(--branco);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.script-box button:hover { background: var(--azul-escuro); }

/* --- Spinner no botão ---------------------------------------------------- */
.spinner {
  width: 1.1em;
  height: 1.1em;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: girar .6s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* --- Painel / dashboard (F8) --------------------------------------------- */
.dash-body { background: var(--fundo); }

.dash__top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .7rem 1.25rem;
  background: var(--branco);
  border-bottom: 1px solid var(--borda);
  position: sticky;
  top: 0;
  z-index: 10;
}
.dash__logo { height: 2.25rem; width: auto; }
.dash__tenant { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.dash__tenant strong { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash__acoes { display: flex; gap: .5rem; flex-shrink: 0; }

.btn--mini { width: auto; padding: .45rem .85rem; font-size: .85rem; }

.dash__main { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.dash__cab {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.dash__cab h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }

.periodo {
  display: inline-flex; background: var(--branco);
  border: 1px solid var(--borda); border-radius: 999px; padding: 3px;
}
.periodo button {
  border: none; background: transparent; cursor: pointer;
  padding: .4rem .9rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: var(--texto-suave);
}
.periodo button.ativo { background: var(--azul); color: var(--branco); }
.periodo button:focus-visible { outline: none; box-shadow: var(--foco); }

.dash__msg { color: var(--texto-suave); padding: 2rem 0; text-align: center; }
.dash__msg--erro { color: var(--vermelho); }

/* KPIs */
.kpis { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; }
.kpi {
  background: var(--branco); border: 1px solid var(--borda);
  border-radius: var(--raio); box-shadow: var(--sombra); padding: 1.25rem;
}
.kpi__label { font-size: .85rem; color: var(--texto-suave); margin-bottom: .35rem; }
.kpi__valor { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.kpi__sub { font-size: .8rem; color: var(--texto-suave); margin-top: .35rem; min-height: 1rem; }

/* Cards de seção */
.dash__grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1rem; }
.card {
  background: var(--branco); border: 1px solid var(--borda);
  border-radius: var(--raio); box-shadow: var(--sombra); padding: 1.25rem;
}
.card h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: .75rem; }
.card__hint { font-size: .85rem; color: var(--texto-suave); margin-bottom: 1rem; }
.card--ouro { border-color: #fde68a; background: linear-gradient(180deg, #fffbeb 0%, var(--branco) 55%); }

/* Gráfico de barras (buscas/dia) */
.grafico { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.grafico__col {
  flex: 1; min-width: 3px; background: var(--azul);
  border-radius: 3px 3px 0 0; opacity: .85;
}
.grafico__col:hover { opacity: 1; }

/* Barras (top serviços) */
.barra { margin-bottom: .85rem; }
.barra:last-child { margin-bottom: 0; }
.barra__cab { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; margin-bottom: .35rem; }
.barra__val { color: var(--texto-suave); font-variant-numeric: tabular-nums; white-space: nowrap; }
.barra__trilha { height: 8px; background: var(--azul-claro); border-radius: 999px; overflow: hidden; }
.barra__fill { height: 100%; background: var(--azul); border-radius: 999px; }

/* Lacunas (perguntas sem boa resposta) */
.lacunas { list-style: none; }
.lacunas li {
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
  padding: .6rem 0; border-bottom: 1px solid var(--borda);
}
.lacunas li:last-child { border-bottom: none; }
.lacuna__contagem { color: var(--amarelo); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Upsell (plano Básico) */
.upsell { text-align: center; max-width: 32rem; margin: 1rem auto; }
.upsell h2 { color: var(--azul); margin-bottom: .5rem; }
.upsell p { color: var(--texto-suave); margin-bottom: 1.25rem; }

/* Badge de status/trial (reusado no topo do dash) */
.trial-tag {
  display: inline-block; font-size: .75rem; font-weight: 600;
  color: var(--amarelo); background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 999px; padding: .2rem .6rem; white-space: nowrap;
}

/* Modal do código de instalação */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 1.25rem;
  background: rgba(15, 23, 42, .5);
}
.modal[hidden] { display: none; }
.modal__card {
  width: 100%; max-width: 34rem; background: var(--branco);
  border-radius: var(--raio); padding: 1.75rem; box-shadow: var(--sombra);
}
.modal__card h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: .35rem; }
.modal__acoes { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.modal__acoes .btn { width: auto; }

/* Abas do painel */
.abas {
  display: flex; gap: .25rem; overflow-x: auto;
  border-bottom: 1px solid var(--borda); margin-bottom: 1.5rem;
}
.aba {
  border: none; background: none; cursor: pointer; white-space: nowrap;
  padding: .7rem 1rem; font-size: .95rem; font-weight: 600;
  color: var(--texto-suave); border-bottom: 2px solid transparent;
}
.aba.ativo { color: var(--azul); border-bottom-color: var(--azul); }
.aba:focus-visible { outline: none; box-shadow: var(--foco); border-radius: 6px 6px 0 0; }

.periodo-linha { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.card__cab { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .25rem; }

/* Lista de serviços */
.servico-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--borda);
}
.servico-row:last-child { border-bottom: none; }
.servico-row__info { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.servico-row__url { font-size: .8rem; color: var(--texto-suave); word-break: break-all; }
.servico-row__inativo {
  display: inline-block; width: fit-content; margin-top: .15rem;
  font-size: .72rem; font-weight: 600; color: var(--texto-suave);
  background: var(--fundo); border: 1px solid var(--borda);
  border-radius: 999px; padding: .1rem .5rem;
}
.servico-row__acoes { display: flex; gap: .4rem; flex-shrink: 0; }
.btn--perigo { color: var(--vermelho); }
.btn--perigo:hover { background: #fef2f2; }

/* Checkbox com label */
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; margin: .5rem 0 1.25rem; cursor: pointer; }
.check input { width: auto; }

/* Dados read-only da conta */
.dados { display: grid; gap: .25rem; }
.dados div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--borda); padding: .5rem 0; }
.dados div:last-child { border-bottom: none; }
.dados dt { color: var(--texto-suave); font-size: .9rem; }
.dados dd { font-weight: 600; text-align: right; word-break: break-all; }

input[type="color"] { height: 2.6rem; padding: .2rem; cursor: pointer; }

@media (min-width: 700px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .dash__grid { grid-template-columns: 1fr 1fr; }
}

/* --- Acessibilidade ------------------------------------------------------ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Breakpoints --------------------------------------------------------- */
@media (min-width: 560px) {
  .linha { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 960px) {
  .auth { grid-template-columns: 1.1fr 1fr; }
  .auth__marca { display: flex; }
  .auth__logo-mobile { display: none; }
  .auth__tagline { display: none; }
  .auth__form { padding: 3rem; }
}
