/* ========================================
   CHATBOT AI - Magic World Experience
   Sistema de Atendimento com IA
   ======================================== */

:root {
  --chat-primary: linear-gradient(135deg, #0f766e 0%, #0ea5a6 50%, #f59e0b 100%);
  --chat-bg: #ffffff;
  --chat-user-bg: linear-gradient(135deg, #0ea5a6 0%, #0f766e 100%);
  --chat-ai-bg: #f3f4f6;
  --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  --chat-border: rgba(14, 165, 166, 0.2);
  --chat-text: #1f2937;
  --chat-text-light: #6b7280;
}

/* ========== BOTÃO FLUTUANTE DO CHAT ========== */

.chatbot-button {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 64px;
  height: 64px;
  background: var(--chat-primary);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: var(--chat-shadow);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
  animation: pulse-chat 2s ease-in-out infinite;
}

.chatbot-button:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 40px rgba(14, 165, 166, 0.35);
}

.chatbot-button:active {
  transform: scale(0.95);
}

.chatbot-button svg {
  width: 32px;
  height: 32px;
  color: white;
  transition: transform 0.3s ease;
}

.chatbot-button.active svg {
  transform: rotate(180deg);
}

.chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  animation: bounce-badge 0.5s ease;
}

@keyframes pulse-chat {
  0%, 100% {
    box-shadow: 0 8px 32px rgba(14, 165, 166, 0.15), 0 0 0 0 rgba(14, 165, 166, 0.5);
  }
  50% {
    box-shadow: 0 8px 32px rgba(14, 165, 166, 0.25), 0 0 0 10px rgba(14, 165, 166, 0);
  }
}

@keyframes bounce-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ========== JANELA DO CHAT ========== */

.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 32px;
  width: min(400px, calc(100vw - 80px));
  height: min(560px, calc(100vh - 180px));
  background: var(--chat-bg);
  border-radius: 24px;
  box-shadow: var(--chat-shadow);
  z-index: 999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--chat-border);
}

.chatbot-window.active {
  display: flex;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ========== CABEÇALHO DO CHAT ========== */

.chatbot-header {
  background: var(--chat-primary);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  overflow: visible;
  flex-shrink: 0;
  min-height: 80px;
}

.chatbot-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.2), transparent 70%);
  pointer-events: none;
}

.chatbot-header-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 44px);
  padding-top: 0;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  flex-shrink: 0;
  margin-top: 1px;
}

.chatbot-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border: 2px solid white;
  border-radius: 50%;
  animation: pulse-online 2s ease-in-out infinite;
}

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

.chatbot-header-text {
  color: white;
  min-width: 0;
  flex: 1;
  overflow: visible;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.chatbot-header-text h3 {
  margin: 0;
  font-family: 'Coco Gothic', sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  display: block;
  width: 100%;
  overflow: visible;
  white-space: normal;
}

.chatbot-header-text p {
  margin: 3px 0 0 0;
  font-size: 11px;
  opacity: 0.95;
  font-weight: 500;
  line-height: 1.3;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin-left: 8px;
  margin-top: 2px;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.chatbot-close svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* ========== ÁREA DE MENSAGENS ========== */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(to bottom, #fafafa 0%, #ffffff 100%);
  scroll-behavior: smooth;
}

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

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(14, 165, 166, 0.2);
  border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(14, 165, 166, 0.3);
}

/* ========== MENSAGENS ========== */

.chatbot-message {
  display: flex;
  gap: 12px;
  animation: fadeInMessage 0.3s ease;
  max-width: 85%;
}

@keyframes fadeInMessage {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-left: auto;
}

.chatbot-message.ai {
  align-self: flex-start;
}

.chatbot-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-message.user .chatbot-message-avatar {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}

.chatbot-message.ai .chatbot-message-avatar {
  background: linear-gradient(135deg, #0ea5a6, #0f766e);
}

.chatbot-message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chatbot-message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--chat-text);
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chatbot-message.user .chatbot-message-bubble {
  background: var(--chat-user-bg);
  color: white;
  border-bottom-right-radius: 4px;
}

.chatbot-message.ai .chatbot-message-bubble {
  background: var(--chat-ai-bg);
  border-bottom-left-radius: 4px;
}

.chatbot-message-time {
  font-size: 11px;
  color: var(--chat-text-light);
  padding: 0 4px;
}

.chatbot-message.user .chatbot-message-time {
  text-align: right;
}

/* ========== TYPING INDICATOR ========== */

.chatbot-typing {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--chat-ai-bg);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  max-width: fit-content;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  animation: fadeInMessage 0.3s ease;
}

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

.chatbot-typing-dot {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}

.chatbot-typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.chatbot-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ========== SUGESTÕES RÁPIDAS ========== */

.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px 16px;
  animation: fadeInMessage 0.3s ease;
}

.chatbot-suggestion {
  padding: 8px 16px;
  background: white;
  border: 1.5px solid var(--chat-border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #0f766e;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chatbot-suggestion:hover {
  background: linear-gradient(135deg, rgba(14, 165, 166, 0.1), rgba(245, 158, 11, 0.1));
  border-color: #0ea5a6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(14, 165, 166, 0.15);
}

/* ========== ÁREA DE INPUT ========== */

.chatbot-input-area {
  padding: 16px 24px;
  background: white;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chatbot-input-wrapper {
  flex: 1;
  position: relative;
}

.chatbot-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  max-height: 100px;
  min-height: 44px;
  line-height: 1.5;
}

.chatbot-input:focus {
  border-color: #0ea5a6;
  box-shadow: 0 0 0 3px rgba(14, 165, 166, 0.1);
}

.chatbot-input::placeholder {
  color: #9ca3af;
}

.chatbot-send-button {
  width: 44px;
  height: 44px;
  background: var(--chat-primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}

.chatbot-send-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(14, 165, 166, 0.3);
}

.chatbot-send-button:active:not(:disabled) {
  transform: translateY(0);
}

.chatbot-send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-send-button svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* ========== MENSAGEM DE BOAS-VINDAS ========== */

.chatbot-welcome {
  text-align: center;
  padding: 24px;
  animation: fadeInMessage 0.3s ease;
}

.chatbot-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(14, 165, 166, 0.2));
}

.chatbot-welcome h4 {
  margin: 0 0 8px 0;
  font-family: 'Coco Gothic', sans-serif;
  font-size: 20px;
  background: var(--chat-primary);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.chatbot-welcome p {
  margin: 0;
  color: var(--chat-text-light);
  font-size: 14px;
  line-height: 1.6;
}

/* ========== LINKS E FORMATAÇÃO ========== */

.chatbot-message-bubble a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

.chatbot-message.user .chatbot-message-bubble a {
  color: white;
}

.chatbot-message.ai .chatbot-message-bubble a {
  color: #0f766e;
}

.chatbot-message-bubble strong {
  font-weight: 700;
}

.chatbot-message-bubble em {
  font-style: italic;
}

.chatbot-message-bubble code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

/* ========== RESPONSIVO MOBILE ========== */

@media (max-width: 768px) {
  .chatbot-button {
    bottom: 24px;
    right: 16px;
    width: 50px;
    height: 50px;
  }

  .chatbot-button svg {
    width: 24px;
    height: 24px;
  }

  .chatbot-window {
    bottom: 80px;
    right: 8px;
    left: 8px;
    width: calc(100% - 16px);
    height: auto;
    max-height: min(420px, 55vh);
    border-radius: 16px;
  }

  .chatbot-messages {
    padding: 10px 12px;
    gap: 10px;
    max-height: 200px;
    min-height: 150px;
  }

  .chatbot-input-area {
    padding: 10px 12px;
    gap: 8px;
  }

  .chatbot-input {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 36px;
  }

  .chatbot-send-button {
    width: 36px;
    height: 36px;
  }

  .chatbot-send-button svg {
    width: 16px;
    height: 16px;
  }

  .chatbot-header {
    padding: 10px 12px;
    min-height: 50px;
  }

  .chatbot-header-text h3 {
    font-size: 13px;
    line-height: 1.2;
  }

  .chatbot-header-text p {
    font-size: 10px;
  }

  .chatbot-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
    flex-shrink: 0;
  }

  .chatbot-avatar::after {
    width: 8px;
    height: 8px;
    bottom: 0;
    right: 0;
  }

  .chatbot-close {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  .chatbot-close svg {
    width: 16px;
    height: 16px;
  }

  .chatbot-header-info {
    max-width: calc(100% - 40px);
    gap: 8px;
  }

  .chatbot-suggestions {
    padding: 0 12px 8px;
    gap: 6px;
  }

  .chatbot-suggestion {
    padding: 6px 10px;
    font-size: 11px;
  }

  .chatbot-message {
    max-width: 88%;
    gap: 8px;
  }

  .chatbot-message-avatar {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .chatbot-message-bubble {
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.5;
  }

  .chatbot-message-time {
    font-size: 9px;
  }

  .chatbot-welcome {
    padding: 12px;
  }

  .chatbot-welcome-icon {
    font-size: 32px;
    margin-bottom: 8px;
  }

  .chatbot-welcome h4 {
    font-size: 16px;
  }

  .chatbot-welcome p {
    font-size: 12px;
  }

  .chatbot-typing {
    padding: 8px 12px;
    gap: 8px;
  }

  .chatbot-typing-dot {
    width: 6px;
    height: 6px;
  }
}

/* ========== ACESSIBILIDADE ========== */

@media (prefers-reduced-motion: reduce) {
  .chatbot-button,
  .chatbot-window,
  .chatbot-message,
  .chatbot-typing {
    animation: none;
  }

  .chatbot-close:hover {
    transform: none;
  }
}

/* ========== ESTADOS DE ERRO ========== */

.chatbot-error {
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  color: #991b1b;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeInMessage 0.3s ease;
}

.chatbot-error svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ========== TEMA ESCURO (OPCIONAL) ========== */

@media (prefers-color-scheme: dark) {
  .chatbot-window {
    background: #1f2937;
  }

  .chatbot-messages {
    background: linear-gradient(to bottom, #111827 0%, #1f2937 100%);
  }

  .chatbot-message.ai .chatbot-message-bubble {
    background: #374151;
    color: #f9fafb;
  }

  .chatbot-input-area {
    background: #1f2937;
    border-top-color: #374151;
  }

  .chatbot-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }

  .chatbot-input:focus {
    border-color: #0ea5a6;
  }

  .chatbot-suggestion {
    background: #374151;
    border-color: #4b5563;
    color: #10b981;
  }

  .chatbot-welcome p {
    color: #9ca3af;
  }
}

