/* Variáveis de Cores e Estilo */
:root {
  /* Gradiente Holográfico Laranja (Amber -> Orange -> Red-Orange) */
  --chat-gradient: linear-gradient(135deg, #fbbf24 0%, #f97316 50%, #ea580c 100%);
  --chat-gradient-hover: linear-gradient(135deg, #f59e0b 0%, #ea580c 50%, #c2410c 100%);
  
  --chat-bg: rgba(255, 255, 255, 0.9); /* Glassmorphism base */
  --chat-white: #ffffff;
  --chat-text: #1f2937;
  --chat-text-secondary: #6b7280;
  --chat-border: rgba(0, 0, 0, 0.06);
  --chat-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.15), 0 10px 20px -5px rgba(0, 0, 0, 0.1);
}

/* Container Principal */
#chat-widget {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 99999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

#chat-widget * {
  pointer-events: auto;
  box-sizing: border-box;
}

/* Botão Flutuante (Esfera Pura) */
.chat-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--chat-gradient);
  border: none;
  cursor: pointer;
  box-shadow: 
    0 10px 30px rgba(249, 115, 22, 0.4),
    inset 0 2px 10px rgba(255,255,255,0.4), /* Brilho interno superior */
    inset 0 -5px 15px rgba(0,0,0,0.1);    /* Sombra interna inferior */
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10002;
  margin-top: 16px;
  opacity: 0.85;
}

.chat-button:hover {
  transform: scale(1.1) translateY(-4px);
  opacity: 1;
  box-shadow: 
    0 20px 40px rgba(249, 115, 22, 0.5),
    inset 0 2px 15px rgba(255,255,255,0.5);
  background: var(--chat-gradient-hover);
}

/* Painel de Chat (Glassmorphism) */
.chat-panel {
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  box-shadow: var(--chat-shadow);
  transform-origin: bottom right;
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10001;
}

.chat-panel.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Header Minimalista */
.chat-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  background: white;
  border-bottom: 1px solid var(--chat-border);
}

.chat-avatar-header {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  margin-right: 16px;
  background: var(--chat-gradient); /* Esfera Gradiente Pura */
  box-shadow: 
    0 4px 12px rgba(249, 115, 22, 0.2),
    inset 0 2px 5px rgba(255,255,255,0.3);
}

.chat-header-info {
  flex: 1;
}

.chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--chat-text);
  letter-spacing: -0.01em;
}

.chat-header p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--chat-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header p::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

#chat-close { 
  background: transparent;
  border: none; 
  color: var(--chat-text-secondary); 
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s;
}

#chat-close:hover {
  background: rgba(0,0,0,0.05);
  color: var(--chat-text);
}

/* Área de Mensagens */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  background: linear-gradient(to bottom, #ffffff, #f8fafc);
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.1); border-radius: 10px; }

.message {
  display: flex;
  max-width: 100%;
  animation: slideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.message.user { justify-content: flex-end; }
.message.bot { justify-content: flex-start; }

.message-bubble {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* User Bubble: Gradiente */
.message.user .message-bubble {
  background: var(--chat-gradient);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 8px 20px rgba(249, 115, 22, 0.25);
}

/* Bot Bubble: Branco Clean */
.message.bot .message-bubble {
  background: white;
  color: var(--chat-text);
  border: 1px solid rgba(0,0,0,0.05);
  border-bottom-left-radius: 4px;
}

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

/* Input Area */
.chat-input-container {
  padding: 16px 24px;
  background: white;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

#chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  outline: none;
  font-size: 14px;
  transition: all 0.3s;
  background: #f9fafb;
  color: var(--chat-text);
}

#chat-input:focus {
  background: white;
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

#chat-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--chat-gradient);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

#chat-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.4);
}

#chat-send svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px !important;
  min-width: 60px;
  justify-content: center;
}

.typing-dot {
  width: 5px;
  height: 5px;
  background: #cbd5e1;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; background: #fbbf24; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; background: #f97316; }
.typing-dot:nth-child(3) { background: #ea580c; }

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

/* Botões de Ação */
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.action-btn {
  background: white;
  border: 1px solid transparent;
  color: #ea580c;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  position: relative;
  background-clip: padding-box;
}

.action-btn::before {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: -1;
  margin: -1px;
  border-radius: inherit;
  background: var(--chat-gradient);
}

.action-btn:hover {
  background: var(--chat-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
  transform: translateY(-1px);
}

/* Responsividade Mobile */
@media (max-width: 480px) {
  #chat-widget {
    bottom: 0;
    right: 0;
    width: 100%;
    z-index: 999999;
  }

  .chat-panel {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: none;
  }
  
  .chat-button {
    bottom: 20px;
    right: 20px;
    position: absolute;
  }

  .chat-panel.visible ~ .chat-button {
    display: none;
  }
}
