/* ==========================================================================
   JE SOLUÇÕES — WIDGET DE CHAT ONLINE COM EXPERIÊNCIA HUMANA
   Design System: Branco, Grafite (#111827 / #1F2937) e Vermelho JE (#E30613)
   Estilo: Natural, Elegante, WhatsApp-like, 100% Responsivo
   ========================================================================== */

:root {
  --je-red: #E30613;
  --je-red-hover: #C50410;
  --je-red-soft: rgba(227, 6, 19, 0.08);
  --je-graphite: #111827;
  --je-graphite-light: #1F2937;
  --je-graphite-muted: #4B5563;
  --je-gray-border: #E5E7EB;
  --je-gray-bg: #F9FAFB;
  --je-gray-chat-bg: #F3F4F6;
  --je-white: #FFFFFF;
  --je-green-online: #10B981;
  --je-shadow-float: 0 12px 36px -4px rgba(17, 24, 39, 0.22), 0 4px 12px rgba(227, 6, 19, 0.15);
  --je-shadow-bubble: 0 2px 6px rgba(0, 0, 0, 0.04);
  --je-radius-lg: 20px;
  --je-radius-bubble: 18px;
  --je-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --je-z-index: 999999;
}

/* ==========================================================================
   1. BOTÃO FLUTUANTE (LAUNCHER)
   ========================================================================== */
.je-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--je-z-index);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  outline: none;
  font-family: var(--je-font);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

.je-chat-launcher:hover {
  transform: translateY(-2px) scale(1.03);
}

.je-chat-launcher:active {
  transform: translateY(0) scale(0.97);
}

/* Tooltip/Pill de convite suave: oculto por padrão no Desktop */
.je-chat-launcher-pill {
  background: var(--je-white);
  color: var(--je-graphite);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--je-gray-border);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.je-chat-launcher-pill strong {
  color: var(--je-red);
}

/* Exibir texto somente quando necessário: hover ou foco por teclado (Desktop) ou convite mobile inicial */
.je-chat-launcher:hover .je-chat-launcher-pill,
.je-chat-launcher:focus-visible .je-chat-launcher-pill,
.je-chat-launcher-pill.is-mobile-invite {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* Botão Flutuante: TV JE 100% isolada, sem bola vermelha, círculos ou molduras */
.je-chat-launcher-avatar {
  position: relative;
  width: 92px;
  height: 92px;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.je-chat-launcher:hover .je-chat-launcher-avatar,
.je-chat-launcher:focus-visible .je-chat-launcher-avatar {
  transform: translateY(-2px) scale(1.04);
}

.je-chat-launcher:active .je-chat-launcher-avatar {
  transform: translateY(0) scale(0.96);
}

/* Container do Mascote com Sombra Direta na Silhueta e Ciclo Natural de Animação */
.je-launcher-mascot-container {
  position: relative;
  width: 92px;
  height: 92px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.20));
  pointer-events: none;
  animation: tvJeNaturalSway 9s ease-in-out infinite;
  transform-origin: 50% 90%;
}

@keyframes tvJeNaturalSway {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-2px) rotate(2.5deg);
  }
  50% {
    transform: translateY(0) rotate(0deg);
  }
  75% {
    transform: translateY(-1.5px) rotate(-2deg);
  }
}

.je-mascot-crossfade {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.je-mascot-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 280ms ease-in-out;
  pointer-events: none;
  will-change: opacity;
}

.je-mascot-layer.is-active {
  opacity: 1;
}

/* Ícone de fechar quando o chat estiver aberto */
.je-chat-launcher-avatar .je-icon-close {
  display: none;
}

.je-chat-launcher.is-active .je-launcher-mascot-container {
  display: none;
}

.je-chat-launcher.is-active .je-chat-launcher-pill {
  display: none !important;
}

.je-chat-launcher.is-active .je-chat-launcher-avatar .je-icon-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #E30613;
  color: #FFFFFF;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   2. JANELA PRINCIPAL DO CHAT (CONTAINER)
   ========================================================================== */
.je-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 590px;
  max-height: calc(100vh - 110px);
  max-height: calc(100dvh - 110px);
  background-color: var(--je-white);
  border-radius: var(--je-radius-lg);
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--je-z-index);
  font-family: var(--je-font);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  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;
}

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

/* ==========================================================================
   3. CABEÇALHO LIMPO E PROFISSIONAL (FUNDO BRANCO COM DETALHE VERMELHO #E30613)
   ========================================================================== */
.je-chat-header {
  background: #FFFFFF !important;
  border-top: 3.5px solid #E30613;
  border-bottom: 1px solid #F3F4F6;
  color: #111827;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

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

/* TV JE bem visível no cabeçalho (~52px de silhueta), sem círculos, badges ou molduras */
.je-chat-header-avatar {
  position: relative;
  width: 66px;
  height: 66px;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
}

.je-header-mascot-container {
  position: relative;
  width: 66px;
  height: 66px;
}

.je-chat-header-titles {
  display: flex;
  flex-direction: column;
}

.je-chat-header-title {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.25;
  color: #111827;
}

.je-chat-header-subtitle {
  font-size: 12px;
  color: #6B7280;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.je-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.je-chat-header-btn {
  background: #F3F4F6;
  border: none;
  color: #6B7280;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}

.je-chat-header-btn:hover {
  background: #E5E7EB;
  color: #111827;
}

.je-chat-header-btn:active {
  transform: scale(0.95);
}

.je-chat-header-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

/* ==========================================================================
   4. CORPO DE MENSAGENS (FEED) — LIMPO E AREJADO
   ========================================================================== */
.je-chat-body {
  flex: 1;
  background-color: #FAFAFA !important;
  background-image: none !important;
  padding: 16px;
  overflow-y: auto;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

/* Barra de rolagem discreta */
.je-chat-body::-webkit-scrollbar {
  width: 6px;
}
.je-chat-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
}

/* Aviso de contexto transparente / Data */
.je-chat-date-pill {
  align-self: center;
  background: #ECEFF1;
  color: #4B5563;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 2px;
}

/* Mensagem de Transparência (Assistente Virtual) */
.je-chat-transparency-badge {
  align-self: center;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  color: #4B5563;
  font-size: 11.5px;
  text-align: center;
  padding: 8px 14px;
  border-radius: 12px;
  max-width: 90%;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* ==========================================================================
   5. BALÕES DE MENSAGEM (BUBBLES)
   ========================================================================== */
.je-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: jeMsgFadeIn 0.18s ease-out;
}

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

.je-msg-row.is-user {
  align-self: flex-end;
  align-items: flex-end;
}

.je-msg-row.is-assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.je-msg-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

/* Balão do Visitante (Direita) */
.je-msg-row.is-user .je-msg-bubble {
  background: #111827;
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Balão do Assistente com TV JE Isolada (~34px) */
.je-msg-assistant-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.je-msg-avatar {
  width: 44px;
  height: 44px;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0;
  object-fit: contain;
  flex-shrink: 0;
  box-shadow: none !important;
  margin-bottom: 2px;
}

.je-msg-row.is-assistant .je-msg-bubble {
  background-color: #FFFFFF;
  color: #1F2937;
  border: 1px solid #E5E7EB;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Metadados: Hora e Checks */
.je-msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  margin-top: 3px;
  padding: 0 4px;
  color: #9CA3AF;
}

.je-msg-row.is-user .je-msg-meta {
  color: rgba(255, 255, 255, 0.7);
  justify-content: flex-end;
}

.je-msg-check {
  display: inline-flex;
  align-items: center;
}

.je-msg-check svg {
  width: 14px;
  height: 14px;
  stroke: #60A5FA;
  stroke-width: 2.2;
}

/* ==========================================================================
   6. INDICADOR DE DIGITAÇÃO REAL (TYPING INDICATOR)
   ========================================================================== */
.je-typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  animation: jeMsgFadeIn 0.15s ease-out;
}

.je-typing-bubble {
  background-color: #FFFFFF;
  border: 1px solid #E5E7EB;
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.je-typing-dot {
  width: 7px;
  height: 7px;
  background-color: #9CA3AF;
  border-radius: 50%;
  animation: jeTypingPulse 1.4s infinite ease-in-out;
}

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

@keyframes jeTypingPulse {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; background-color: #E30613; }
}

.je-typing-label {
  font-size: 11.5px;
  color: #6B7280;
}

/* Botão discreto para retornar às mensagens recentes */
.je-chat-scroll-bottom-btn {
  position: absolute;
  bottom: 84px;
  right: 18px;
  background: #FFFFFF;
  color: #111827;
  border: 1px solid #E5E7EB;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.je-chat-scroll-bottom-btn.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.je-chat-scroll-bottom-btn:hover {
  background: #F9FAFB;
}

/* ==========================================================================
   8. ÁREA DE ENTRADA DE TEXTO (FOOTER / DIGITAÇÃO CONFORTÁVEL)
   ========================================================================== */
.je-chat-footer {
  background-color: #FFFFFF;
  padding: 12px 14px 12px 14px;
  border-top: 1px solid #E5E7EB;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.je-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  position: relative;
}

.je-chat-input-wrapper {
  flex: 1;
  min-height: 48px;
  background-color: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 24px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.je-chat-input-wrapper:focus-within {
  border-color: #E30613;
  background-color: #FFFFFF;
  box-shadow: 0 0 0 2px rgba(227, 6, 19, 0.15);
}

.je-chat-textarea {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  color: #111827;
  resize: none;
  max-height: 96px;
  min-height: 24px;
  padding: 0;
  overflow-y: auto;
}

.je-chat-textarea::placeholder {
  color: #9CA3AF;
}

/* Botão Enviar Mensagem */
.je-chat-send-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border-radius: 50%;
  background-color: #E30613;
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.15s, opacity 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(227, 6, 19, 0.25);
}

.je-chat-send-btn:hover:not(:disabled) {
  background-color: #C50410;
  transform: scale(1.05);
}

.je-chat-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.je-chat-send-btn:disabled {
  background-color: #E5E7EB;
  color: #9CA3AF;
  box-shadow: none;
  cursor: default;
}

.je-chat-send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  margin-left: 2px;
}

.je-chat-footer-brand {
  font-size: 10.5px;
  color: #9CA3AF;
  text-align: center;
  user-select: none;
}

/* Alerta de erro de conexão / Rate limit */
.je-chat-error-banner {
  background: #FEF2F2;
  border-left: 3px solid #E30613;
  color: #991B1B;
  padding: 8px 12px;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: space-between;
  margin: 0 16px;
  border-radius: 4px;
}

/* ==========================================================================
   9. RESPONSIVIDADE MOBILE (TELAS <= 640px)
   ========================================================================== */
@media (max-width: 640px) {
  .je-chat-launcher {
    bottom: 16px;
    right: 16px;
  }

  .je-chat-launcher-avatar {
    width: 82px;
    height: 82px;
  }

  .je-launcher-mascot-container {
    width: 82px;
    height: 82px;
  }

  .je-chat-launcher-pill {
    display: none;
  }

  /* Convite mobile inicial por 3 segundos */
  .je-chat-launcher-pill.is-mobile-invite {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(0) !important;
  }

  .je-chat-launcher.is-active {
    display: none !important;
  }

  .je-chat-window {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    transform: translateY(100%);
    transform-origin: bottom center;
  }

  .je-chat-window.is-open {
    transform: translateY(0);
  }

  .je-chat-header {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px 16px;
  }

  .je-chat-header-avatar,
  .je-header-mascot-container {
    width: 58px;
    height: 58px;
  }

  .je-msg-avatar {
    width: 38px;
    height: 38px;
  }

  /* Altura mínima de 48px e tipografia mínima de 16px no mobile para evitar zoom indesejado no iOS/Android */
  .je-chat-textarea {
    font-size: 16px;
  }

  .je-chat-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* ==========================================================================
   10. ACESSIBILIDADE E MOVIMENTO REDUZIDO
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .je-chat-launcher,
  .je-chat-window,
  .je-launcher-mascot-container,
  .je-mascot-layer,
  .je-msg-avatar {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}

/* ==========================================================================
   11. NAVEGAÇÃO ESTRUTURADA E LINKS CLICÁVEIS NO CHAT
   ========================================================================== */
.je-chat-link {
  color: #E30613;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.18s ease;
  word-break: break-all;
  display: inline;
}

.je-chat-link:hover {
  color: #C50410;
  text-decoration-thickness: 2px;
}

.je-msg-row.is-user .je-chat-link {
  color: #93C5FD;
}

.je-msg-row.is-user .je-chat-link:hover {
  color: #BFDBFE;
}

/* Botões de Ação de Navegação Rápida */
.je-msg-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #E5E7EB;
}

.je-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: #FFF5F5;
  color: #E30613;
  border: 1px solid #FECACA;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 2px rgba(227, 6, 19, 0.04);
  -webkit-tap-highlight-color: transparent;
  width: fit-content;
  max-width: 100%;
}

.je-action-btn:hover {
  background: #E30613;
  color: #FFFFFF;
  border-color: #E30613;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(227, 6, 19, 0.2);
}

.je-action-btn:active {
  transform: translateY(0);
}

.je-action-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  flex-shrink: 0;
}

/* Destaque Visual Discreto da Seção Destino */
@keyframes jeSectionHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(227, 6, 19, 0.4);
    outline: 2px solid transparent;
  }
  25% {
    box-shadow: 0 0 0 8px rgba(227, 6, 19, 0.16);
    outline: 2px solid rgba(227, 6, 19, 0.85);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(227, 6, 19, 0);
    outline: 2px solid transparent;
  }
}

.je-section-highlight {
  animation: jeSectionHighlight 2.5s cubic-bezier(0.16, 1, 0.3, 1) !important;
  border-radius: 14px;
}

/* Marcador invisível para âncoras personalizadas */
.je-anchor-marker {
  display: block;
  position: relative;
  top: -88px;
  visibility: hidden;
  height: 0;
  margin: 0;
  padding: 0;
}

.planos-section,
.cobertura-section,
.jornada-panel {
  scroll-margin-top: 88px;
}

