/* ============================================================
   PAINEL DE ATENDIMENTO — sistema de design
   Direção: calmo, preciso, profissional. Feito para uso prolongado.
   White-label: a cor de marca vive em --marca-* e pode ser trocada
   por tenant sem tocar no resto.
   ============================================================ */

:root {
  /* Marca (trocável por cliente) */
  --marca: #0f6e6e;          /* teal profundo */
  --marca-escuro: #0a5252;
  --marca-claro: #e4f2f1;

  /* Superfícies */
  --bg: #f6f5f1;             /* off-white quente */
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --linha: #e7e4dd;
  --linha-forte: #d5d1c7;

  /* Texto */
  --tinta: #1c1e1d;
  --tinta-2: #565a57;
  --tinta-3: #8b8f8a;

  /* Semânticos */
  --cliente: #2b7a4b;        /* balão do cliente (verde discreto) */
  --cliente-bg: #eef7f0;
  --bot-bg: #eef1f5;
  --agente-bg: var(--marca-claro);
  --alerta: #c2410c;
  --aguardando: #b45309;

  /* Métricas */
  --raio: 12px;
  --raio-sm: 8px;
  --sombra: 0 1px 2px rgba(28, 30, 29, 0.04), 0 2px 8px rgba(28, 30, 29, 0.05);
  --sombra-forte: 0 4px 20px rgba(28, 30, 29, 0.10);
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--tinta);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--marca-claro), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  box-shadow: var(--sombra-forte);
  padding: 40px 32px 32px;
}
.login-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--marca);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.login-brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--marca);
  box-shadow: 0 0 0 4px var(--marca-claro);
}
.login-sub { color: var(--tinta-3); font-size: 13px; margin-bottom: 28px; }
.campo { margin-bottom: 16px; }
.campo label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--tinta-2); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.campo input {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--linha-forte);
  border-radius: var(--raio-sm);
  font-family: inherit; font-size: 14px;
  background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s;
}
.campo input:focus {
  outline: none; border-color: var(--marca);
  box-shadow: 0 0 0 3px var(--marca-claro);
  background: var(--surface);
}
.btn {
  width: 100%; padding: 12px;
  background: var(--marca); color: #fff;
  border: none; border-radius: var(--raio-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--marca-escuro); }
.erro {
  background: #fdf0ed; border: 1px solid #f4cdbf;
  color: var(--alerta); padding: 10px 12px;
  border-radius: var(--raio-sm); font-size: 13px; margin-bottom: 16px;
}

/* ---------- Layout app ---------- */
.app {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  overflow: hidden;
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .app.mostrando-conversa .lista { display: none; }
  .app:not(.mostrando-conversa) .painel-conversa { display: none; }
}

/* Coluna esquerda: lista */
.lista {
  border-right: 1px solid var(--linha);
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.lista-topo {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--linha);
}
.marca-linha {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.marca {
  font-family: var(--font-display); font-weight: 600;
  font-size: 16px; letter-spacing: -0.02em; color: var(--marca);
  display: flex; align-items: center; gap: 8px;
}
.marca .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--marca); box-shadow: 0 0 0 3px var(--marca-claro);
}
.sair {
  font-size: 12px; color: var(--tinta-3);
  text-decoration: none; padding: 4px 8px; border-radius: 6px;
}
.sair:hover { background: var(--surface-2); color: var(--tinta-2); }

.filtros { display: flex; gap: 6px; flex-wrap: wrap; }
.filtro {
  font-size: 12px; padding: 5px 10px;
  border: 1px solid var(--linha-forte); border-radius: 20px;
  color: var(--tinta-2); text-decoration: none;
  transition: all .15s; white-space: nowrap;
}
.filtro:hover { border-color: var(--marca); color: var(--marca); }
.filtro.ativo {
  background: var(--marca); color: #fff; border-color: var(--marca);
}

.conversas { overflow-y: auto; flex: 1; }
.conversa-item {
  display: block; text-decoration: none; color: inherit;
  padding: 14px 18px; border-bottom: 1px solid var(--linha);
  transition: background .12s; position: relative;
}
.conversa-item:hover { background: var(--surface-2); }
.conversa-item.ativa { background: var(--marca-claro); }
.conversa-item.ativa::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--marca);
}
.ci-topo {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-bottom: 3px;
}
.ci-nome {
  font-weight: 600; font-size: 14px; color: var(--tinta);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ci-hora { font-size: 11px; color: var(--tinta-3); flex-shrink: 0; }
.ci-previa {
  font-size: 13px; color: var(--tinta-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.ci-previa .rem { color: var(--tinta-3); font-weight: 500; }
.ci-badges { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.pill {
  font-size: 10.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.03em;
}
.pill.bot { background: var(--bot-bg); color: #4b5563; }
.pill.aguardando_humano { background: #fef3e2; color: var(--aguardando); }
.pill.com_humano { background: var(--marca-claro); color: var(--marca-escuro); }
.pill.encerrada { background: #f0efec; color: var(--tinta-3); }
.nao-lida {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--marca); flex-shrink: 0;
}

/* Coluna direita: conversa */
.painel-conversa {
  display: flex; flex-direction: column;
  background: var(--surface-2); overflow: hidden;
}
.conversa-topo {
  padding: 16px 24px; background: var(--surface);
  border-bottom: 1px solid var(--linha);
  display: flex; align-items: center; gap: 14px;
}
.voltar {
  display: none; text-decoration: none; color: var(--tinta-2);
  font-size: 20px; line-height: 1;
}
@media (max-width: 720px) { .voltar { display: block; } }
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--marca); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 600; font-size: 16px;
  flex-shrink: 0;
}
.ct-info { flex: 1; min-width: 0; }
.ct-nome { font-weight: 600; font-size: 15px; }
.ct-num { font-size: 12px; color: var(--tinta-3); }

.mensagens {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 10px;
  background-image: radial-gradient(var(--linha) 0.5px, transparent 0.5px);
  background-size: 22px 22px;
}
.msg { max-width: 62%; display: flex; flex-direction: column; }
.msg .bolha {
  padding: 9px 13px; border-radius: 14px;
  font-size: 14px; line-height: 1.45; word-wrap: break-word;
  white-space: pre-wrap; box-shadow: var(--sombra);
}
.msg .meta {
  font-size: 10.5px; color: var(--tinta-3);
  margin-top: 3px; padding: 0 4px;
}
/* cliente à esquerda */
.msg.cliente { align-self: flex-start; align-items: flex-start; }
.msg.cliente .bolha {
  background: var(--surface); color: var(--tinta);
  border-bottom-left-radius: 4px;
}
/* bot e agente à direita */
.msg.bot, .msg.agente { align-self: flex-end; align-items: flex-end; }
.msg.bot .bolha {
  background: var(--bot-bg); color: var(--tinta);
  border-bottom-right-radius: 4px;
}
.msg.agente .bolha {
  background: var(--marca); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg .rem-tag {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--tinta-3);
  margin-bottom: 3px; padding: 0 4px;
}

/* Aviso de leitura (MVP não envia) */
.barra-info {
  padding: 12px 24px; background: var(--surface);
  border-top: 1px solid var(--linha);
  font-size: 12.5px; color: var(--tinta-3);
  text-align: center;
}
.barra-info strong { color: var(--tinta-2); font-weight: 600; }

/* Estados vazios */
.vazio {
  flex: 1; display: grid; place-items: center; padding: 40px;
  text-align: center; color: var(--tinta-3);
}
.vazio-conteudo { max-width: 280px; }
.vazio h3 {
  font-family: var(--font-display); font-weight: 600;
  color: var(--tinta-2); font-size: 16px; margin-bottom: 6px;
}
.vazio p { font-size: 13px; }

/* scrollbar discreta */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--linha-forte); border-radius: 10px;
  border: 3px solid var(--surface);
}
.mensagens::-webkit-scrollbar-thumb { border-color: var(--surface-2); }

/* ============================================================
   Seleção de cliente (admin), conta, e extras
   ============================================================ */

/* Topo com ações múltiplas */
.topo-acoes { display: flex; align-items: center; gap: 4px; }

.badge-admin {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: #fff; background: var(--marca);
  padding: 2px 7px; border-radius: 20px; margin-right: 2px;
}

/* ---------- Seleção de cliente ---------- */
.sel-wrap { min-height: 100vh; background: var(--bg); }
.sel-topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: var(--surface);
  border-bottom: 1px solid var(--linha);
}
.sel-user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--tinta-2); }
.sel-conteudo { max-width: 640px; margin: 0 auto; padding: 48px 24px; }
.sel-titulo {
  font-family: var(--font-display); font-weight: 600; font-size: 26px;
  letter-spacing: -0.02em; color: var(--tinta); margin-bottom: 6px;
}
.sel-sub { color: var(--tinta-2); font-size: 14px; margin-bottom: 32px; }
.sel-grid { display: flex; flex-direction: column; gap: 12px; }

.cliente-card {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; background: var(--surface);
  border: 1px solid var(--linha); border-radius: var(--raio);
  text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.cliente-card:hover {
  border-color: var(--marca); box-shadow: var(--sombra);
  transform: translateY(-1px);
}
.cliente-card.inativo { opacity: 0.5; }
.cliente-inicial {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--marca); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 600; font-size: 20px;
  flex-shrink: 0;
}
.cliente-info { flex: 1; min-width: 0; }
.cliente-nome { font-weight: 600; font-size: 16px; color: var(--tinta); margin-bottom: 3px; }
.cliente-meta { font-size: 13px; }
.cliente-alerta { color: var(--aguardando); font-weight: 600; }
.cliente-ok { color: var(--tinta-3); }
.cliente-seta {
  font-size: 20px; color: var(--tinta-3); flex-shrink: 0;
  transition: transform .15s, color .15s;
}
.cliente-card:hover .cliente-seta { color: var(--marca); transform: translateX(3px); }

/* ---------- Minha conta ---------- */
.conta-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px; background: var(--bg);
}
.conta-card {
  width: 100%; max-width: 440px; background: var(--surface);
  border: 1px solid var(--linha); border-radius: var(--raio);
  box-shadow: var(--sombra); padding: 28px;
}
.conta-topo {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.conta-ident {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 22px; margin-bottom: 22px;
  border-bottom: 1px solid var(--linha);
}
.conta-secao {
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
  color: var(--tinta); margin-bottom: 16px;
}
.sucesso {
  background: var(--cliente-bg); border: 1px solid #bfe3ca;
  color: var(--cliente); padding: 10px 12px;
  border-radius: var(--raio-sm); font-size: 13px; margin-bottom: 16px;
}
