/* === GEMINI CHAT WIDGET STYLES - Limpo, responsivo e integrado ao tema === */

/* Reset mínimo para isolar o widget sem brigar com o tema */
#gemini-chat-widget,
#gemini-chat-widget *,
#gemini-chat-widget *::before,
#gemini-chat-widget *::after {
  box-sizing: border-box;
}

#gemini-chat-widget {
  position: fixed;
  z-index: 2147483647 !important; /* manter acima do site */
  font-family: inherit; /* use a fonte do site */
  /* Variáveis com fallback; o tema do site pode sobrescrever */
  --primary: var(--chiapetta-primary, #2bdcb5);
  --secondary: var(--chiapetta-secondary, #9b2dff);
  --bg-dark: var(--chiapetta-bg-dark, #0d0d0d);
  --bg-mid: var(--chiapetta-bg-mid, #151515);
  --bg-light: var(--chiapetta-bg-light, #1d1d1d);
  --text-main: var(--chiapetta-text-main, #efefef);
  --text-muted: var(--chiapetta-text-muted, #a6a6a6);
  --gemini-bot-bg: var(--bg-light);
  --gemini-bot-text: var(--text-main);
  --gemini-bot-border: var(--primary);
}

/* Posicionamento do widget */
.gemini-chat-bottom-right { bottom: 20px !important; right: 20px !important; }
.gemini-chat-bottom-left  { bottom: 20px !important; left: 20px !important;  }
.gemini-chat-top-right    { top: 20px !important;    right: 20px !important; }
.gemini-chat-top-left     { top: 20px !important;    left: 20px !important;  }

/* Botão do chat */
.gemini-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 25px rgba(43, 220, 181, 0.3);
  border: 2px solid var(--bg-light);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.gemini-chat-button:hover { transform: scale(1.1); background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%); }
.gemini-chat-button:active { transform: scale(0.95); }
.gemini-chat-button.gemini-chat-open { transform: scale(0.9); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); }

/* Animação de pulso opcional */
@keyframes pulse-attention {
  0%   { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(66, 133, 244, 0.7); }
  70%  { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), 0 0 0 10px rgba(66, 133, 244, 0); }
  100% { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(66, 133, 244, 0); }
}
.gemini-chat-button.pulse { animation: pulse-attention 2s infinite; }

/* Janela do chat */
.gemini-chat-window {
  position: fixed !important;
  background: var(--bg-dark);
  border: 2px solid var(--bg-light);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--primary);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2147483646;
  width: min(380px, calc(100vw - 40px));
  height: min(550px, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
}

/* Posição da janela em relação ao botão */
.gemini-chat-bottom-right .gemini-chat-window { bottom: 90px !important; right: 20px !important; }
.gemini-chat-bottom-left  .gemini-chat-window { bottom: 90px !important; left: 20px !important;  }
.gemini-chat-top-right    .gemini-chat-window { top: 90px !important;    right: 20px !important; }
.gemini-chat-top-left     .gemini-chat-window { top: 90px !important;    left: 20px !important;  }

/* Header */
.gemini-chat-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--text-main);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--bg-light);
}
.gemini-chat-title { font-weight: 600; font-size: 16px; flex: 1; }
.gemini-chat-close {
  background: none; border: none; color: white; cursor: pointer; padding: 8px; border-radius: 50%;
  transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
}
.gemini-chat-close:hover { background-color: rgba(255, 255, 255, 0.15); transform: scale(1.1); }

/* Área de mensagens */
.gemini-chat-messages {
  background: var(--bg-mid);
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 20px;
  border-bottom: 1px solid var(--bg-light);
  flex: 1;
}
.gemini-chat-messages::-webkit-scrollbar { width: 6px; }
.gemini-chat-messages::-webkit-scrollbar-track { background: transparent; }
.gemini-chat-messages::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.2); border-radius: 3px; }

/* Mensagens */
.gemini-message { margin: 10px 0 16px 0; animation: slideInMessage 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: flex-end; }
.gemini-user-message { justify-content: flex-end; }
.gemini-bot-message  { justify-content: flex-start; }

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

.gemini-message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  max-width: 82%;
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 1;
  border: 1px solid var(--bg-light);
}

/* Rótulo do remetente */
.gemini-message-bubble .message-sender {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 6px 0;
  opacity: 0.9;
}
.gemini-user-message .message-sender { color: rgba(255,255,255,0.95); }
.gemini-bot-message  .message-sender { color: var(--primary); }

/* Caudas dos balões */
.gemini-user-message .gemini-message-bubble::after,
.gemini-bot-message  .gemini-message-bubble::after {
  content: ""; position: absolute; width: 12px; height: 12px; transform: rotate(45deg);
}
.gemini-user-message .gemini-message-bubble::after { right: -6px; bottom: 10px; background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); box-shadow: 0 2px 6px rgba(0,0,0,0.35); }
.gemini-bot-message  .gemini-message-bubble::after { left: -6px;  bottom: 10px; background: var(--bg-light); border-left: 1px solid var(--primary); border-top: 1px solid var(--primary); }

/* Agrupamento */
.gemini-user-message + .gemini-user-message .gemini-message-bubble { border-top-right-radius: 6px; margin-top: -4px; }
.gemini-bot-message  + .gemini-bot-message  .gemini-message-bubble { border-top-left-radius: 6px;  margin-top: -4px; }

/* Tipografia no balão */
.gemini-message-bubble p { margin: 0 0 8px 0; }
.gemini-message-bubble ul, .gemini-message-bubble ol { margin: 6px 0 6px 18px; }
.gemini-message-bubble li { margin: 4px 0; }
.gemini-message-bubble hr { border: none; height: 1px; background: rgba(255,255,255,0.08); margin: 10px 0; }
.gemini-message-bubble blockquote { border-left: 3px solid var(--primary); padding-left: 10px; margin: 6px 0; color: var(--text-muted); }

/* Meta (hora) */
.gemini-message-bubble .message-time { position: absolute; right: 10px; bottom: 6px; font-size: 11px; opacity: 0.7; margin: 0; }

/* Usuário */
.gemini-user-message .gemini-message-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--text-main);
  margin-left: auto;
  box-shadow: 0 4px 12px rgba(43, 220, 181, 0.3);
}

/* IA */
.gemini-bot-message .gemini-message-bubble {
  background-color: var(--gemini-bot-bg);
  color: var(--gemini-bot-text);
  border: 2px solid var(--gemini-bot-border);
  font-weight: 500;
}
.gemini-bot-message .gemini-message-bubble strong { font-weight: 700; }
.gemini-bot-message .gemini-message-bubble code {
  background-color: #0f172a;
  color: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  border: 1px solid #1f2937;
}
.gemini-bot-message .gemini-message-bubble a { color: #7dd3fc; text-decoration: underline; font-weight: 500; }
.gemini-bot-message .gemini-message-bubble a:hover { color: #38bdf8; }

/* Container de input */
.gemini-chat-input-container { padding: 16px 20px; background: var(--bg-dark); border-top: 1px solid var(--bg-light); }
.gemini-chat-input-wrapper { display: flex; align-items: flex-end; gap: 12px; }
.gemini-chat-input {
  flex: 1; border: 2px solid var(--bg-light); border-radius: 24px; padding: 12px 18px; font-size: 14px;
  resize: none; outline: none; min-height: 44px; max-height: 120px; transition: all 0.2s ease; background: var(--bg-mid); color: var(--text-main);
}
.gemini-chat-input:focus { border-color: var(--primary); background: var(--bg-light); box-shadow: 0 0 0 3px rgba(43, 220, 181, 0.2); }
.gemini-chat-send-button {
  width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(43, 220, 181, 0.4);
}
.gemini-chat-send-button:hover { transform: scale(1.05); }
.gemini-chat-send-button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Loading */
.gemini-chat-loading { padding: 16px 20px; display: flex; align-items: center; gap: 12px; background: var(--bg-mid); border-top: 1px solid var(--bg-light); font-size: 14px; color: var(--text-muted); }
.gemini-loading-dots { display: flex; gap: 4px; }
.gemini-loading-dots span { width: 8px; height: 8px; border-radius: 50%; background-color: var(--primary); animation: pulseLoading 1.4s ease-in-out infinite both; }
.gemini-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.gemini-loading-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes pulseLoading { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* Responsividade */
@media (max-width: 640px) {
  .gemini-chat-window { width: calc(100vw - 20px); max-width: 420px; height: min(80vh, 520px); }
  .gemini-chat-messages { padding: 15px; }
  .gemini-chat-button { width: 56px; height: 56px; }
  .gemini-chat-input { font-size: 16px; }
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary);
  animation: typingBounce 1.4s ease-in-out infinite both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

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

/* Typing Animation Cursor */
.gemini-typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background-color: var(--primary);
  animation: blink 1s infinite;
  margin-left: 2px;
  vertical-align: baseline;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Print */
@media print { #gemini-chat-widget { display: none !important; } }
