/* =========================================================
   Chat Web Transcotta — interface do passageiro
   Identidade do App Transcotta: vermelho #C01F26, laranja #F07038,
   superfície #F6F4F2, Nunito Sans. Mobile-first.
========================================================= */

@font-face { font-family: 'Nunito Sans'; src: url('assets/fonts/NunitoSans-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Nunito Sans'; src: url('assets/fonts/NunitoSans-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Nunito Sans'; src: url('assets/fonts/NunitoSans-ExtraBold.ttf') format('truetype'); font-weight: 800; font-display: swap; }

:root {
  --vermelho: #c01f26;
  --vermelho-vivo: #e03a3a;
  --vermelho-escuro: #8f1014;
  --laranja: #f07038;
  --amarelo: #f9e38c;
  --tinta: #1f2328;
  --suave: #5b6270;
  --superficie: #f6f4f2;
  --linha: #e7e2de;
  --branco: #fff;
  --verde: #15803d;
  --ambar: #b45309;
  --raio: 18px;
  --sombra: 0 1px 2px rgba(31, 35, 40, .06), 0 2px 8px rgba(31, 35, 40, .05);
  --fonte: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--fonte);
  font-size: 17px;
  line-height: 1.45;
  color: var(--tinta);
  background: var(--superficie);
  -webkit-text-size-adjust: 100%;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 24px;
  height: 24px;
  flex: none;
  /* herdado pelo conteúdo do <use> (estilo no <symbol> não chega lá) */
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

:focus-visible { outline: 3px solid var(--laranja); outline-offset: 2px; }

/* ---------- estrutura ---------- */
.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--superficie);
  overflow: hidden;
}

/* ---------- cabeçalho ---------- */
.topo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top));
  color: var(--branco);
  background: linear-gradient(135deg, var(--vermelho-vivo), var(--vermelho) 55%, var(--vermelho-escuro));
  box-shadow: 0 2px 10px rgba(143, 16, 20, .25);
  z-index: 2;
}

.topo__marca {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--branco);
}

.topo__marca img { display: block; width: 38px; height: 38px; }

.topo__texto { flex: 1; min-width: 0; }

.topo__titulo {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topo__estado {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 2px 0 0;
  font-size: .9rem;
  font-weight: 700;
  opacity: .96;
}

.estado__icone {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amarelo);
}

[data-estado="online"] .estado__icone { background: #7ee2a0; box-shadow: 0 0 0 3px rgba(126, 226, 160, .3); }
[data-estado="fechado"] .estado__icone { background: transparent; border: 2px solid var(--amarelo); }
[data-estado="fila"] .estado__icone { border-radius: 2px; transform: rotate(45deg); background: var(--amarelo); }
[data-estado="atendimento"] .estado__icone { background: #7ee2a0; border-radius: 3px; }
[data-estado="encerrada"] .estado__icone { background: rgba(255, 255, 255, .55); border-radius: 2px; }

.topo__acao {
  flex: none;
  min-height: 44px;
  padding: 6px 12px;
  border: 1.5px solid rgba(255, 255, 255, .55);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: var(--branco);
  font: inherit;
  font-size: .85rem;
  font-weight: 800;
  cursor: pointer;
}

.topo__acao:hover { background: rgba(255, 255, 255, .12); }
.topo__acao:focus-visible { outline-color: var(--amarelo); }

/* ---------- homologação (só no ambiente interno) ---------- */
.homologacao {
  margin: 0;
  padding: 6px 12px;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-align: center;
  color: #1f2328;
  background: repeating-linear-gradient(135deg, #fde68a 0 14px, #fcd34d 14px 28px);
  border-bottom: 1px solid #d97706;
}

/* ---------- avisos ---------- */
.conexao {
  padding: 8px 16px;
  font-size: .92rem;
  font-weight: 700;
  text-align: center;
  color: #7c2d12;
  background: #ffedd5;
  border-bottom: 1px solid #fed7aa;
}

.conexao[data-tipo="ok"] { color: #14532d; background: #dcfce7; border-bottom-color: #bbf7d0; }

.faixa {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  background: #fff8f0;
  border-bottom: 1px solid #f6dcc3;
  font-size: .9rem;
  line-height: 1.35;
}

.faixa strong { display: block; font-weight: 800; }
.faixa .ic { width: 22px; height: 22px; color: var(--vermelho); margin-top: 1px; }
.faixa[data-tipo="fila"] { background: #fff4e5; border-bottom-color: #f8cf9f; }
.faixa[data-tipo="fila"] .ic { color: var(--ambar); }

/* ---------- conversa ---------- */
.conversa {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px 18px;
  scroll-behavior: smooth;
}

.mensagens {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { display: flex; flex-direction: column; max-width: 88%; }

.msg__balao {
  padding: 10px 14px 8px;
  border-radius: var(--raio);
  background: var(--branco);
  border: 1px solid var(--linha);
  box-shadow: var(--sombra);
  overflow-wrap: anywhere;
}

.msg__autor {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 3px;
  font-size: .8rem;
  font-weight: 800;
  color: var(--vermelho);
}

.msg__texto { margin: 0; white-space: pre-wrap; }

.msg__texto a {
  color: var(--vermelho-escuro);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
  padding: 2px 0;
}

.msg__rodape {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: .75rem;
  color: var(--suave);
}

.msg--bot, .msg--atendente { align-self: flex-start; }
.msg--bot .msg__balao { border-top-left-radius: 6px; }

.msg--atendente .msg__balao {
  border-top-left-radius: 6px;
  border-left: 4px solid var(--laranja);
}

.msg--atendente .msg__autor { color: #9a3412; }

.msg--passageiro { align-self: flex-end; }

.msg--passageiro .msg__balao {
  color: var(--branco);
  background: var(--vermelho);
  border-color: var(--vermelho);
  border-top-right-radius: 6px;
}

.msg--passageiro .msg__rodape { color: rgba(255, 255, 255, .85); }
.msg--passageiro .msg__texto a { color: var(--branco); }

.msg--passageiro[data-envio="pendente"] .msg__balao { opacity: .75; }
.msg--passageiro[data-envio="erro"] .msg__balao { background: var(--branco); color: var(--tinta); border: 1.5px dashed var(--vermelho); }
.msg--passageiro[data-envio="erro"] .msg__rodape { color: var(--vermelho); font-weight: 700; }

.msg--sistema { align-self: center; max-width: 94%; }

.msg--sistema .msg__balao {
  text-align: center;
  background: #efe9e4;
  border: none;
  box-shadow: none;
  font-size: .93rem;
  color: #3b3f46;
}

.msg--sistema .msg__rodape { justify-content: center; }

.separador {
  align-self: center;
  margin: 8px 0;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 800;
  color: var(--suave);
  background: var(--branco);
  border: 1px solid var(--linha);
}

/* ---------- menu ---------- */
.menu {
  margin-top: 12px;
  padding: 12px;
  border-radius: 20px;
  background: var(--branco);
  border: 1px solid var(--linha);
  box-shadow: var(--sombra);
}

.menu__titulo { margin: 0 0 10px; font-size: 1rem; font-weight: 800; }

.menu__grade { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.opcao {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 84px;
  padding: 11px 12px;
  border: 1.5px solid var(--linha);
  border-radius: 16px;
  background: var(--superficie);
  color: var(--tinta);
  font: inherit;
  font-size: .98rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .1s;
}

.opcao:hover { border-color: var(--vermelho); background: #fff; }
.opcao:active { transform: scale(.98); }
.opcao:disabled { opacity: .55; cursor: default; }

.opcao__icone {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--branco);
  background: var(--vermelho);
}

/* Mesmo tamanho dos demais cartões; só o destaque laranja. */
.opcao--atendente { background: #fff4ec; border-color: #fbd3b9; }
.opcao--atendente:hover { border-color: var(--laranja); background: #fff; }
.opcao--atendente .opcao__icone { background: var(--laranja); }

/* ---------- anexos ---------- */
.msg__imagem-link { display: block; margin: 2px 0 4px; }

.msg__imagem {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
  background: var(--superficie);
}

.msg__arquivo {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 2px 0 4px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--linha);
  background: var(--superficie);
  color: var(--tinta);
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.msg--passageiro .msg__arquivo { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .5); color: var(--branco); }
.msg__arquivo small { font-weight: 400; opacity: .8; }
.msg__removido { margin: 2px 0 4px; font-style: italic; opacity: .85; }

.anexo-escolhido {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--superficie);
  border: 1px solid var(--linha);
  font-size: .92rem;
  font-weight: 700;
}

.anexo-escolhido__nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.anexo-escolhido__remover {
  flex: none;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--suave);
  font-size: 1.4rem;
  cursor: pointer;
}

.compor__anexar {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 1.5px solid var(--linha);
  background: var(--superficie);
  color: var(--vermelho);
  cursor: pointer;
}

.compor__anexar[aria-pressed="true"] { background: #fdecec; border-color: #f3c3c5; }

/* ---------- pesquisa de satisfação ---------- */
.pesquisa {
  margin-top: 12px;
  padding: 16px;
  border-radius: 20px;
  background: var(--branco);
  border: 1px solid var(--linha);
  box-shadow: var(--sombra);
}

.pesquisa__titulo { margin: 0 0 10px; font-size: 1.05rem; font-weight: 800; }
.pesquisa__notas { display: grid; gap: 8px; margin-bottom: 12px; }

.nota {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1.5px solid var(--linha);
  border-radius: 14px;
  background: var(--superficie);
  color: var(--tinta);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.nota__numero {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--branco);
  border: 1.5px solid var(--linha);
  font-weight: 800;
}

.nota[aria-checked="true"] { border-color: var(--vermelho); background: #fdecec; }
.nota[aria-checked="true"] .nota__numero { background: var(--vermelho); border-color: var(--vermelho); color: var(--branco); }

.pesquisa__rotulo { display: block; margin: 0 0 4px; font-size: .92rem; font-weight: 700; color: var(--suave); }

.pesquisa__comentario {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--linha);
  border-radius: 14px;
  background: var(--superficie);
  color: var(--tinta);
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}

.pesquisa__acoes { display: flex; gap: 10px; margin-top: 12px; }
.pesquisa__acoes .btn { flex: 1; }
.pesquisa__acoes .btn:disabled { opacity: .5; cursor: default; }

.pesquisa-obrigado {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #dcfce7;
  color: #14532d;
  font-weight: 800;
  text-align: center;
}

/* ---------- entrada direta fora do horário ---------- */
.indisponivel {
  margin-top: 12px;
  padding: 16px;
  border-radius: 20px;
  background: var(--branco);
  border: 1px solid var(--linha);
  box-shadow: var(--sombra);
}

.indisponivel__titulo { margin: 0 0 6px; font-size: 1.05rem; font-weight: 800; }
.indisponivel__texto { margin: 0 0 14px; color: var(--suave); }

/* ---------- novas mensagens ---------- */
.novas {
  position: absolute;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: var(--tinta);
  color: var(--branco);
  font: inherit;
  font-size: .9rem;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
  cursor: pointer;
  z-index: 3;
}

.novas .ic { width: 18px; height: 18px; }

/* ---------- rodapé ---------- */
.rodape {
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--branco);
  border-top: 1px solid var(--linha);
}

.compor { display: flex; align-items: flex-end; gap: 8px; }

.compor textarea {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  max-height: 140px;
  padding: 12px 14px;
  border: 1.5px solid var(--linha);
  border-radius: 16px;
  background: var(--superficie);
  color: var(--tinta);
  font: inherit;
  font-size: 1rem;
  line-height: 1.35;
  resize: none;
}

.compor textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #6b7280; }

.compor textarea:focus { border-color: var(--vermelho); background: var(--branco); outline: none; box-shadow: 0 0 0 3px rgba(192, 31, 38, .15); }
.compor textarea:disabled { opacity: .6; }

.compor__enviar, .compor__menu {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 48px;
  height: 48px;
  border-radius: 16px;
  border: none;
  font: inherit;
  cursor: pointer;
}

.compor__enviar { background: var(--vermelho); color: var(--branco); }
.compor__enviar:hover { background: var(--vermelho-escuro); }
.compor__enviar:disabled { background: #d9d4d0; cursor: default; }

.compor__menu {
  display: flex;
  gap: 4px;
  padding: 0 10px;
  background: var(--superficie);
  color: var(--vermelho);
  border: 1.5px solid var(--linha);
  font-size: .85rem;
  font-weight: 800;
}

.compor__menu[aria-expanded="true"] { background: #fdecec; border-color: #f3c3c5; }

.contador { margin: 6px 4px 0; font-size: .8rem; color: var(--suave); text-align: right; }

.encerrado { text-align: center; padding: 4px 0 2px; }
.encerrado p { margin: 0 0 10px; font-weight: 700; color: var(--suave); }

/* ---------- botões ---------- */
.btn {
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--linha);
  background: var(--branco);
  color: var(--tinta);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.btn--primario { width: 100%; border: none; background: var(--vermelho); color: var(--branco); }
.btn--primario:hover { background: var(--vermelho-escuro); }
.btn--perigo { border: none; background: var(--vermelho); color: var(--branco); }

/* ---------- telas (sessão expirada etc.) ---------- */
.tela {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(246, 244, 242, .97);
  z-index: 5;
}

.tela__cartao {
  width: 100%;
  max-width: 380px;
  padding: 28px 22px;
  border-radius: 22px;
  text-align: center;
  background: var(--branco);
  border: 1px solid var(--linha);
  box-shadow: var(--sombra);
}

.tela__cartao h2 { margin: 12px 0 6px; font-size: 1.2rem; font-weight: 800; }
.tela__cartao p { margin: 0 0 18px; color: var(--suave); }

/* ---------- diálogo ---------- */
.dialogo {
  width: min(92vw, 380px);
  padding: 22px;
  border: none;
  border-radius: 22px;
  color: var(--tinta);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.dialogo::backdrop { background: rgba(31, 35, 40, .5); }
.dialogo h2 { margin: 0 0 6px; font-size: 1.15rem; font-weight: 800; }
.dialogo p { margin: 0 0 18px; color: var(--suave); }
.dialogo__acoes { display: flex; flex-direction: column-reverse; gap: 10px; }
.dialogo__acoes .btn { width: 100%; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: min(92vw, 480px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--tinta);
  color: var(--branco);
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  z-index: 10;
}

/* ---------- telas maiores: coluna central tipo aplicativo ---------- */
@media (min-width: 600px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    background: var(--superficie) linear-gradient(160deg, var(--vermelho-vivo), var(--vermelho) 45%, var(--vermelho-escuro)) no-repeat;
    background-size: 100% 240px;
  }

  .app {
    width: 100%;
    height: min(880px, calc(100dvh - 48px));
    margin: 0;
    border-radius: 26px;
    box-shadow: 0 18px 50px rgba(31, 35, 40, .2);
  }

  .topo { border-radius: 26px 26px 0 0; }
  .homologacao { border-radius: 26px 26px 0 0; }
  .homologacao:not([hidden]) + .topo { border-radius: 0; }
  .msg { max-width: 78%; }
  .menu__grade { grid-template-columns: repeat(3, 1fr); }
  .opcao { min-height: 96px; }
}

@media (min-width: 600px) and (max-height: 640px) {
  .app { height: 100dvh; border-radius: 0; }
  .topo, .homologacao { border-radius: 0; }
}

@media (max-width: 359px) {
  body { font-size: 16px; }
  .topo { gap: 10px; padding-left: 10px; padding-right: 10px; }
  .topo__marca { width: 42px; height: 42px; }
  .topo__marca img { width: 32px; height: 32px; }
  .topo__titulo { font-size: 1.02rem; }
  .topo__estado { font-size: .82rem; }
  .topo__acao { padding: 6px 10px; font-size: .8rem; }
  .opcao { min-height: 78px; font-size: .92rem; padding: 10px; gap: 6px; }
  .opcao__icone { width: 34px; height: 34px; }
  .compor__menu span { display: none; }
}

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

@media (forced-colors: active) {
  .estado__icone { border: 2px solid CanvasText; }
}
