/* ==========================================================================
   MAIN.CSS
   Arquivo agregador + estilos globais do chat da Gro
   ========================================================================== */

/* ==========================================================================
   IMPORTS
   ========================================================================== */

@import "base.css";
@import "layout.css";
@import "components.css";
@import "comments.css";
@import "ia-art.css";

/* ==========================================================================
   CHAT WIDGET - GRO
   Implementação única, alinhada ao HTML atual e ao chat.js
   ========================================================================== */

/* Painel */
#gro-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 84px;
  z-index: 9999;

  width: 370px;
  max-width: calc(100vw - 32px);
  height: 520px;

  display: flex;
  flex-direction: column;
  overflow: hidden;

  border-radius: 20px;
  border: 1px solid var(--border-color);
  background:
    linear-gradient(180deg, rgba(18, 24, 38, 0.96), rgba(11, 15, 23, 0.98));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-strong);

  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#gro-chat-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Botão flutuante */
#gro-chat-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;

  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;

  border: 1px solid rgba(124, 156, 255, 0.24);
  border-radius: 999px;
  cursor: pointer;

  background:
    linear-gradient(180deg, rgba(124, 156, 255, 0.18), rgba(124, 156, 255, 0.10));
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;

  box-shadow: 0 12px 32px rgba(124, 156, 255, 0.18);
  backdrop-filter: blur(14px);
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}

#gro-chat-button::before {
  content: "✦";
  color: var(--accent);
  font-size: 0.95rem;
  line-height: 1;
}

#gro-chat-button:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 156, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(124, 156, 255, 0.24), rgba(124, 156, 255, 0.14));
  box-shadow: 0 18px 42px rgba(124, 156, 255, 0.24);
}

/* Cabeçalho */
#gro-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 16px 18px;
  font-weight: 700;
  color: var(--text-primary);

  border-bottom: 1px solid var(--border-color);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015));
}

#gro-chat-header span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#gro-chat-header span::before {
  content: "●";
  color: var(--accent);
  font-size: 0.78rem;
}

#gro-chat-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.22s ease;
}

#gro-chat-close:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  transform: rotate(90deg);
}

/* Área de mensagens */
#gro-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0.00));
}

#gro-chat-messages::-webkit-scrollbar {
  width: 8px;
}

#gro-chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

#gro-chat-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(124, 156, 255, 0.55), rgba(167, 139, 250, 0.55));
  border-radius: 999px;
}

.gro-msg {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.96rem;
}

.gro-msg.user {
  margin-left: 28px;
  background: rgba(124, 156, 255, 0.14);
  border: 1px solid rgba(124, 156, 255, 0.18);
  color: var(--text-primary);
}

.gro-msg.assistant {
  margin-right: 28px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

/* Área de input */
#gro-chat-input-area {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border-color);
  background: rgba(11, 15, 23, 0.88);
}

#gro-chat-input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

#gro-chat-input:focus {
  border-color: rgba(124, 156, 255, 0.34);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
}

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

#gro-chat-send {
  padding: 11px 15px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;

  background: var(--accent);
  color: #fff;
  transition: background 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}

#gro-chat-send:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(124, 156, 255, 0.22);
}

/* ==========================================================================
   CHAT RESPONSIVO
   ========================================================================== */

@media (max-width: 768px) {
  #gro-chat-button {
    right: 16px;
    bottom: 16px;
  }

  #gro-chat-panel {
    right: 0;
    bottom: 0;

    width: 100vw;
    max-width: 100vw;
    height: 100dvh;

    border-radius: 0;
    border: none;
    box-shadow: none;

    opacity: 1;
    pointer-events: none;
    transform: translateX(100%);
    transition: transform 0.28s ease;
  }

  #gro-chat-panel.open {
    pointer-events: auto;
    transform: translateX(0);
  }

  #gro-chat-header {
    padding-top: 64px;
    font-size: 16px;
  }

  #gro-chat-messages {
    padding: 16px;
  }

  #gro-chat-input-area {
    gap: 10px;
    padding: 12px;
  }

  #gro-chat-input {
    min-height: 44px;
    font-size: 16px;
  }

  #gro-chat-send {
    min-height: 44px;
    padding: 0 16px;
  }
}

/* ==========================================================================
   EFEITO PENSANDO E DIGITANDO
   ========================================================================== */

.gro-thinking {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.28;
  animation: groDotPulse 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes groDotPulse {
  0%, 80%, 100% {
    transform: translateY(0) scale(0.9);
    opacity: 0.28;
  }
  40% {
    transform: translateY(-4px) scale(1.08);
    opacity: 1;
  }
}

.gro-msg.is-typing::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1.1em;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--accent);
  border-radius: 2px;
  animation: groCaretBlink 0.75s steps(1) infinite;
}

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