* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    height: 100vh; /* Altura total da tela */
    display: flex; /* O BODY agora é o container flex */
    background-color: #f0f2f5;
    overflow: hidden; /* Impede rolagem na página inteira */
}

/* --- BARRA LATERAL (Usa ID #) --- */
#sidebar {
    width: 350px; /* Largura fixa */
    background-color: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    padding: 15px;
    background-color: #f0f2f5;
    border-bottom: 1px solid #ddd;
    font-weight: bold;
    height: 60px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

#contact-list {
    flex: 1; /* Ocupa o resto do espaço vertical */
    overflow-y: auto; /* ROLAGEM AQUI */
    overflow-x: hidden;
}

.contact-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}
.contact-item:hover { background-color: #f5f5f5; }
.contact-item.active { background-color: #e9edef; }

.contact-name { font-weight: bold; display: block; }
.contact-phone { font-size: 0.8em; color: #666; }

/* --- ÁREA DO CHAT (Usa ID #) --- */
#chat-area {
    flex: 1; /* Ocupa todo o resto da largura */
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #efeae2; /* Cor de fundo do Wpp */
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png'); /* Pattern opcional */
    background-repeat: repeat;
}

#chat-header {
    padding: 15px;
    background-color: #f0f2f5;
    border-bottom: 1px solid #ddd;
    font-weight: bold;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#messages-list {
    flex: 1; /* Ocupa o espaço flexível */
    padding: 20px;
    overflow-y: auto; /* ROLAGEM AQUI */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Balões */
.message {
    max-width: 60%;
    padding: 10px 15px;
    border-radius: 7px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.message.inbound {
    align-self: flex-start;
    background: #fff;
    border-top-left-radius: 0;
}

.message.outbound {
    align-self: flex-end;
    background: #d9fdd3;
    border-top-right-radius: 0;
}

.msg-time {
    font-size: 0.7em;
    color: #999;
    display: block;
    text-align: right;
    margin-top: 5px;
}

/* Footer / Input */
#chat-footer {
    padding: 10px;
    background: #f0f2f5;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #fff;
    outline: none;
}

button {
    padding: 10px 15px;
    border-radius: 8px;
    border: none;
    background: #008069;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}