/* ====================================================================
   PALETA DE CORES TEMA WHATSAPP
   ==================================================================== */
:root {
    --color-whatsapp-green: #075E54;
    --color-whatsapp-light-green: #25D366; 
    --color-whatsapp-bg: #EAE6DF;
    --color-whatsapp-my-bubble: #DCF8C6;
    --color-whatsapp-other-bubble: #FFFFFF;
    
    /* Cores de suporte */
    --color-card: #ffffff; 
    --color-text: #1F2933;
    --color-secondary: #6A7780;
    --color-danger: #dc3545;
    
    /* VARIÁVEL DE COMPENSAÇÃO DA BARRA DE NAVEGAÇÃO NATIVA */
    /* Valor de fallback fixo para WebViews antigos - 60px */
    --navbar-compensation: 60px; 
}

/* ====================================================================
   RESET BÁSICO E ESTRUTURA GERAL
   ==================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--color-whatsapp-bg); 
    color: var(--color-text);
    margin: 0;
    padding: 0; 
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; 
    box-sizing: border-box;
    overflow-y: hidden; 
}

/* ====================================================================
   1. ESTRUTURA E LAYOUT DO CHAT
   ==================================================================== */

.chat-wrapper {
    width: 100%;
    max-width: 600px;
    height: 100vh; 
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: relative;
}

@media (max-width: 650px) {
    .chat-wrapper {
        max-width: 100vw;
        height: 100vh; 
        border-radius: 0; 
        box-shadow: none;
    }
}

.card {
    background-color: var(--color-card);
    display: flex;
    flex-direction: column; 
    height: 100%;
    min-height: 100%; 
}

/* ====================================================================
   2. HEADER, STATUS E AVATAR
   ==================================================================== */

.chat-header {
    background-color: var(--color-whatsapp-green);
    color: white; 
    padding: 15px 20px;
    display: flex; 
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; 
}

.user-info { display: flex; align-items: center; gap: 10px; }
.details h1 { font-size: 1.15rem; margin: 0; font-weight: 500; }
.status-text { font-size: 0.8rem; color: rgba(255, 255, 255, 0.8); margin: 0; display: flex; align-items: center; gap: 4px; text-transform: capitalize; }

/* Avatar de Gênero */
.user-avatar { font-size: 28px; background-color: white; color: #999; border-radius: 50%; padding: 5px; line-height: 1; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-male { color: #007bff; }
.user-female { color: #ff69b4; }

/* Avatar Pequeno (Header do Usuário Logado) */
.user-avatar-small { font-size: 18px; padding: 3px; width: 24px; height: 24px; margin-right: 5px; opacity: 0.8; }
.user-avatar-small.user-male { background-color: rgba(0, 123, 255, 0.1); }
.user-avatar-small.user-female { background-color: rgba(255, 105, 180, 0.1); }

/* Avatar de Imagem */
.user-avatar.avatar-img,
.user-avatar-small.avatar-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-right: 0; 
}

.user-avatar-small.avatar-img {
    width: 24px;
    height: 24px;
    margin-right: 5px;
    opacity: 0.9;
}

/* Indicadores de Status */
.status-indicator { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-online { background-color: var(--color-whatsapp-light-green); }
.status-offline { background-color: #aaa; }

/* Área do Usuário Logado */
.current-user { color: rgba(255, 255, 255, 0.8); display: flex; align-items: center; font-size: 0.9rem; }

/* Estilos para o ícone clicável do avatar (usuário logado) */
#userAvatarClickable, .current-user .avatar-img {
    cursor: pointer;
    transition: opacity 0.2s;
}
#userAvatarClickable:hover, .current-user .avatar-img:hover {
    opacity: 0.8;
}

/* Estilo para o estado de upload (opcional) */
.user-avatar-uploading {
    opacity: 0.5 !important;
}


/* ====================================================================
   2.1. AÇÕES DO USUÁRIO E MENU DROP-DOWN (EDITAR PERFIL E SAIR)
   ==================================================================== */

.user-actions {
    position: relative; /* CRÍTICO: Define o contexto para o menu flutuante */
    display: flex;
    align-items: center;
}

.btn-menu {
    background: none;
    border: none;
    color: white;
    opacity: 0.8;
    padding: 5px;
    margin-left: 5px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-menu:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.btn-menu .material-icons {
    font-size: 24px;
}

/* O MENU SUSPENSO */
.dropdown-menu {
    position: absolute;
    top: 100%; 
    right: 0; /* Alinha o menu à direita */
    margin-top: 5px; 
    background-color: var(--color-card); 
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 50; 
    min-width: 180px;
    overflow: hidden;
}

.dropdown-menu.hidden {
    display: none;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.95rem;
    transition: background-color 0.1s;
}

.dropdown-item:hover {
    background-color: var(--color-whatsapp-bg); 
}

.dropdown-item .material-icons {
    margin-right: 10px;
    font-size: 20px;
    color: var(--color-secondary);
}


/* ====================================================================
   3. ÁREA DE MENSAGENS E BALÕES
   ==================================================================== */

.messages-area {
    flex-grow: 1; 
    padding: 10px 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px; 
    background-color: var(--color-whatsapp-bg); 
    -webkit-overflow-scrolling: touch;
}
.message { 
    max-width: 80%; 
    padding: 8px 10px; 
    border-radius: 8px; 
    line-height: 1.4; 
    word-wrap: break-word; 
    box-shadow: 0 1px 1px rgba(0,0,0,0.08); 
    display: flex; 
    flex-direction: column; 
    position: relative; 
}
.message .text { padding: 0; white-space: pre-wrap; }
.message.me { 
    align-self: flex-end; 
    background-color: var(--color-whatsapp-my-bubble); 
    color: var(--color-text); 
    border-bottom-right-radius: 4px; 
}
.message.other { 
    align-self: flex-start; 
    background-color: var(--color-whatsapp-other-bubble); 
    color: var(--color-text); 
    border: none; 
    border-bottom-left-radius: 4px; 
}
.deleted { font-style: italic; color: var(--color-secondary); font-size: 0.9em; display: flex; align-items: center; gap: 5px; }
.msg-footer { display: flex; justify-content: flex-end; align-items: center; margin-top: 2px; font-size: 0.7rem; color: #888; }
.delete-btn { background: none; border: none; color: inherit; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; padding: 0; margin-left: 5px; }
.delete-btn:hover { opacity: 1; }

/* Player de Áudio */
.audio-container audio { display: none; }
.audio-container { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.play-pause-btn { background: var(--color-whatsapp-green); color: white; border: none; border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px; line-height: 1; flex-shrink: 0; transition: background-color 0.2s; }
.speed-btn { background: transparent; color: inherit; border: 1px solid #aaa; border-radius: 15px; padding: 3px 6px; cursor: pointer; font-size: 12px; min-width: 35px; text-align: center; flex-shrink: 0; }
.audio-time { font-size: 12px; flex-grow: 1; text-align: right; }
.message.me .audio-time { color: rgba(0, 0, 0, 0.5); }
.message.other .audio-time { color: #888; }


/* ====================================================================
   5. INPUT E COMPOSITOR
   ==================================================================== */

.message-composer {
    padding: 8px 10px; 
    border-top: none; 
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
    
    display: flex;
    align-items: flex-end; 
    
    background-color: var(--color-whatsapp-bg); 
    gap: 8px;
    flex-shrink: 0;
    
    /* COMPENSAÇÃO PARA BARRA DE NAVEGAÇÃO NATIVA */
    padding-bottom: calc(8px + env(safe-area-inset-bottom)); 
    padding-bottom: calc(8px + var(--navbar-compensation));
}

/* Container flexível para input + emoji */
.input-and-emoji-wrapper {
    flex-grow: 1;
    flex-shrink: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
}

.message-input {
    flex-grow: 1;
    padding: 10px 45px 10px 15px; 
    border: none;
    border-radius: 20px;
    background-color: var(--color-card); 
    font-size: 1rem;
    min-height: 48px; 
    height: auto; 
    max-height: 100px; 
    overflow-y: auto; 
    resize: none;
    box-sizing: border-box;
}

/* Botão de Emoji (posicionado sobre o input) */
.control-btn.emoji-in-input {
    position: absolute;
    right: 5px;
    bottom: 0px;
    color: var(--color-secondary);
    font-size: 24px;
    height: 48px; 
    width: 40px;
    padding: 0;
    line-height: 48px;
    transition: color 0.2s;
    z-index: 10; 
    cursor: pointer;
}

/* Container dos botões de ação (Microfone/Enviar) */
.action-buttons {
    display: flex;
    align-items: flex-end;
    gap: 5px; 
    flex-shrink: 0;
}

/* Botões de Ação (Microfone e Enviar) */
.action-btn {
    background-color: var(--color-whatsapp-light-green); 
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px; 
    height: 48px; 
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    cursor: pointer;
    font-size: 24px;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background-color: #1DA851;
}

/* Visibilidade: Mantido vazio para forçar a exibição do botão de enviar (se houver problemas com o JS) */
.action-btn.hidden {
    /* display: none; - Geralmente usado pelo JS */
}

.mic-active {
    color: var(--color-danger); 
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.composer-disabled {
    text-align: center;
    color: var(--color-secondary);
    padding: 10px 0;
    width: 100%;
}


/* ====================================================================
   6. EMOJI PICKER - POSICIONAMENTO
   ==================================================================== */

.emoji-picker {
    position: absolute;
    /* COMPENSAÇÃO PARA BARRA DE NAVEGAÇÃO NATIVA */
    bottom: calc(64px + env(safe-area-inset-bottom)); 
    bottom: calc(64px + var(--navbar-compensation)); 
    
    right: 15px; 
    background-color: var(--color-card);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 20;
    max-width: 250px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.emoji-picker.hidden {
    display: none;
}

.emoji {
    cursor: pointer;
    font-size: 1.5rem;
    transition: transform 0.1s;
}

.emoji:hover {
    transform: scale(1.2);
}

/* Ajuste para telas menores */
@media (max-width: 650px) {
    .emoji-picker {
        right: 10px; 
        max-width: 90%; 
        left: auto;
    }
}
/* ====================================================================
   7. ESTILOS DA PÁGINA DE EDIÇÃO DE PERFIL
   (Se você for usar um arquivo separado, adicione isso ao seu CSS)
   ==================================================================== */

.profile-container {
    max-width: 450px;
    margin: 50px auto;
    background-color: var(--color-card);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.form-header {
    text-align: center;
    margin-bottom: 30px;
}
.form-header h2 {
    font-size: 1.5rem;
    color: var(--color-whatsapp-green);
    margin-top: 10px;
}
/* Estilos do Avatar */
.avatar-preview-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
}
.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-whatsapp-light-green);
}
.avatar-upload-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    background-color: var(--color-whatsapp-light-green);
    color: white;
    border-radius: 50%;
    padding: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s;
}
.avatar-upload-icon:hover {
    background-color: #1DA851; 
}
/* Estilos do Formulário */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--color-text);
}
.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.form-control:focus {
    border-color: var(--color-whatsapp-green);
    outline: none;
}
.btn-submit {
    width: 100%;
    padding: 12px;
    background-color: var(--color-whatsapp-green);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}
.btn-submit:hover {
    background-color: #054a42; 
}
/* Alertas e Links */
.alert-success { color: #155724; background-color: #d4edda; border-color: #c3e6cb; padding: 10px; border-radius: 4px; margin-bottom: 15px; }
.alert-danger { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; padding: 10px; border-radius: 4px; margin-bottom: 15px; }
.back-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: var(--color-whatsapp-green);
    text-decoration: none;
}

/* ====================================================================
   /* ====================================================================
   8. ESTILOS DE LOGIN (index.php) - Modernização da Interface
   ==================================================================== */

.login-page {
    background-color: #F0F2F5; /* Fundo cinza suave */
    /* Garante que o corpo da página de login ocupe todo o viewport */
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-box {
    width: 100%;
    max-width: 400px; /* Pouco mais largo para um visual mais robusto */
    background-color: var(--color-card); /* Branco */
    padding: 40px;
    border-radius: 16px; /* Bordas mais suaves */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1); /* Sombra mais profunda e moderna */
    text-align: center;
    transition: all 0.3s ease-in-out;
}

.login-title {
    font-size: 2rem;
    color: var(--color-whatsapp-green);
    margin-bottom: 10px;
    font-weight: 700; /* Mais negrito */
}

.login-subtitle {
    font-size: 1rem;
    color: var(--color-secondary);
    margin-bottom: 30px;
    font-weight: 400;
}

/* Formulário e Grupos */
.login-form .form-group {
    margin-bottom: 25px; /* Mais espaço entre campos */
    text-align: left;
    position: relative; /* Para ícones flutuantes */
}

/* Ícones dentro dos inputs */
.login-form .form-group .material-icons {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-secondary);
    font-size: 1.3rem;
    transition: color 0.3s;
    z-index: 2;
}

.login-form label {
    display: none; /* Esconde o label para um design mais limpo, usando placeholder */
}

.login-form input {
    width: 100%;
    padding: 15px 15px 15px 50px; /* Aumenta o padding e adiciona espaço para o ícone */
    border: 2px solid #DDDDDD; /* Borda mais perceptível */
    border-radius: 12px;
    font-size: 1rem;
    color: var(--color-text);
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: #F8F8F8; /* Levemente cinza */
}

.login-form input:focus {
    border-color: var(--color-whatsapp-light-green); /* Verde vibrante no foco */
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2); /* Sombra suave */
    background-color: var(--color-card); /* Volta para branco no foco */
}

/* Ícone de foco - opcional, requer JS para mover o ícone, mas bom para referência */
.login-form input:focus + .material-icons {
    color: var(--color-whatsapp-light-green);
}

/* Botão de Login */
.btn-primary {
    background-color: var(--color-whatsapp-light-green); /* Verde brilhante */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background-color: var(--color-whatsapp-green);
    box-shadow: 0 4px 10px rgba(7, 94, 84, 0.3);
}

/* Alertas - Estilos mantidos, mas aprimorados */
.alert {
    border-radius: 8px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.login-info {
    margin-top: 35px;
    font-size: 0.85rem;
    color: var(--color-secondary);
}

/* Título de Teste */
.login-info strong {
    color: var(--color-text);
}
