/* Botão flutuante */
.chat-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  z-index: 1000;
  color: white;
}

.chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

/* Widget do chat */
.chat-widget {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 300px;
  height: 400px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 1001;
  overflow: hidden;
}

.chat-widget.open {
  display: flex;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header do chat */
.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-title {
  font-weight: 600;
  font-size: 14px;
}

.chat-status {
  font-size: 11px;
  opacity: 0.9;
}

.close-button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Área de mensagens */
.chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  gap: 8px;
  max-width: 85%;
}

.bot-message {
  align-self: flex-start;
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 4px;
}

.bot-message .message-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.user-message .message-avatar {
  background: #e5e7eb;
  color: #6b7280;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-text {
  background: #f3f4f6;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}

.bot-message .message-text {
  background: #f3f4f6;
  color: #374151;
}

.user-message .message-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.message-time {
  font-size: 10px;
  color: #9ca3af;
  padding: 0 4px;
}

.user-message .message-time {
  text-align: right;
}

/* Área de input */
.chat-input-area {
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: white;
}

.input-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

#messageInput {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#messageInput:focus {
  border-color: #667eea;
}

.send-button {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.send-button:hover {
  transform: scale(1.05);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.char-counter {
  text-align: right;
  font-size: 10px;
  color: #9ca3af;
  margin-top: 4px;
}

/* Loading indicator */
.loading-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.loading-dots div {
  width: 5px;
  height: 5px;
  background: #667eea;
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite both;
}

.loading-dots div:nth-child(1) {
  animation-delay: -0.32s;
}
.loading-dots div:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Responsivo */
@media (max-width: 480px) {
  .chat-button {
    width: 50px;
    height: 50px;
    bottom: 15px;
    right: 15px;
  }

  .chat-widget {
    width: calc(100vw - 30px);
    height: 70vh; /* Reduced height to avoid occupying full screen */
    max-height: 450px; /* Maximum height to keep it compact */
    bottom: 80px;
    right: 15px;
    left: 15px;
  }

  .chat-header {
    padding: 10px;
  }

  .chat-title {
    font-size: 13px;
  }

  .chat-status {
    font-size: 10px;
  }

  .chat-avatar {
    width: 24px;
    height: 24px;
  }

  .chat-messages {
    padding: 10px;
    gap: 10px;
  }

  .message-text {
    padding: 8px 12px;
    font-size: 12px;
  }

  .message-avatar {
    width: 18px;
    height: 18px;
  }

  .message-time {
    font-size: 9px;
  }

  .chat-input-area {
    padding: 10px;
  }

  #messageInput {
    padding: 8px 12px;
    font-size: 12px;
  }

  .send-button {
    width: 32px;
    height: 32px;
  }
}

/* Scrollbar customizada */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}