#chat-widget * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
}

/* ── Botão flutuante ── */
#chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a0522d, #6B3410);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 26px;
  z-index: 9998;
  box-shadow: 0 4px 20px rgba(139, 69, 19, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

#chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(139, 69, 19, 0.55);
}

/* Indicador online */
#chat-fab::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid #fff;
}

#chat-fab.aberto::after {
  display: none;
}

/* ── Janela do chat ── */
#chat-janela {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 370px;
  max-height: 560px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#chat-janela.aberto {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Cabeçalho ── */
#chat-header {
  background: linear-gradient(135deg, #a0522d, #6B3410);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#chat-header .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

#chat-header .info .nome {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

#chat-header .info .status {
  font-size: 11px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

#chat-header .info .status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

#chat-header-btns {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

#chat-menu-btn,
#chat-fechar {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  padding: 5px 9px;
  transition: background 0.15s;
}

#chat-menu-btn:hover,
#chat-fechar:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ── Área de mensagens ── */
#chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #faf8f5;
  scrollbar-width: thin;
  scrollbar-color: #d4b896 transparent;
}

/* Separador de data */
.data-sep {
  text-align: center;
  font-size: 11px;
  color: #b8a090;
  margin: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-sep::before,
.data-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #ecddd0;
}

/* ── Bolhas ── */
.bolha-wrap {
  display: flex;
  flex-direction: column;
}

.bolha-wrap.usuario {
  align-items: flex-end;
}

.bolha-wrap.bot {
  align-items: flex-start;
}

.bolha-inner {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.bolha-wrap.usuario .bolha-inner {
  flex-direction: row-reverse;
}

.mini-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a0522d, #6B3410);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.bolha {
  max-width: 80%;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}

.bolha-wrap.bot .bolha {
  background: #fff;
  color: #2d1a0e;
  border: 1px solid #ead9c6;
  border-radius: 4px 18px 18px 18px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.bolha-wrap.usuario .bolha {
  background: linear-gradient(135deg, #a0522d, #7a3d1e);
  color: #fff;
  border-radius: 18px 4px 18px 18px;
  box-shadow: 0 2px 8px rgba(139, 69, 19, 0.3);
}

.hora {
  font-size: 10px;
  color: #b8a090;
  margin-top: 4px;
  padding: 0 4px;
}

/* ── Animação de digitando ── */
.digitando {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 15px;
  background: #fff;
  border: 1px solid #ead9c6;
  border-radius: 4px 18px 18px 18px;
  width: fit-content;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.digitando span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a0522d;
  opacity: 0.4;
  animation: pulsa 1.2s infinite;
}

.digitando span:nth-child(2) { animation-delay: 0.2s; }
.digitando span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulsa {
  0%, 60%, 100% { opacity: 0.4; transform: scale(1); }
  30%            { opacity: 1;   transform: scale(1.3); }
}

/* ── Menu de opções rápidas ── */
#chat-menu {
  background: #fff;
  border-top: 1px solid #ead9c6;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

#chat-menu.escondido {
  display: none;
}

.menu-item {
  background: #faf8f5;
  border: 1px solid #ddd0be;
  color: #5c3010;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
}

.menu-item:hover {
  background: #8B4513;
  color: #fff;
  border-color: #8B4513;
  transform: translateY(-1px);
}

.menu-item .icone {
  font-size: 16px;
}

/* ── Rodapé / input ── */
#chat-footer {
  border-top: 1px solid #ead9c6;
  background: #fff;
}

#chat-voltar-menu {
  width: 100%;
  background: #fdf6f0;
  border: none;
  border-bottom: 1px solid #ead9c6;
  color: #8B4513;
  font-size: 12px;
  cursor: pointer;
  padding: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s;
}

#chat-voltar-menu:hover {
  background: #f5e8dc;
}

#chat-input-area {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
}

#chat-input {
  flex: 1;
  border: 1.5px solid #ddd0be;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13px;
  color: #2d1a0e;
  background: #faf8f5;
  outline: none;
  resize: none;
  transition: border-color 0.2s;
}

#chat-input:focus {
  border-color: #a0522d;
}

#chat-enviar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a0522d, #6B3410);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  align-self: flex-end;
  box-shadow: 0 2px 8px rgba(139, 69, 19, 0.35);
}

#chat-enviar:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(139, 69, 19, 0.45);
}

#chat-enviar:active  { transform: scale(0.93); }
#chat-enviar:disabled {
  background: #ccc;
  box-shadow: none;
  cursor: not-allowed;
}

/* ── Modo Escuro ── */
body.dark-mode #chat-janela {
  background: #1a1008;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

body.dark-mode #chat-msgs {
  background: #120b04;
  scrollbar-color: #5c3010 transparent;
}

body.dark-mode .data-sep {
  color: #7a5c40;
}

body.dark-mode .data-sep::before,
body.dark-mode .data-sep::after {
  background: #3a2010;
}

body.dark-mode .bolha-wrap.bot .bolha {
  background: #2a1608;
  color: #f0dcc8;
  border-color: #4a2a10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .bolha-wrap.usuario .bolha {
  background: linear-gradient(135deg, #7a3d1e, #5c2e10);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

body.dark-mode .hora {
  color: #7a5c40;
}

body.dark-mode .digitando {
  background: #2a1608;
  border-color: #4a2a10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode #chat-menu {
  background: #1a1008;
  border-top-color: #3a2010;
}

body.dark-mode .menu-item {
  background: #2a1608;
  border-color: #4a2a10;
  color: #d4a070;
}

body.dark-mode .menu-item:hover {
  background: #a0522d;
  color: #fff;
  border-color: #a0522d;
}

body.dark-mode #chat-footer {
  background: #1a1008;
  border-top-color: #3a2010;
}

body.dark-mode #chat-voltar-menu {
  background: #1a1008;
  border-bottom-color: #3a2010;
  color: #c07840;
}

body.dark-mode #chat-voltar-menu:hover {
  background: #2a1608;
}

body.dark-mode #chat-input {
  background: #2a1608;
  border-color: #4a2a10;
  color: #f0dcc8;
}

body.dark-mode #chat-input::placeholder {
  color: #7a5c40;
}

body.dark-mode #chat-input:focus {
  border-color: #a0522d;
}

/* ── Responsivo ── */
@media (max-width: 420px) {
  #chat-janela {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 86px;
  }

  #chat-fab {
    bottom: 16px;
    right: 16px;
  }

  #chat-menu {
    grid-template-columns: 1fr 1fr;
  }
}