/* Estilos Gerais e de Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: transparent;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* Container Principal do Chat */
.chat-container {
  /* o que você já tinha */
  display: flex;
  flex-direction: column;
  width: 360px;
  height: 450px;
  max-width: 400px;
  background-color: #181818;
  border-radius: 12px;
  overflow: hidden;

  /* fixa no canto inferior direito */
  position: fixed;
  bottom: 20px;
  right: 20px;
  margin: 0;
  z-index: 9999;

  /* sombra + leve borda para destacar no fundo escuro */
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 8px 18px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}


/* Cabeçalho com Logo e Subtítulo */
.chat-header {
    position: relative; /* Essencial para que o 'position: absolute' do h2 funcione dentro dele */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    overflow: hidden;
    transition: all 0.5s ease-out;
    margin-bottom: 20px;
}

/* PASSO 2: O vídeo fica na camada de baixo, como um elemento normal no centro. */
.logo-video {
    width: 70%;
    height: 70%;
    border-radius: 50%;
    object-fit: cover; /* Garante que o vídeo preencha o círculo */
    cursor: pointer;
}

/* PASSO 3: O título é retirado do fluxo normal e posicionado sobre tudo. */
.chat-header h2 {
    position: absolute; /* Coloca o h2 por cima do fluxo normal */
    top: 89%;           /* Posiciona o topo do elemento no meio verticalmente */
    left: 50%;          /* Posiciona a esquerda do elemento no meio horizontalmente */
    transform: translate(-50%, -50%); /* O truque para a centralização perfeita! */
    font-size: 2px;
    width: 80%; /* Garante que o texto tenha espaço para não quebrar de forma estranha */
    margin: 0;   /* Reseta a margem para evitar desalinhamentos */
    
    font-size: 1rem;
    font-weight: 500;
    z-index: 2; /* Garante que o texto fique na camada de cima */
    
    /* Efeito de Gradiente (mantido como estava) */
    background-image: linear-gradient(to right, #686868 0%, #ffffff 50%, #686868 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;

    /* Transição de opacidade (mantida como estava) */
    transition: opacity 0.5s ease-in-out;
}
/* Caixa de Mensagens */
.chat-box {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto; /* Habilita a rolagem vertical */
    display: flex;
    flex-direction: column;
    gap: 12px; /* Espaçamento entre as bolhas de mensagem */
}

/* Estilo Padrão para Bolhas de Mensagem */
.message {
    padding: 12px 18px;
    border-radius: 20px;
    line-height: 1.4;
    word-wrap: break-word;
    max-width: 75%;
}

/* Mensagem do Usuário (Direita, Azul) */
.user-message {
    background-color: #4491fa;
    color: #ffffff;
    align-self: flex-end; /* Alinha à direita */
    border-bottom-right-radius: 5px; /* Detalhe do design */
    white-space: pre-line; /* respeita quebras de linha se o usuário usar */
}

/* Mensagem da IA (Esquerda, Cinza) */
.ai-message {
    background-color: #262626;
    color: #e0e0e0;
    align-self: flex-start; /* Alinha à esquerda */
    border-bottom-left-radius: 5px; /* Detalhe do design */
    white-space: pre-line; /* >>> NOVO: respeita \n que a IA enviar */
}

/* Formulário de Input */
.chat-input-form {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid #262626;
}

#user-input {
    flex-grow: 1;
    border: none;
    background-color: #242424;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 22px; /* Borda arredondada */
    font-size: 1rem;
    outline: none; /* Remove a borda ao focar */
}

#user-input::placeholder {
    color: #777777;
}

/* NOVO E MAIS FORTE */
.chat-input-form #send-btn {
    background-color: #4491fa;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px; /* Esta regra agora deve vencer */
    min-height: 44px; /* Adicionado como garantia extra */
    min-width: 44px; /* Adicionado como garantia extra */
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}

#send-btn svg {
    fill: #ffffff;
    width: 20px;
    height: 20px;
}

/* Estilo do Botão quando Desabilitado */
#send-btn:disabled {
    background-color: #2a3a50; /* Cor mais escura para indicar inatividade */
    cursor: not-allowed;
}

.ImageP{
    display: none;
}

    .ImageMobile{
     display: none;
    }


.logo-video2{
  /* tamanho fluido mantendo proporção do vídeo */
  height: 100px;
  width: auto;
  display: block;
  object-fit: contain;

  /* melhora clique/seleção no header */
  pointer-events: none;
}



/* --- Estilização da Barra de Rolagem Customizada --- */

/* Para navegadores baseados em WebKit (Chrome, Safari, Edge) */
.chat-box::-webkit-scrollbar {
    width: 8px; /* Largura da barra */
}

.chat-box::-webkit-scrollbar-track {
    background: #1c1c1c; /* Cor do fundo da barra */
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb {
    background-color: #4491fa; /* A cor azul do seu tema */
    border-radius: 10px;      /* Bordas arredondadas */
    border: 2px solid #1c1c1c; /* Cria uma pequena borda em volta */
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background-color: #5d9eff; /* Cor um pouco mais clara ao passar o mouse */
}

/* Para Firefox */
.chat-box {
    scrollbar-width: thin; /* Deixa a barra mais fina */
    scrollbar-color: #4491fa #1c1c1c; /* Cor do "polegar" e do fundo */
}


/* No seu .chat-header existente, adicione a linha 'transition' */
.chat-header {
    padding: 20px;
    text-align: center;
    overflow: hidden; /* Adicionado para evitar que o conteúdo vaze durante a animação */
    transition: all 0.5s ease-out; /* <- ADICIONE ESTA LINHA */
}

/* Adicione esta nova regra ao final do seu CSS */
.chat-header.hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    opacity: 0;
}

/* --- Estilo para Links nas Mensagens da IA --- */
.ai-message a {
    color: #4491fa;
    text-decoration: underline;
    font-weight: 500;
}

/* --- Estilização do Indicador de Loading --- */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 6px; /* Espaço entre os pontos */
    padding: 14px 18px;
    background-color: #262626; /* Mesma cor das bolhas da IA */
    border-radius: 20px;
    align-self: flex-start; /* Alinha à esquerda */
    border-bottom-left-radius: 5px;
    margin-top: 10px;
}

.loading-indicator span {
    height: 8px;
    width: 8px;
    background-color: #4491fa; /* Nosso azul padrão */
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

/* Adiciona um atraso na animação de cada ponto para criar o efeito de onda */
.loading-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1.0);
    }
}

/* ========================= */
/*      MELHORIAS DE LISTA   */
/* ========================= */

/* prefixo (ex.: "Aqui estão os modelos:") acima da lista */
.ai-message .ai-preface {
    margin-bottom: 8px;
    font-weight: 600;
    color: #f0f0f0;
}

/* lista vertical gerada pelo formatAiContent */
.ai-message .ai-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-message .ai-list li {
    background: #1f1f1f;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 10px 12px;
    line-height: 1.35;
}


.desktop-header{
  display: flex;
  align-items: center;
  justify-content: space-between; /* <— space-between pedido */
  gap: var(--gap);
  height: var(--header-height);
  padding-inline: var(--inline-pad);
  background: var(--header-bg);
  color: var(--text);
  border-bottom: 1px solid var(--header-border);
  /* centraliza o conteúdo sem perder a faixa full-bleed */
  max-width: 100%;
  opacity: 0; 
  transition: opacity 500ms ease; 
}

.desktop-header:not(.hidden) { opacity: 1; }

@media (min-width: 1200px){
  .desktop-header{
    margin-inline: auto;
    max-width: var(--maxw);
    border-left: 1px solid var(--header-border);
    border-right: 1px solid var(--header-border);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
  }
}

/* Esconder em telas menores (somente desktop visível)
   — usa 1024px como corte; ajuste se quiser outro breakpoint */
@media (max-width: 1023.98px){
  .desktop-header{ display: none; }
}

/* ===========================
   Grupo esquerdo (logo + título)
   =========================== */

.desktop-header{
  display: flex;
  align-items: center;
  width: 100%;
  height: 100px;
  background: #181818;
}

.desktop-header-t1{
  display: flex;
  align-items: center;
}


.desktop-header-t1 h2{
  margin: 0;
  font-weight: 700;
  font-size: var(--title-size);
  line-height: 1.1;
  letter-spacing: 0.2px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.desktop-header-t1 h1{
  display: none;
}

/* ===========================
   Grupo direito (botão voltar)
   =========================== */
.desktop-header-t2{
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-btn2{
  --btn-size: clamp(36px, 5vw, 42px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--btn-size);
  height: var(--btn-size);
  border-radius: 999px;
  border: 1px solid var(--header-border);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  line-height: 1;
  background: #4491fa;
  transition: transform .12s ease, background .2s ease, border-color .2s ease;
  will-change: transform;
  margin-right: 16px;
  cursor: pointer;
}

.back-btn2:hover{
  transform: translateY(-1px);
  filter: brightness(0.9);
}

.back-btn2:active{
  transform: translateY(0);
}

.back-btn2:focus-visible{
  outline: 2px solid transparent;
  box-shadow:
    0 0 0 3px rgba(125, 211, 252, 0.55),
    0 0 0 6px rgba(125, 211, 252, 0.18);
}

/* ===========================
   Modo claro opcional (se usar prefers-color-scheme)
   =========================== */
@media (prefers-color-scheme: light){
  :root{
    --header-bg: #ffffff;
    --header-border: rgba(0,0,0,0.08);
    --text: #0d0f17;
    --muted: #4a4f5a;
  }
  .back-btn2:hover{
    border-color: rgba(14, 165, 233, 0.35);
    background: linear-gradient(180deg, rgba(14,165,233,0.06), rgba(0,0,0,0.01));
  }
}

.linha{
    width: 100%;
    height: 2px;
    background: #222222;
}

.hidden { display: none !important; }

.btn-sair-inicio{
    padding: 1rem;
}


/* Responsividade para Dispositivos Móveis */
@media (max-width: 600px) {
    body {
        height: -webkit-fill-available; /* Ajuste para iOS */
        height: 100vh;
    }

    .chat-header h2 {
    position: absolute; /* Coloca o h2 por cima do fluxo normal */
    top: 80%;           /* Posiciona o topo do elemento no meio verticalmente */
    left: 50%;          /* Posiciona a esquerda do elemento no meio horizontalmente */
    transform: translate(-50%, -50%); /* O truque para a centralização perfeita! */
    width: 80%; /* Garante que o texto tenha espaço para não quebrar de forma estranha */
    margin: 0;   /* Reseta a margem para evitar desalinhamentos */
    
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 2; /* Garante que o texto fique na camada de cima */
    
    /* Efeito de Gradiente (mantido como estava) */
    background-image: linear-gradient(to right, #686868 0%, #ffffff 50%, #686868 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;

    /* Transição de opacidade (mantida como estava) */
    transition: opacity 0.5s ease-in-out;
}

.desktop-header-t1 h2{
  display: none;
}

.desktop-header-t1 h1{
  margin: 0;
  font-weight: 700;
  font-size: var(--title-size);
  line-height: 1.1;
  letter-spacing: 0.2px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

    .chat-container {
        border-radius: 0;
        width: 300px;
        height: 450px;
        max-width: 300px;
        border-radius: 14px;

    }


    .chat-header {
        padding-top: 10px; /* Mais espaço no topo em celulares */
    }

    .chat-input-form {
        padding: 10px;
    }

    #user-input {
        padding: 10px 18px;
    }
    .logo-video {
        display: none;
    }

    .SubTitle h2 {
        display: block;
        font-size: 8px;
    }

    .ImageP{
        display: block;
        width: 50%;
        margin-bottom: 10px;
    }

    .ImageMobile{
     display: block;
     width: 100px;
    }

    .logo-video2 {
        display: none;
    }
    /* ------- FIX: input sempre visível no mobile ------- */
    .chat-input-form {
        position: relative;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        /* Fallback simples + ajuste com safe areas (iOS) */
        bottom: 36px; /* ajuste este valor se quiser ainda mais pra cima */
        bottom: max(env(safe-area-inset-bottom), 36px);
        /* em alguns navegadores, a função acima pode não estar disponível;
        o fallback "bottom: 36px" garante o afastamento */

        background-color: #181818;
        border-top: 1px solid #262626;
        padding: 12px 16px;
        z-index: 1000;
    }

    /* Quando você rola ou usa scrollIntoView, para um pouco acima do input/filtro */
    .chat-box {
        scroll-padding-bottom: calc(170px + max(env(safe-area-inset-bottom), 36px));
    }

    /* Garante espaço extra para a ÚLTIMA bolha sempre ficar acima do input/filtro */
    .chat-box > *:last-child {
        margin-bottom: calc(170px + max(env(safe-area-inset-bottom), 36px));
    }

    /* Se o seu código usa scrollIntoView no item (IA/usuário), dá folga no alinhamento */
    .chat-box > * {
        scroll-margin-bottom: calc(170px + max(env(safe-area-inset-bottom), 36px));
    }

}
