/* Chat Overlay Styles */

.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(52, 52, 63, 0.95);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

.chat-overlay.active {
  opacity: 1;
  visibility: visible;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}

/* Prevenir scroll do body quando chat estiver ativo */
body.chat-active {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
}

.chat-container {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  border-radius: 0;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(20px);
  transition: all 0.3s ease;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-overlay.active .chat-container {
  transform: scale(1) translateY(0);
}

/* Chat Header */
.chat-header {
  background: linear-gradient(
    135deg,
    rgba(251, 61, 40, 0.1),
    rgba(255, 120, 81, 0.1)
  );
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.chat-avatar {
  display: none;
}

.chat-avatar svg {
  width: 100%;
  height: 100%;
}

.chat-title {
  color: var(--light-gray);
}

.chat-title h3 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.chat-title p {
  font-size: 0.9rem;
  color: rgba(237, 231, 231, 0.7);
  margin: 0 0 6px 0;
}

.chat-status {
  color: rgba(237, 231, 231, 0.6);
  font-size: 0.8rem;
  font-style: italic;
  line-height: 1.4;
  margin-top: 4px;
}

.chat-close {
  background: none;
  border: none;
  color: var(--light-gray);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-close:hover {
  background: rgba(251, 61, 40, 0.1);
  color: var(--red);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(251, 61, 40, 0.3);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(251, 61, 40, 0.5);
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message.bot .message-avatar {
  background: transparent;
  padding: 0;
}

.message.bot .message-avatar svg {
  width: 100%;
  height: 100%;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--red), var(--orange));
  color: white;
  font-size: 1.2rem;
  font-weight: 600;
}

.message-content {
  background: rgba(255, 255, 255, 0.05);
  padding: 16px 20px;
  border-radius: 16px;
  max-width: 450px;
  width: fit-content;
  color: var(--light-gray);
  font-size: 0.95rem;
  line-height: 1.5;
  border: 1px solid rgba(255, 255, 255, 0.08);
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: keep-all;
  hyphens: none;
  white-space: normal;
}

/* Estilização para quebras de linha nas mensagens */
.message-content br {
  display: block;
  margin: 8px 0;
  content: "";
}

/* Espaçamento adicional para parágrafos separados */
.message-content br + br {
  margin-top: 12px;
}

/* Melhor espaçamento para múltiplas quebras de linha */
.message-content br + br + br {
  margin-top: 16px;
}

/* Aumentar largura das mensagens do bot em telas maiores */
@media (min-width: 1024px) {
  .message-content {
    max-width: 600px;
  }
  
  /* Melhor espaçamento para quebras de linha em telas maiores */
  .message-content br {
    margin: 10px 0;
  }
  
  .message-content br + br {
    margin-top: 15px;
  }
}

@media (min-width: 1440px) {
  .message-content {
    max-width: 700px;
  }
  
  .message-content br {
    margin: 12px 0;
  }
  
  .message-content br + br {
    margin-top: 18px;
  }
}

@media (min-width: 1920px) {
  .message-content {
    max-width: 800px;
  }
  
  .message-content br {
    margin: 14px 0;
  }
  
  .message-content br + br {
    margin-top: 20px;
  }
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--red), var(--orange));
  color: white;
  border: none;
}

.message.bot .message-content {
  background: rgba(255, 255, 255, 0.05);
  word-break: keep-all;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: none;
  white-space: normal;
}
/* Highlighted text styling for **text** format */
.message-content .highlighted {
  background: linear-gradient(135deg, rgba(251, 61, 40, 0.2), rgba(255, 120, 81, 0.2));
  color: var(--light-gray);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(251, 61, 40, 0.3);
  font-weight: 500;
  display: inline-block;
  margin: 0 1px;
}

.message.user .message-content .highlighted {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}
.message-time {
  font-size: 0.8rem;
  color: rgba(237, 231, 231, 0.5);
  margin-top: 8px;
  text-align: right;
}

.message.user .message-time {
  text-align: left;
}

/* Chat Input */
.chat-input-container {
  padding: 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

.chat-terms-notice {
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.chat-terms-notice p {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(237, 231, 231, 0.7);
  text-align: center;
  line-height: 1.4;
}

.chat-terms-notice a {
  color: var(--red);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
}

.chat-terms-notice a:hover {
  color: var(--orange);
  text-decoration: underline;
}

.chat-input-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px 18px;
  color: var(--light-gray);
  font-family: "Montserrat", sans-serif;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  min-height: 50px;
  transition: all 0.3s ease;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.chat-input::-webkit-scrollbar {
  display: none; /* WebKit */
}

.chat-input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(251, 61, 40, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

.chat-input::placeholder {
  color: rgba(237, 231, 231, 0.5);
}

.chat-send {
  background: var(--red);
  border: none;
  border-radius: 12px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chat-send:hover {
  background: #e6352a;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(251, 61, 40, 0.3);
}

.chat-send:active {
  transform: translateY(0);
}

.chat-send:disabled {
  background: rgba(251, 61, 40, 0.5);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Character Counter */
.chat-character-counter {
  text-align: right;
  font-size: 0.75rem;
  color: rgba(237, 231, 231, 0.5);
  margin-top: 8px;
  transition: color 0.3s ease;
}

.chat-character-counter.warning {
  color: #ff9800;
}

.chat-character-counter.danger {
  color: var(--red);
  font-weight: 500;
}

.chat-character-counter.waiting {
  color: #2196F3;
  font-weight: 500;
  animation: pulse-waiting 1.5s infinite;
}

@keyframes pulse-waiting {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  max-width: 450px;
  width: fit-content;
  align-self: flex-start;
  margin-bottom: 20px;
}

/* Aumentar largura do indicador de digitação em telas maiores */
@media (min-width: 1024px) {
  .typing-indicator {
    max-width: 600px;
  }
}

@media (min-width: 1440px) {
  .typing-indicator {
    max-width: 700px;
  }
}

@media (min-width: 1920px) {
  .typing-indicator {
    max-width: 800px;
  }
}

.typing-indicator .message-avatar {
  width: 36px;
  height: 36px;
  background: transparent;
  padding: 0;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: rgba(237, 231, 231, 0.6);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {
  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Welcome message */
.welcome-message {
  text-align: center;
  padding: 40px 20px;
  color: rgba(237, 231, 231, 0.7);
}

.welcome-message h4 {
  font-size: 1.3rem;
  margin-bottom: 12px;
  color: var(--light-gray);
}

.welcome-message p {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

.suggested-questions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
  margin: 0 auto;
}

.suggested-question {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: left;
  color: var(--light-gray);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.suggested-question:hover {
  background: rgba(251, 61, 40, 0.1);
  border-color: var(--red);
  transform: translateX(4px);
}

/* Responsive */
@media (max-width: 768px) {
  .chat-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  /* Prevenir scroll em dispositivos touch */
  .chat-overlay.active {
    touch-action: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }

  .chat-header {
    padding: 16px 20px;
  }

  .chat-avatar {
    display: none;
  }

  .chat-title h3 {
    font-size: 1.2rem;
  }

  .chat-status {
    font-size: 0.75rem;
    line-height: 1.3;
  }

  .chat-messages {
    padding: 20px;
  }

  /* Modificação para mensagens do bot no mobile */
  .message.bot {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .message.bot .message-avatar {
    width: 32px;
    height: 32px;
    margin-bottom: 4px;
  }

  .message.bot .message-content {
    max-width: 100%;
    width: 100%;
    padding: 14px 16px;
    word-break: keep-all;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: none;
    white-space: normal;
  }

  .message.user {
    flex-direction: row-reverse;
  }

  .message.user .message-content {
    max-width: 320px;
    padding: 14px 16px;
  }

  .typing-indicator {
    width: fit-content;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    align-self: flex-start;
  }

  .typing-indicator .message-avatar {
    width: 28px;
    height: 28px;
    margin: 0;
  }

  /* Smaller typing dots on mobile */
  .typing-dots span {
    width: 6px;
    height: 6px;
  }

  .chat-input-container {
    padding: 16px 20px;
  }

  .chat-terms-notice {
    margin-bottom: 10px;
    padding: 6px 10px;
  }

  .chat-terms-notice p {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .chat-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  /* Prevenir scroll em dispositivos touch pequenos */
  .chat-overlay.active {
    touch-action: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }

  .suggested-questions {
    max-width: 100%;
  }

  /* Ajustes para telas muito pequenas */
  .message.bot .message-content {
    max-width: 100%;
    width: 100%;
    padding: 12px 14px;
    word-break: keep-all;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: none;
    white-space: normal;
  }

  .message.user .message-content {
    max-width: 280px;
    padding: 12px 14px;
  }

  .typing-indicator {
    width: fit-content;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    align-self: flex-start;
  }

  .typing-indicator .message-avatar {
    width: 26px;
    height: 26px;
    margin: 0;
  }

  /* Even smaller typing dots on very small screens */
  .typing-dots span {
    width: 5px;
    height: 5px;
  }
}
