/* AgentDesk — tema claro. A cor de destaque vem do agente ativo (--agente). */
:root {
  --agente: #C2185B;
  --agente-suave: #fce4ec;
  --fundo: #f6f5f3;
  --painel: #ffffff;
  --linha: #e7e5e1;
  --texto: #1d1d1f;
  --suave: #6b6b70;
  --balao-eu: #ffffff;
  --balao-agente: #ffffff;
  --perigo: #c62828;
  --raio: 14px;
  --topo: 56px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; }

/* ---- estrutura ---- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100dvh; }
.topo {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: var(--topo);
  background: var(--painel); border-bottom: 1px solid var(--linha);
  padding-top: max(8px, env(safe-area-inset-top));
}
.agentes { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.agente-btn {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  border: 1px solid var(--linha); white-space: nowrap; background: var(--painel);
}
.agente-btn .bolinha {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px; background: var(--c);
}
.agente-btn .desc { color: var(--suave); font-size: 12px; }
.agente-btn[aria-current="true"] { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.agente-btn .nao-lidas { background: var(--c); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; }
.btn-icone { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--suave); }
.btn-icone:hover { background: var(--fundo); }

.corpo { display: grid; grid-template-columns: 260px 1fr; min-height: 0; }
.pastas { background: var(--painel); border-right: 1px solid var(--linha); overflow-y: auto; padding: 8px; }
.pasta {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px;
}
.pasta:hover { background: var(--fundo); }
.pasta[aria-current="true"] { background: var(--agente-suave); color: var(--agente); font-weight: 600; }
.pasta .nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pasta .nao-lidas { background: var(--agente); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }

/* ---- conversa ---- */
.conversa { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; min-width: 0; }
.conversa-topo { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--linha); background: var(--painel); }
.conversa-topo h2 { margin: 0; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voltar { display: none; }
.status { font-size: 12px; color: var(--suave); }
.status.off { color: var(--perigo); }

.mensagens { overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.dia { align-self: center; font-size: 12px; color: var(--suave); background: var(--painel); border-radius: 999px; padding: 2px 10px; margin: 10px 0 4px; }
.carregar-mais { align-self: center; font-size: 13px; color: var(--agente); padding: 6px 12px; }
.msg { max-width: min(680px, 86%); padding: 8px 12px; border-radius: var(--raio); background: var(--balao-agente);
  box-shadow: 0 1px 1px rgba(0,0,0,.05); overflow-wrap: anywhere; }
.msg.eu { align-self: flex-end; background: var(--agente-suave); border-bottom-right-radius: 4px; }
.msg.agente { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg .texto { white-space: pre-wrap; }
.msg .texto a { color: var(--agente); }
.msg .rodape { font-size: 11px; color: var(--suave); margin-top: 2px; text-align: right; }
.msg .via { margin-right: 6px; }
.msg.pendente { opacity: .6; }
.msg img.anexo { display: block; max-width: 100%; max-height: 360px; border-radius: 10px; margin-bottom: 4px; cursor: zoom-in; }
.msg audio { display: block; width: 260px; max-width: 100%; margin: 4px 0; }
.doc { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--fundo); color: inherit; text-decoration: none; margin-bottom: 4px; }
.digitando { align-self: flex-start; color: var(--suave); font-size: 13px; padding: 4px 12px; }
.vazio { margin: auto; color: var(--suave); text-align: center; }

/* ---- caixa de envio ---- */
.envio { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; background: var(--painel); border-top: 1px solid var(--linha);
  padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.envio textarea {
  flex: 1; resize: none; border: 1px solid var(--linha); border-radius: 22px; padding: 10px 16px;
  font: inherit; max-height: 160px; min-height: 44px; outline: none; background: var(--fundo);
}
.envio textarea:focus { border-color: var(--agente); background: #fff; }
.btn-redondo { width: 48px; height: 48px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--agente); color: #fff; }
.btn-redondo:disabled { opacity: .5; cursor: default; }
.mic { width: 56px; height: 56px; }
.mic.gravando { background: var(--perigo); animation: pulso 1.2s infinite; }
@keyframes pulso { 0%,100% { box-shadow: 0 0 0 0 rgba(198,40,40,.35); } 50% { box-shadow: 0 0 0 10px rgba(198,40,40,0); } }
.gravacao { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--perigo); font-variant-numeric: tabular-nums; min-height: 44px; padding: 0 8px; }
.gravacao .cancelar { color: var(--suave); text-decoration: underline; margin-left: auto; }

/* ---- login ---- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.cartao { background: var(--painel); border-radius: 16px; padding: 32px 24px; max-width: 380px; width: 100%; text-align: center; box-shadow: 0 2px 16px rgba(0,0,0,.06); }
.cartao h1 { margin: 0 0 8px; font-size: 24px; }
.cartao p { color: var(--suave); margin: 0 0 24px; }
.btn-grande { width: 100%; padding: 14px; border-radius: 12px; background: var(--agente); color: #fff; font-weight: 600; }
.btn-grande:disabled, .btn-secundario:disabled { opacity: .6; cursor: default; }
.form-senha { display: grid; gap: 10px; }
.form-senha input { width: 100%; padding: 13px 14px; border: 1px solid var(--linha); border-radius: 12px; font: inherit; font-size: 16px; outline: none; }
.form-senha input:focus { border-color: var(--agente); }
.ou { color: var(--suave); font-size: 13px; margin: 14px 0; }
.btn-secundario { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--linha); background: var(--painel); color: var(--texto); }

.aviso { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #333; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); z-index: 10; }
.zoom { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 20; cursor: zoom-out; }
.zoom img { max-width: 96vw; max-height: 96vh; }

/* ---- celular: uma coluna (pastas OU conversa) ---- */
@media (max-width: 760px) {
  .corpo { grid-template-columns: 1fr; }
  .corpo.com-conversa .pastas { display: none; }
  .corpo:not(.com-conversa) .conversa { display: none; }
  .pastas { border-right: 0; }
  .pasta { padding: 14px 12px; font-size: 16px; }
  .voltar { display: grid; }
  .agente-btn .desc { display: none; }
  .msg { max-width: 90%; }
  .envio textarea { font-size: 16px; } /* evita zoom no iPhone */
}
