/* ====== ESTILO CHAT IA TÔ AÍ ====== */

/* Garantir que nada gere scroll lateral por causa do chat */
html, body {
  overflow-x: hidden;
}

/* WIDGET GERAL */
#toai-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 100vw;
}

/* BOTÃO FLUTUANTE */
#toai-chat-toggle {
  background: #5c2ea3; /* roxo Tô Aí */
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease-out;
}

#toai-chat-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.20);
}

/* CAIXA DO CHAT */
#toai-chat-box {
  width: 320px;          /* largura desktop */
  max-width: 90vw;       /* nunca passa da largura da tela */
  max-height: 550px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  display: none;         /* começa fechado */
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 8px;
}

/* CABEÇALHO */
#toai-chat-header {
  background: linear-gradient(135deg, #5c2ea3, #3d1f70);
  color: #ffffff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toai-chat-title {
  display: flex;
  flex-direction: column;
}

.toai-chat-title strong {
  font-size: 14px;
}

.toai-chat-title span {
  font-size: 11px;
  opacity: 0.8;
}

#toai-chat-close {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
}

/* ÁREA DE MENSAGENS */
#toai-chat-messages {
  padding: 10px;
  background: #f5f5f9;
  flex: 1;
  overflow-y: auto;
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: anywhere;   /* impede links e textos longos de estourar a largura */
}

.msg {
  max-width: 90%;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 6px;
  line-height: 1.4;
}

/* Mensagens da IA */
.msg.bot {
  background: #f5f5f9;
  color: #222222;
  border-radius: 12px 12px 12px 2px;
  border: 1px solid #ddd;
}

/* Mensagens do usuário */
.msg.user {
  background: #5c2ea3;
  color: #ffffff;
  border-radius: 12px 12px 2px 12px;
  margin-left: auto;
}

/* LINKS AZUIS NO CHAT */
#toai-chat-messages a {
  color: #007bff !important;
  text-decoration: underline;
}

#toai-chat-messages a:hover {
  color: #0056b3 !important;
}

/* INPUT E BOTÃO ENVIAR */
#toai-chat-input-area {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid #e0dff0;
  background: #ffffff;
  width: 100%;
  box-sizing: border-box;
}

#toai-chat-input {
  flex: 1;
  min-width: 0;              /* ESSENCIAL para não estourar no mobile */
  border-radius: 999px;
  border: 1px solid #ddd;
  padding: 8px 12px;
  font-size: 13px;
}

#toai-chat-input:focus {
  outline: none;
  border-color: #5c2ea3;
}

#toai-chat-send {
  background: #b6ff3b; /* verde limão Tô Aí */
  border: none;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

/* Mensagem de carregando */
.msg.loading {
  font-style: italic;
  opacity: 0.7;
}

/* ===== RESPONSIVO – CELULAR ===== */
@media (max-width: 600px) {

  /* Widget ocupa o rodapé inteiro, centralizado */
  #toai-chat-widget {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    align-items: center;
  }

  /* Caixa do chat 100% da largura, com margens internas */
  #toai-chat-box {
    width: calc(100% - 20px) !important;  /* 10px de cada lado */
    max-width: 480px;
    margin: 0 auto 8px auto;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    max-height: 75vh;
    overflow: hidden;
  }

  #toai-chat-messages {
    padding: 14px;
    font-size: 15px;
    line-height: 1.55;
  }

  #toai-chat-input-area {
    padding: 8px;
    gap: 6px;
    width: 100%;
  }

  #toai-chat-input {
    padding: 10px 14px;
    font-size: 15px;
  }

  #toai-chat-send {
    padding: 0 16px;
    font-size: 14px;
  }

  /* Botão “Falar com a Tô Aí” largo e centralizado */
  #toai-chat-toggle {
    width: calc(100% - 20px);
    max-width: 480px;
    margin: 0 auto 12px auto;
    border-radius: 30px;
    padding: 14px;
    font-size: 16px;
    justify-content: center;
    text-align: center;
  }
}
