/* ==========================================================================
   GIRASSOL INTELIGÊNCIA - WIDGET DE CHAT INSTITUCIONAL (NÚCLEO IA)
   Paleta: Obsidian (#07090D), Solar Gold (#E5A93C), Glassmorphism, Micro-animações
   ========================================================================== */

:root {
  --chat-bg: rgba(10, 13, 20, 0.95);
  --chat-surface: rgba(18, 23, 34, 0.92);
  --chat-border: rgba(229, 169, 60, 0.22);
  --chat-border-glow: rgba(229, 169, 60, 0.45);
  --chat-gold: #E5A93C;
  --chat-gold-light: #F7D070;
  --chat-gold-glow: rgba(229, 169, 60, 0.25);
  --chat-text: #F3F4F6;
  --chat-text-muted: #9CA3AF;
  --chat-user-bg: linear-gradient(135deg, rgba(229, 169, 60, 0.2) 0%, rgba(229, 169, 60, 0.08) 100%);
  --chat-assistant-bg: rgba(24, 30, 44, 0.85);
  --chat-radius: 20px;
}

/* --- Botão Flutuante (Trigger) --- */
.girassol-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #161C28 0%, #0B0E14 100%);
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  color: var(--chat-text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(229, 169, 60, 0.15);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: inherit;
}

.girassol-chat-launcher:hover {
  border-color: var(--chat-gold);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.75), 0 0 28px rgba(229, 169, 60, 0.35);
  transform: translateY(-2px);
}

.girassol-chat-launcher:active {
  transform: scale(0.97);
}

.launcher-icon-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(229, 169, 60, 0.25) 0%, transparent 70%);
  color: var(--chat-gold);
}

.launcher-pulse {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 8px;
  height: 8px;
  background: #10B981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10B981;
  animation: pulse-ring 2s infinite ease-out;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
  100% { transform: scale(0.9); opacity: 1; }
}

.launcher-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #FFFFFF;
}

/* --- Container da Janela de Chat --- */
.girassol-chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  height: 580px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 30px rgba(229, 169, 60, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9991;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.girassol-chat-window.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* --- Cabeçalho do Chat --- */
.chat-header {
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(24, 30, 44, 0.95) 0%, rgba(14, 18, 27, 0.95) 100%);
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-agent-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-agent-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(229, 169, 60, 0.25) 0%, rgba(14, 18, 27, 0.8) 100%);
  border: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-gold);
}

.agent-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #10B981;
  border-radius: 50%;
  border: 2px solid #0E121B;
}

.agent-titles {
  display: flex;
  flex-direction: column;
}

.agent-name {
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.01em;
}

.agent-badge {
  font-size: 11px;
  color: var(--chat-gold);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-btn-icon {
  background: transparent;
  border: none;
  color: var(--chat-text-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-btn-icon:hover {
  color: var(--chat-text);
  background: rgba(255, 255, 255, 0.08);
}

/* --- Área de Mensagens --- */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(229, 169, 60, 0.2);
  border-radius: 10px;
}

/* --- Bolhas de Mensagem --- */
.chat-bubble {
  max-width: 84%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  animation: fadeInBubble 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--chat-assistant-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--chat-user-bg);
  border: 1px solid var(--chat-border);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.bubble-time {
  display: block;
  font-size: 10px;
  color: var(--chat-text-muted);
  margin-top: 5px;
  text-align: right;
}

.chat-bubble.assistant .bubble-time {
  text-align: left;
}

/* --- Ações Rápidas & WhatsApp Bridge --- */
.chat-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.chat-action-btn {
  background: rgba(229, 169, 60, 0.08);
  border: 1px solid var(--chat-border);
  color: var(--chat-gold-light);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-action-btn:hover {
  background: rgba(229, 169, 60, 0.16);
  border-color: var(--chat-gold);
  transform: translateX(2px);
}

.chat-whatsapp-banner {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.chat-whatsapp-link {
  color: #34D399;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-whatsapp-link:hover {
  text-decoration: underline;
}

/* --- Indicador de Digitação (Typing) --- */
.chat-typing {
  align-self: flex-start;
  padding: 10px 16px;
  background: var(--chat-assistant-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: none;
  align-items: center;
  gap: 5px;
}

.chat-typing.active {
  display: flex;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-gold);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* --- Rodapé e Input --- */
.chat-footer {
  padding: 14px 16px;
  background: rgba(14, 18, 27, 0.95);
  border-top: 1px solid var(--chat-border);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.chat-input {
  flex: 1;
  background: rgba(24, 30, 44, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 10px 18px;
  color: #FFFFFF;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input::placeholder {
  color: var(--chat-text-muted);
}

.chat-input:focus {
  border-color: var(--chat-gold);
  box-shadow: 0 0 12px rgba(229, 169, 60, 0.2);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-gold) 0%, #D49226 100%);
  border: none;
  color: #0B0E14;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 0 15px rgba(229, 169, 60, 0.4);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-powered-by {
  font-size: 10.5px;
  text-align: center;
  color: var(--chat-text-muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* --- Responsividade Mobile --- */
@media (max-width: 640px) {
  .girassol-chat-launcher {
    bottom: 20px;
    right: 20px;
    padding: 10px 14px;
  }
  .launcher-label {
    display: none;
  }
  .girassol-chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
}
