/* Versão: 2.1.0 - BTOS AI Assistant (DNA Edition)
   Foco: Refinamento orgânico, correção de contraste e erradicação de bordas duras. 
   Dimensões originais preservadas conforme solicitado. */

.chatbot-container {
  position: fixed;
  z-index: 1080;
  right: 20px;
  bottom: 40px;
}

.chatbot-toggle-button {
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 45px;
  height: 45px;
  padding: 0;
  border: none;
  border-radius: 50%;

  background-color: transparent;
  box-shadow: var(--shadow-dna-md);

  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#rhafael-avatar-icon {
  width: 100%;
  height: 100%;
  border: 2px solid var(--color-primary-bs);
  border-radius: 50%;

  object-fit: cover;
}

.chatbot-toggle-button:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: var(--shadow-dna-lg);
}

.chatbot-window {
  position: absolute;
  right: 0;
  bottom: 65px;

  overflow: hidden;
  display: none;
  flex-direction: column;

  width: 400px; /* Dimensão preservada */
  height: 600px; /* Dimensão preservada */
  border: 1px solid rgb(0 0 0 / 8%);
  border-radius: 24px; /* Evolução do "quadrado" para o DNA BTOS */

  background-color: #fff;
  box-shadow: var(--shadow-dna-xl);

  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chatbot-window.chatbot-window-large {
  width: 480px; /* Dimensão preservada */
  height: 680px; /* Dimensão preservada */
}

.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 1.2rem;
  border-bottom: 1px solid rgb(0 0 0 / 5%);

  background-color: rgb(255 255 255 / 90%);
  backdrop-filter: blur(10px);
}

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.chatbot-header h5 {
  margin: 0;

  font-family: var(--font-family-headings);
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
}

.chatbot-header-secondary-button {
  cursor: pointer;

  padding: 0.4rem 0.75rem;
  border: 1px solid rgb(0 0 0 / 8%);
  border-radius: 999px;

  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;

  background: #fff;

  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.chatbot-header-secondary-button:hover {
  border-color: rgb(19 50 188 / 18%);
  color: var(--color-primary-bs);
  background: #f8faff;
}

#chatbot-close-button {
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;

  color: #666;

  background: #f0f0f2;

  transition: background 0.2s;
}

#chatbot-close-button:hover {
  background: #e5e5e7;
}

.chatbot-messages {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 1rem;

  padding: 1.2rem;

  background-color: #fff;
}

.message {
  max-width: 85%;
  padding: 0.85rem 1.1rem;

  font-size: 0.95rem;
  line-height: 1.5;
  overflow-wrap: break-word;

  box-shadow: var(--shadow-dna-sm);
}

.message.user {
  align-self: flex-end;
  border-radius: 18px 18px 4px; /* Curva orgânica assimétrica */
  color: #fff !important; /* Correção: Garantir branco no fundo azul */
  background: linear-gradient(135deg, var(--color-primary-bs) 0%, #0d4db8 100%);
}

.message.model {
  align-self: flex-start;

  border: 1px solid rgb(0 0 0 / 3%);
  border-radius: 18px 18px 18px 4px; /* Curva orgânica assimétrica */

  color: #1a1a1a;

  background-color: #f2f2f7;
}

.chatbot-input-form {
  display: flex;
  gap: 0.8rem;

  padding: 1.2rem;
  border-top: 1px solid rgb(0 0 0 / 5%);

  background-color: #fff;
}

.chatbot-input-form input {
  flex-grow: 1;

  padding: 0.7rem 1rem;
  border: 1.5px solid #e5e5e7;
  border-radius: 12px;

  font-size: 0.95rem;
  color: #1a1a1a !important; /* Correção: Texto escuro para contraste total no fundo branco */

  background-color: #f9f9fb;

  transition: border-color 0.2s;
}

.chatbot-input-form input:focus {
  border-color: var(--color-primary-bs);
  background-color: #fff;
  outline: none;
}

.chatbot-input-form button {
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;

  background-color: var(--color-primary-bs);

  transition: transform 0.2s;
}

.chatbot-input-form button:hover:not(:disabled) {
  transform: scale(1.05);
}

/* --- Chat Proativo --- */
.proactive-chat-container {
  position: fixed;
  z-index: 1085;
  inset: 0;

  display: none;
  align-items: flex-end;
  justify-content: flex-end;
}

.proactive-chat-container.visible {
  display: flex;
}

.proactive-chat-backdrop {
  position: absolute;
  inset: 0;

  background-color: rgb(0 0 0 / 30%);
  backdrop-filter: blur(4px);

  animation: fade-in 0.4s ease;
}

.proactive-chat-box {
  position: relative;

  width: 380px;
  max-width: 90vw;
  margin: 20px;
  margin-bottom: 105px;
  padding: 2.2rem;
  border: 1px solid rgb(0 0 0 / 5%);
  border-radius: 24px;

  background-color: #fff;
  box-shadow: var(--shadow-dna-xl);

  animation: slide-up 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

#proactive-chat-content h5 {
  margin-bottom: 1rem;
  font-family: var(--font-family-headings);
  font-weight: 800;
  color: #1a1a1a;
}

.proactive-chat-actions {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

/* --- Spinner & Animações DNA --- */
.btos-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgb(19 50 188 / 10%);
  border-top: 2px solid var(--color-primary-bs);
  border-radius: 50%;

  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.typing-cursor {
  display: inline-block;

  width: 6px;
  height: 1.1rem;
  margin-left: 4px;

  vertical-align: middle;

  background-color: var(--color-primary-bs);

  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 0;
  }

  50% {
    opacity: 1;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slide-up {
  from {
    transform: translateY(40px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Responsividade Mobile (Surgical Fix) --- */
@media (width <= 576px) {
  .chatbot-window,
  .chatbot-window.chatbot-window-large {
    position: fixed; /* Fixa na viewport para controle total */
    right: 16px;
    bottom: 100px; /* Acima do botão flutuante */
    left: 16px; /* Centraliza com margens laterais */

    width: auto; /* Remove largura fixa */
    height: 65vh; /* Altura confortável (65% da tela) */
    max-height: 600px;
    border-radius: 20px;
  }

  .chatbot-header-secondary-button {
    padding-inline: 0.65rem;
    font-size: 0.74rem;
  }
}
