/* style/analu.css */

/* === 1. GLOBAL LAYOUT === */
.landing-container.refined {
  margin-top: 40px;
  padding: 0 5%;
}

/* === 2. INTRO GRID: MESSAGE + AVATAR === */
.landing-intro.refined-intro {
  display: grid;
  grid-template-columns: 2fr 1fr;   /* texto (2fr) + avatar (1fr) */
  align-items: center;
  gap: 32px;
  max-width: 920px;
  margin: 0 auto 40px;
  overflow: visible !important;
}

/* === 4. MESSAGE BUBBLE === */
.interaction-column.refined-interaction {
  grid-area: message;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-wrap: break-word;
}
.analu-message {
  border-left: 5px solid #007bff;
  padding: 20px;
  border-radius: 10px;
  font-size: 1.05em;
  line-height: 1.5;
  max-height: 240px;
  overflow: hidden;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
  transition: background-color .3s, color .3s;
}
.analu-message::-webkit-scrollbar { width: 8px; }
.analu-message::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.analu-message::-webkit-scrollbar-track { background: transparent; }
.analu-title {
  font-weight: bold;
  font-size: 1.05em;
  word-break: break-word;
}

/* light/dark */
html:not(.dark) .analu-message { background: #f0f8ff; color: #002244; }
html.dark        .analu-message { background: #002244; color: #f8f9fa; }

/* === 5. PRIMARY BUTTONS === */
.refined-buttons {
  grid-area: buttons;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.refined-button {
  padding: 14px 20px;
  border-radius: 999px;
  background: #0069d9;
  color: #fff;
  text-align: center;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: background .3s;
}
.refined-button:hover { background: #0056b3; }
.refined-button.secondary {
  background: #fff;
  color: #0069d9;
  border: 2px solid #0069d9;
}
.refined-button.secondary:hover { background: #e6f0ff; }

/* === 6. INPUT AREA === */
.input-area {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  max-width: 800px;
  margin: 0 auto 32px;
}
.refined-input {
  padding: 14px 20px;
  border: 1px solid #ccc;
  border-radius: 24px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
  transition: border-color .3s;
}
.refined-input:focus { outline: none; border-color: #0069d9; }
.refined-input-send {
  width: 48px; height: 48px;
  background: #0069d9; color: #fff;
  border: none; border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: background .3s;
}
.refined-input-send:hover { background: #0056b3; }

/* === 7. FLOAT BUTTON & CHAT WINDOW === */
.analu-float {
  position: fixed;
  bottom: 20px;
  right: max(calc((100vw - 960px)/2 - 10px),20px);
  z-index: 9999;
  background: transparent; border: none; padding: 0;
}
.analu-float img {
  width: 60px; height: 60px;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0,0,0,0.2);
  transition: transform .2s;
}
.analu-float:hover img { transform: scale(1.05); }

#analu-chat {
  display: none;
  position: fixed;
  bottom: 90px; right: 20px;
  width: 320px; max-height: 400px;
  background: #fff; border:2px solid #ccc; border-radius:16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  overflow: hidden; flex-direction: column;
  font-family: Arial,sans-serif;
}
#analu-chat.open { display: flex; }
.chat-header { background: #0066cc; color: #fff; padding: 10px; font-weight: bold; }
.chat-body { flex:1; padding:10px; overflow-y:auto; font-size:14px; color:#333; }
#analu-input { border:none; border-top:1px solid #ddd; padding:10px; width:100%; }

/* === CHAT FLUTUANTE – FUNDO IGUAL AO DA LANDING === */
html:not(.dark) #analu-chat {
  background: #f0f8ff;   /* mesmo que .analu-message no modo claro */
  color: #002244;
  border: 2px solid #bcd3e8; /* tom azul claro em vez de cinza */
}

html.dark #analu-chat {
  background: #002244;   /* mesmo que .analu-message no modo escuro */
  color: #f8f9fa;
  border: 2px solid #334155; /* tom escuro */
}

/* o corpo de mensagens herda as cores */
#analu-chat .chat-body {
  color: inherit;
  background: transparent;
}

/* === 8. INACTIVE TOOL BUTTONS === */
a.button {
  padding: 12px 18px; background:#007bff; color:#fff;
  border-radius:999px; text-decoration:none; font-weight:500;
  min-width:180px; transition: background .3s;
}
a.button:hover { background:#0056b3; }
a.button.button-inactive {
  background: #00438c; color:#e0e0e0; cursor:not-allowed;
  position:relative;
}
a.button.button-inactive::after {
  content:"Em desenvolvimento"; position:absolute;
  bottom:-35px; left:50%; transform:translateX(-50%);
  background:#000;color:#fff;padding:5px 10px;border-radius:5px;
  opacity:0; transition:opacity .3s; white-space:nowrap;
}
a.button.button-inactive:hover::after { opacity:1; }

/* === 9. HIDE BUTTON PULSES DURING LIPSYNC === */
.refined-button,
.highlight-pulse,
.highlight-pulse-infinite {
  animation: none !important;
  transition: none !important;
}

/* === 10. MOBILE (≤1024px coarse) === */
@media (max-width:1024px) and (pointer:coarse) {
  .landing-intro.refined-intro {
    grid-template-areas:
      "avatar message"
      "buttons buttons";
    grid-template-columns: 140px 1fr;
    gap:16px;
    padding:0 12px;
  }
  .intro-avatar { width:140px !important; max-width:none !important; }
  .input-area { padding:0 8px; }
}

/* === 11. AVATAR ANIMADO: Boca, Olhos e Flutuar === */
/* === AVATAR ANIMADO: Boca, Olhos e Flutuar === */
.intro-avatar {
  grid-area: avatar;
  justify-self: center;
  align-self: start;
  width: 100%;
  max-width: 260px;
}

.intro-avatar .analu-animated-container {
  position: relative;
  width: 100%;
  max-width: 260px;
  /* float only when not talking */
  animation: none;
}
.intro-avatar .analu-animated-container:not(.talking) {
  animation: analu-flutuar 5s ease-in-out infinite;
}

/* stack all frames */
.intro-avatar .analu-animated-container img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.2s ease;
}

/* base always visible when not talking */
.intro-avatar .analu-frame-base {
  z-index: 1;
  opacity: 1;
}

/* mouth layers start hidden */
.intro-avatar .analu-frame-mouth-open,
.intro-avatar .analu-frame-mouth-closed {
  z-index: 2;
  opacity: 0;
  will-change: opacity;
}

/* eyes‐closed (blink) */
.intro-avatar .analu-frame-eyes-closed {
  z-index: 3;
  opacity: 0;
  animation: analu-piscar 5s infinite;
}

/* TALKING: alternate both mouth layers */
.intro-avatar .analu-animated-container.talking .analu-frame-mouth-open {
  opacity: 1;
  animation: analu-lipsync 0.35s steps(1) infinite alternate;
}
.intro-avatar .analu-animated-container.talking .analu-frame-mouth-closed {
  opacity: 1;
  animation: analu-lipsync 0.35s steps(1) infinite alternate-reverse;
}

/* keyframes */
@keyframes analu-flutuar {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-4px); }
}
@keyframes analu-piscar {
  0%,96%,100% { opacity: 0; }
  97%,98%     { opacity: 1; }
}
@keyframes analu-lipsync {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* mouth layers are always in the DOM, but invisible by default */
.intro-avatar .analu-frame-mouth-open,
.intro-avatar .analu-frame-mouth-closed {
  opacity: 0;
  transition: opacity 0.1s linear !important;
}

/* when talking + mouth-open flag: show the open mouth */
.intro-avatar .analu-animated-container.talking.mouth-open .analu-frame-mouth-open {
  opacity: 1 !important;
}
/* when talking + no mouth-open flag: show the closed mouth */
.intro-avatar .analu-animated-container.talking:not(.mouth-open) .analu-frame-mouth-closed {
  opacity: 1 !important;
}

/* Indicador “pensando…” dentro do chat flutuante */
#analu-thinking {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 12px 0;
  height: 16px;              /* garante que nunca zere */
}

#analu-thinking .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1e90ff;       /* cor igual ao botão azul */
  animation: analu-dot 0.9s infinite ease-in-out;
}

#analu-thinking .dot:nth-child(2) { animation-delay: 0.15s; }
#analu-thinking .dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes analu-dot {
  0%, 80%, 100% { opacity: .2; transform: translateY(0); }
  40%          { opacity: 1;  transform: translateY(-4px); }
}

/* === MOBILE (≤480px) – reduzir avatar, mantendo 2 colunas === */
@media (max-width: 480px) {
  .landing-intro.refined-intro {
    /* mantém as duas colunas: texto 2fr + avatar */
    grid-template-columns: 2fr auto;
    gap: 16px;        /* você já tinha 32px, pode reduzir se desejar */
    padding: 0 12px;  /* ajuste de padding se precisar */
  }

  /* força o avatar menor: largura fixa, altura respeita aspect-ratio */
  .intro-avatar {
    width: 120px;     /* escolha o valor que preferir (ex: 100, 120, 140) */
    max-width: 120px;
  }
  
  /* se usar container com aspect-ratio, opcionalmente limite também ali */
  .intro-avatar .analu-animated-container {
    max-width: 120px !important;
    width: 100% !important;
  }
}

/* === padrão (chat lateral branco/azulado) === */
/* === bolha padrão (valem para landing e chat lateral) === */
.analu-msg { 
  background: transparent;
  color: #002244; /* texto escuro no modo light */
  padding: 12px 14px; 
  border-radius: 10px; 
  margin: 8px 0; 
  border: 1px solid rgba(0,34,68,0.3); /* borda azul escura translúcida */
}

.analu-msg.alt { 
  background: transparent;
  border: 1px solid rgba(0,34,68,0.5); 
}

/* === modo claro === */
html:not(.dark) .analu-msg { 
  background: transparent;
  color: #002244;
  border: 1px solid rgba(0,34,68,0.3);
}

html:not(.dark) .analu-msg.alt { 
  background: transparent;
  border: 1px solid rgba(0,34,68,0.5);
}

/* === modo escuro === */
html.dark .analu-msg { 
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.3);
}

html.dark .analu-msg.alt { 
  background: transparent;
  border: 1px solid rgba(255,255,255,0.5);
}

/* === ÁREAS DE MENSAGENS COM SCROLL === */

/* Landing (meio da tela): o contêiner que recebe as bolhas */
.analu-body {
  /* define uma altura máxima razoável e ativa rolagem vertical */
  max-height: clamp(260px, 40vh, 520px);
  overflow-y: auto;
  padding-right: 6px;              /* espaço pro trilho da barra */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent; /* thumb + trilho (Firefox) */
}
.analu-body::-webkit-scrollbar { width: 8px; }
.analu-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.analu-body::-webkit-scrollbar-track { background: transparent; }

/* Chat flutuante (lateral): o contêiner de mensagens */
#analu-messages {
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
#analu-messages::-webkit-scrollbar { width: 8px; }
#analu-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
#analu-messages::-webkit-scrollbar-track { background: transparent; }

/* Opcional: como as bolhas não precisam rolar internamente,
   garantimos que elas mesmas não ocultem conteúdo por overflow */
.analu-body .analu-msg,
#analu-messages .analu-msg {
  overflow: visible;
  max-height: none;
}

/* === LANDING: libera o contêiner e põe o scroll na .analu-body === */

/* .analu-message NÃO deve limitar altura na landing */
.landing-intro.refined-intro .analu-message {
  max-height: none !important;
  overflow: visible !important;
}

/* a área que recebe as bolhas vira o scroller */
.analu-body {
  max-height: clamp(260px, 40vh, 520px);
  overflow-y: auto;
  padding-right: 6px;
  -webkit-overflow-scrolling: touch; /* suaviza no iOS/Safari */

  /* barras finas */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.analu-body::-webkit-scrollbar { width: 8px; }
.analu-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.analu-body::-webkit-scrollbar-track { background: transparent; }

/* só pra garantir: as bolhas não têm scroll interno */
.analu-body .analu-msg { overflow: visible; max-height: none; }

/* Links dentro das mensagens da Analu */
.analu-msg a,
.analu-msg a:visited {
  color: #3b82f6;      /* azul vibrante (ajusta para o tom que quiser) */
  text-decoration: none;
}

.analu-msg a:hover {
  text-decoration: underline; /* só no hover, se quiser */
}
