/* =========================================================================
   1. RESET E ESTRUTURA BASE (HTML & BODY)
   ========================================================================= */
html {
    background-color: #e6e2db; /* Fundo cinza/bege para as laterais em monitores ultra-wide */
    scroll-padding-top: 80px;  /* Evita que o scroll mobile jogue o texto sob a barra fixa */
}

body {
    color: #301a0e;
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    margin: 0 auto;
    overflow: hidden; /* Mantém as barras estáticas e deixa o scroll apenas nos containers */
    font-size: clamp(1.35rem, 3vw, 1.2rem);
    max-width: 800px;
    background-color: #F9F7F3; 
    font-family: 'Georgia', 'Garamond', serif;
    align-items: center; 
}

p { 
    margin: 0 0 0.8em 0; 
    line-height: 1.4;   
    -webkit-hyphens: auto; 
    -ms-hyphen: auto; 
    hyphens: auto;
    text-align: justify;
}

/* Centralização universal de blocos responsivos (Largura máxima de 800px) */
.top-bar, .bottom-panel, #content-display, #chat-container {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 0;
}

/* =========================================================================
   2. BARRA SUPERIOR (TOP BAR) & COMPONENTES
   ========================================================================= */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
    display: flex;
    align-items: center;      
    padding: 10px 5px 12px 5px;
    padding-top: max(10px, env(safe-area-inset-top));
    background-color: #2c1d11; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.nav-left-container {
    display: flex;
    align-items: center;
    margin-left: 5px;        
    gap: 5px;
}

#logo {
    max-height: 28px;
    margin-top: 2px;
}

.brand-text {
    font-size: 1.2rem;
    font-family: 'Garamond', serif;
    letter-spacing: 0.5px;
    color: #f5f2eb;
}

/* Menu Select customizado (Pílula estilizada sem a seta nativa feia) */
#menuSelect {
    margin-left: 2px;
    background: #25180e;
    border: none;
    border-radius: 0 10px 0 10px;
    color: #f5f2eb;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 5px 25px 5px 10px;
    appearance: none; 
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 5px center;
}

#menuSelect option {
    background-color: #fff;
    color: #333;
}

/* Autenticação (Google Botão Pill-Shape) */
.auth-right-container {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 10px;       
}

.btn-auth-google {
    display: inline-flex;      
    align-items: center;       
    justify-content: center;   
    gap: 5px;                  
    background: #ffffff;
    color: #444444;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    font-family: 'Roboto', Arial, sans-serif;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-auth-google:hover {
    background-color: #fdfbf7;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.btn-auth-google svg {
    display: block; 
}

.btn-logout-google {
    background: transparent;
    color: #f5f2eb;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: 'Garamond', serif;
    transition: all 0.2s;
}

.btn-logout-google:hover {
    background: rgba(255,255,255,0.1);
    border-color: #f5f2eb;
}

/* =========================================================================
   3. CONTAINER DE MENAGENS (MURAL DO CHAT)
   ========================================================================= */
#chat-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    height: 100%;
    margin-top: 38px; /* Colado na top-bar por padrão no desktop */
    padding-bottom: 180px; /* Margem de escape para o texto rolar acima do input */
}

/* Balões de Mensagem */
.message {
    padding: 0;
    margin: 0;
    word-wrap: break-word;
}

.message.user {
    display: block;
    align-self: flex-end;
    margin: 0 16px 0 auto;  
    max-width: 80%;
    background-color: #E8F4EC;
    border-right: 3px solid #69c070; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border-radius: 12px 12px 2px 12px;
    padding: 16px;
    color: #333;
}

.message.bot {
    margin: 16px;
    text-indent: 18px;
    background-color: #FFFFFF;
    border-left: 3px solid #8b0000; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-radius: 12px 12px 12px 2px;
    padding: 18px 16px;
    line-height: 1.5;
    color: #2c2c2c;
    max-width: 84%;
}

/* Aviso de introdução do Chat */
#avisoInicial {
    padding: 20px;
    line-height: 1.5;
}

/* Correção Posição do Balão Vazio/Digitando no Mobile */
.message.bot:has(.typing-indicator) {
    align-self: flex-start;
    margin-left: 10px;
    margin-right: auto;
}

/* =========================================================================
   4. SISTEMA DE TELAS ESTÁTICAS (CONTENT DISPLAY)
   ========================================================================= */
#content-display {
    position: fixed;
    top: 54px;
    width: 100%;
    max-width: 800px; /* Garante que ele respeite o limite de 800px igual ao chat */
    left: 50%;        /* Empurra o elemento para a metade da tela */
    transform: translateX(-50%); /* Puxa metade da sua própria largura de volta, centralizando perfeitamente */
    height: calc(100vh - 54px); 
    background-color: white; 
    z-index: 500; 
    overflow-y: auto;
    margin: 0;
    padding: 0 0 180px 0;
    box-sizing: border-box; /* Garante que paddings não quebrem o tamanho */
}

/* Box interno onde os artigos fixos são exibidos */
.conteudo-interno, .aba-conteudo {
    background-color: white;
    margin: 0 auto; 
    min-height: 100%;
    max-width: 800px; 
    padding: 30px;
}

.artigo-container {
    text-indent: 20px;
    margin-top: 0;
}

/* Cabeçalhos internos das Abas */
.conteudo-interno h1, .aba-conteudo h1 {
    font-family: 'Garamond', serif;
    font-size: 1.8rem;
    color: #2c1d11; 
    margin-top: 10px;
    margin-bottom: 22px;
    border-bottom: 1px solid #eaeaea;
    padding-bottom: 15px;
}

.artigo-container h2 {
    font-size: 108%;
    color: #3d1e15;
    margin-top: 25px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-bottom: 5px;
    text-indent: 0;
}

/* Fotos internas dos artigos */
.imgArtigo {
    float: left;
    margin-right: 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    width: 150px;       
    max-width: 40%;     
}

/* Botão Flutuante de Fechar Página (✕) */
.btn-fechar {
    position: absolute;
    top: 15px;    
    right: 25px;        
    background-color: rgba(0, 0, 0, 0.05); 
    color: #442510;     
    border: none;
    border-radius: 50%; 
    width: 36px;
    height: 36px;
    font-size: 1.1rem;  
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out; 
    z-index: 101;        
}

.btn-fechar:hover {
    background-color: #8b0000; 
    color: #ffffff;            
    transform: scale(1.08);    
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); 
}

/* Customização interna da aba Metas */
.meta-item-usuario, .meta-item-ia {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 18px 8px 0;
    border-bottom: 1px solid rgb(124, 193, 124);
}

#incluirItemLista {
    margin: 10px;
    padding: 5px 0 10px 10px;
    font-weight: bold;
    color: #3d1e15;
}

/* =========================================================================
   5. PAINEL INFERIOR DE ENTRADA (BOTTOM PANEL)
   ========================================================================= */
.bottom-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    box-sizing: border-box;
    width: 100%;
    background-color: #2c1d11; 
    border-top: 1px solid rgba(255, 255, 255, 0.1); 
    padding: 14px 16px;
}

.input-container {
    display: flex;
    justify-content: center;
    border: none;
}

#input-mensagem {
    max-width: 680px;
    width: 100%;
    font-size: clamp(1.35rem, 3vw, 1.2rem);
    font-family: 'Garamond', serif;
    color: #2c1d11;
    outline: none;
    box-sizing: border-box;
    resize: none;
    background-color: #ececec;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08) !important;
    border: 1px solid #e0d8c8 !important;
    height: 60px !important; 
    border-radius: 30px !important; 
    padding: 15px 25px; /* Ajustado para alinhar perfeitamente o texto interno */
    overflow: hidden; /* O SEGREDO: Esconde a barra de rolagem cinza nativa do textarea */
    transition: all 0.3s ease;
}

/* Remove qualquer resquício de barra de rolagem em caixas de texto estruturadas */
#input-mensagem::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

#input-mensagem:focus {
    box-shadow: 0 8px 25px rgba(139, 0, 0, 0.15); 
    border-color: #2c1d11;
}

/* A barra superior do painel (Cronômetro e Status) */
.meta-bar {
    background-color: #2c1d11;
    border-radius: 20px 20px 0 0; 
    margin: 0 auto;
    max-width: 700px;
    padding: 8px 20px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20%; 
    color: white;
}

.btn-pausa {
    border-radius: 15px;
    border: none;
    background-color: #f5f2eb;
}

/* =========================================================================
   6. MICRO-INTERAÇÕES & ANIMAÇÕES (INDICADOR DE DIGITANDO)
   ========================================================================= */
#lapis { position: relative; left: -9px; top: 4px; }

#reticencias { 
    display: none; /* Escondido por padrão para não gerar o bug visual */
    position: relative; 
    left: -8px; 
    top: 3px; 
    color: rgb(208, 207, 207); 
    font-size: 130%; 
}

@keyframes escrevendo {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-10deg) translateY(-2px); }
  75% { transform: rotate(10deg) translateY(-1px); }
}

@keyframes onda {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

.escrevendo-ativo #lapis, 
.escrevendo-ativo #reticencias {
  display: inline-block;
}

.escrevendo-ativo #lapis {
  animation: escrevendo 0.6s infinite ease-in-out;
}

#reticencias span {
    width: 6px;
    height: 6px;
    background-color: rgb(254, 236, 210);
    border-radius: 50%;
    display: inline-block;
    animation: onda 1.4s infinite ease-in-out both;
}

#reticencias span:nth-child(1) { animation-delay: -0.32s; }
#reticencias span:nth-child(2) { animation-delay: -0.16s; }
#reticencias span:nth-child(3) { animation-delay: 0s; }

.escrevendo-ativo #reticencias {
    gap: 2px;
    margin-right: 5px;
    top: 3px;
    align-items: center;
    display: inline-flex;
}

/* =========================================================================
   7. REGRAS DE ADAPTAÇÃO RESPONSIVA (MEDIA QUERIES)
   ========================================================================= */

/* Tablets (Entre 601px e 1024px) */
@media (min-width: 601px) and (max-width: 1024px) {
    #chat-container {
        padding-top: 85px; 
        margin-top: 50px; 
        padding-bottom: 250px;
    }
    #content-display {
        padding-bottom: 250px;
    }
}

/* Celulares e Dispositivos Mobile (Abaixo de 600px) */
@media (max-width: 600px) {
    #chat-container {
        padding-top: 63px; 
        margin-top: 50px; 
    }
    #chat-container, #content-display {
        padding-bottom: 180px; 
    }
    .meta-bar {
        gap: 5%; 
        justify-content: space-evenly;
        padding: 7px 10px;
    }
    .btn-pausa {
        padding: 4px 8px; 
        font-size: 0.85rem;
    }
}