/* Painel de chat do Max. Interface nossa; o Chatwoot continua a ser o motor.
   Regras da casa: dourado #C9A227 sobre preto, texto quente, cantos suaves. */

#max-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 2147483001;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #111010;
  border: 1px solid rgba(201, 162, 39, .28);
  border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(224, 185, 58, .12), 0 24px 60px rgba(0, 0, 0, .55);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #e8e2d4;
  opacity: 0;
  transform: translateY(12px) scale(.98);
  transition: opacity .18s ease, transform .18s ease;
}
/* O atributo hidden tem de ganhar do display:flex acima, senão o painel fica
   sempre no ecrã, invisível, a apanhar os toques. Foi o que impediu o botão de
   funcionar no telemóvel (2026-09-24). */
#max-panel[hidden] { display: none !important; }
#max-panel:not([data-aberto="1"]) { pointer-events: none; }
#max-panel[data-aberto="1"] { opacity: 1; transform: none; pointer-events: auto; }

#max-panel header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: linear-gradient(180deg, rgba(201, 162, 39, .12), transparent);
}
#max-panel header img { width: 36px; height: 36px; border-radius: 50%; background: #1b1a18; object-fit: contain; }
#max-panel header .max-quem { flex: 1; min-width: 0; }
#max-panel header strong { display: block; font-size: 15px; font-weight: 600; color: #f3efe6; }
#max-panel header span { display: block; font-size: 12.5px; color: #a79f8c; }
#max-panel header button {
  border: 0; background: transparent; color: #a79f8c; cursor: pointer;
  font-size: 22px; line-height: 1; padding: 4px 6px; border-radius: 8px;
}
#max-panel header button:hover { color: #f3efe6; background: rgba(255, 255, 255, .06); }

#max-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
#max-msgs::-webkit-scrollbar { width: 8px; }
#max-msgs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 8px; }

.max-bolha {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: max-entra .18s ease;
}
.max-bolha a { color: #E0B93A; }
.max-de-max { align-self: flex-start; background: #1c1b19; border: 1px solid rgba(255, 255, 255, .06); border-bottom-left-radius: 6px; }
.max-de-mim { align-self: flex-end; background: linear-gradient(180deg, #E0B93A, #C9A227); color: #14120c; border-bottom-right-radius: 6px; }
.max-erro { align-self: center; text-align: center; font-size: 13.5px; color: #e8b4b4; background: rgba(180, 60, 60, .12); border: 1px solid rgba(180, 60, 60, .3); }

@keyframes max-entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

#max-escrevendo { align-self: flex-start; display: none; gap: 5px; padding: 13px 14px; background: #1c1b19; border-radius: 16px; border-bottom-left-radius: 6px; }
#max-escrevendo[data-on="1"] { display: flex; }
#max-escrevendo i { width: 7px; height: 7px; border-radius: 50%; background: #8d8676; animation: max-pisca 1.2s infinite; }
#max-escrevendo i:nth-child(2) { animation-delay: .18s; }
#max-escrevendo i:nth-child(3) { animation-delay: .36s; }
@keyframes max-pisca { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }

#max-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(255, 255, 255, .06); }
#max-form input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .1); background: #1a1917; color: #e8e2d4;
  font: inherit;
}
#max-form input:focus { outline: none; border-color: rgba(201, 162, 39, .6); }
#max-form button {
  border: 0; border-radius: 12px; padding: 0 16px; cursor: pointer;
  background: linear-gradient(180deg, #E0B93A, #C9A227); color: #14120c; font: 600 15px/1 inherit;
}
#max-form button:disabled { opacity: .5; cursor: default; }

#max-dica { margin: auto 0; text-align: center; color: #7d7767; font-size: 13.5px; padding: 0 12px; }

#max-rodape { padding: 0 12px 12px; text-align: center; font-size: 11.5px; color: #7d7767; }
#max-rodape .max-rgpd { display: block; margin-top: 3px; font-size: 10.5px; color: #6b6557; line-height: 1.4; }
#max-rodape a { color: #9a927c; text-decoration: none; }
#max-rodape a:hover { color: #C9A227; }

#max-nao-lidas {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px;
  border-radius: 999px; background: #d64545; color: #fff;
  font: 700 12px/20px system-ui, sans-serif; text-align: center; padding: 0 5px;
}

@media (max-width: 520px) {
  #max-panel {
    right: 0; bottom: 0; width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #max-panel, .max-bolha { transition: none; animation: none; }
}

/* Botão que abre o painel. Dourado para chamar a atenção, com brilho à volta
   (não sombra por baixo) e ícone de balão para não deixar dúvida. */
#max-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #E0B93A 0%, #C9A227 100%);
  color: #0d0d0d; cursor: pointer;
  font: 600 15px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 0 0 1px rgba(224,185,58,.35), 0 0 18px rgba(201,162,39,.45), 0 0 44px rgba(201,162,39,.22);
  transition: transform .15s ease, box-shadow .15s ease;
}
#max-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px rgba(224,185,58,.6), 0 0 24px rgba(201,162,39,.6), 0 0 60px rgba(201,162,39,.35);
}
#max-launcher svg { display: block; }
@media (max-width: 520px) {
  /* Esconde o rótulo, nunca o contador: ambos são span dentro do botão, e a
     regra antiga apagava o contador no telemóvel (2026-09-24). */
  #max-launcher span:not(#max-nao-lidas) { display: none; }
  #max-launcher { padding: 16px; }
}

/* Cartão de marcação dentro da conversa. Aparece por baixo da mensagem em que o
   Max manda o link da agenda, e nunca substitui o link: se isto falhar, o link
   continua a fechar o funil. */
.max-agenda {
  align-self: flex-start;
  max-width: 92%;
  margin: -2px 0 2px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #16150f;
  border: 1px solid rgba(201, 162, 39, .3);
  animation: max-entra .18s ease;
}
.max-agenda-titulo { margin: 0 0 8px; font-size: 12.5px; color: #a79f8c; }
.max-agenda-corpo { font-size: 13.5px; color: #9a927c; }

.max-agenda-dia { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.max-agenda-dia > span {
  flex: 0 0 100%; font-size: 11.5px; color: #7d7767;
  letter-spacing: .02em;
}
.max-agenda-dia button {
  border: 1px solid rgba(201, 162, 39, .35);
  background: rgba(201, 162, 39, .08);
  color: #E0B93A;
  border-radius: 9px; padding: 7px 11px; cursor: pointer;
  font: 600 13px/1 inherit; font-variant-numeric: tabular-nums;
}
.max-agenda-dia button:hover { background: rgba(201, 162, 39, .2); color: #f3efe6; }

.max-agenda-escolhido {
  margin: 0 0 8px; color: #e8e2d4; font-size: 13.5px; font-weight: 600;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.max-agenda form { display: flex; flex-direction: column; gap: 7px; }
.max-agenda input {
  padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 13.5px;
  border: 1px solid rgba(255, 255, 255, .12); background: #1a1917; color: #e8e2d4;
}
.max-agenda input:focus { outline: none; border-color: rgba(201, 162, 39, .6); }
.max-agenda form button {
  border: 0; border-radius: 10px; padding: 10px; cursor: pointer;
  background: linear-gradient(180deg, #E0B93A, #C9A227); color: #14120c;
  font: 600 14px/1 inherit;
}
.max-agenda form button:disabled { opacity: .55; cursor: default; }
.max-agenda-erro { margin: 8px 0 0; font-size: 12.5px; color: #e8b4b4; }
.max-agenda-ok { margin: 0; font-size: 13.5px; color: #9fd0a0; }

@media (max-width: 520px) {
  .max-agenda { max-width: 100%; }
  .max-agenda-dia button { padding: 9px 12px; }   /* alvo de toque maior */
}

/* Saída para quem não quiser marcar aqui. Fica no fim do cartão, não no meio da
   conversa: o link cru entre balões é feio e rouba a atenção do que interessa. */
.max-agenda-alternativa { margin: 10px 0 0; font-size: 12px; color: #7d7767; }
.max-agenda-alternativa a { color: #9a927c; }
.max-agenda-alternativa a:hover { color: #C9A227; }

.max-agenda-mais {
  border: 0; background: none; color: #9a927c; cursor: pointer;
  font: 600 12.5px/1 inherit; padding: 6px 2px; text-decoration: underline;
}
.max-agenda-mais:hover { color: #E0B93A; }

/* O botão de marcar a trabalhar. Uma espera de segundos sem sinal nenhum
   parece avaria, e a pessoa carrega outra vez. */
.max-agenda form button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.max-girar {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(20, 18, 12, .25);
  border-top-color: #14120c;
  animation: max-rodar .7s linear infinite;
}
@keyframes max-rodar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .max-girar { animation: none; opacity: .5; }
}

/* Voltar aos horários. Carregar na hora errada não pode ser um beco. */
.max-agenda-voltar {
  border: 0; background: none; color: #9a927c; cursor: pointer;
  font: 500 12px/1 inherit; text-decoration: underline; padding: 2px 4px;
  vertical-align: baseline;
}
.max-agenda-voltar:hover { color: #E0B93A; }
