/* =========================================================
   ESTILOS DO BOTÃO E JANELA DO ASSISTENTE IA (CORE AI)
   ========================================================= */

/* Botão Flutuante (FAB) */
#ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  border: none;
  outline: none;
  box-shadow: 0 4px 18px rgba(14, 165, 233, 0.45);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

#ai-chat-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.6);
}

#ai-chat-fab:active {
  transform: scale(0.95);
}

#ai-chat-fab i {
  font-size: 20px;
  transition: transform 0.3s ease;
}

/* Efeito sutil de pulso / status */
#ai-chat-fab::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #22c55e;
  border: 2px solid #0f172a;
  border-radius: 50%;
}

/* Janela de Chat */
#ai-chat-window {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 500px;
  max-height: calc(100vh - 120px);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 9999;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}

#ai-chat-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Temas Dark e Light para a Janela */
html[data-theme="dark"] #ai-chat-window,
body[data-theme="dark"] #ai-chat-window {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

html[data-theme="light"] #ai-chat-window,
body[data-theme="light"] #ai-chat-window {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #1e293b;
}

/* Header do Chat */
.ai-chat-header {
  cursor: grab;
  padding: 14px 18px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

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

.ai-chat-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.ai-chat-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
}

.ai-chat-subtitle {
  font-size: 11px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-status-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}

.ai-chat-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  opacity: 0.8;
  transition: opacity 0.2s, background 0.2s;
}

.ai-chat-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* Corpo das Mensagens */
.ai-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13.5px;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}

/* Balões de Mensagem */
.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  line-height: 1.45;
  word-wrap: break-word;
  animation: aiMsgIn 0.25s ease-out;
}

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

.ai-msg.ai {
  align-self: flex-start;
}

.ai-msg.user {
  align-self: flex-end;
}

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
}

.ai-msg.ai .ai-msg-bubble {
  background: #1e293b;
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

html[data-theme="light"] .ai-msg.ai .ai-msg-bubble,
body[data-theme="light"] .ai-msg.ai .ai-msg-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-msg-time {
  font-size: 10px;
  opacity: 0.55;
  margin-top: 3px;
  padding: 0 4px;
}
.ai-msg.user .ai-msg-time {
  text-align: right;
}

/* Indicador de Digitação (Typing dots) */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #1e293b;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
}

html[data-theme="light"] .ai-typing-indicator,
body[data-theme="light"] .ai-typing-indicator {
  background: #f1f5f9;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: aiBounce 1.2s infinite ease-in-out;
}

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

@keyframes aiBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* Rodapé com Input */
.ai-chat-footer {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .ai-chat-footer,
body[data-theme="light"] .ai-chat-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
}

.ai-chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1e293b;
  color: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
}

html[data-theme="light"] .ai-chat-input,
body[data-theme="light"] .ai-chat-input {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.ai-chat-input:focus {
  border-color: #38bdf8;
}

.ai-chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.ai-chat-send-btn:hover {
  transform: scale(1.05);
}

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


.ai-chat-header:active {
  cursor: grabbing;
}