/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #d1d7db;
    /* WhatsApp web background outside chat */
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 100%;
    /* Permite ocupar a tela toda */
    height: 100%;
    background-color: #efeae2;
    /* Default WhatsApp chat background */
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Background Pattern Overlay */
.app-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('background.png');
    /* Public placeholder for WA bg */
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

/* Header */
.chat-header {
    background-color: #008069;
    color: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    /* Ensure image stays distinct */
    background: #f0f0f0;
    /* Fallback color */
    display: flex;
    justify-content: center;
    align-items: center;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.details {
    margin-left: 12px;
    display: flex;
    flex-direction: column;
}

.details .name {
    font-weight: 600;
    font-size: 16px;
}

.details .status {
    font-size: 13px;
    opacity: 0.8;
}

.header-actions .material-icons {
    margin-left: 20px;
    cursor: pointer;
    font-size: 24px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.date-divider {
    text-align: center;
    margin: 10px 0;
}

.date-divider span {
    background-color: #eef3f6;
    color: #5b6972;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 12px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.message {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
}

.bubble {
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    font-size: 14.2px;
    line-height: 19px;
    color: #111b21;
}

.message.received .bubble {
    background-color: #ffffff;
    border-top-left-radius: 0;
}

.message.sent .bubble {
    background-color: #d9fdd3;
    border-top-right-radius: 0;
}

.meta {
    float: right;
    margin-left: 10px;
    margin-top: 4px;
    font-size: 11px;
    color: #667781;
    display: flex;
    align-items: center;
}

.meta .material-icons {
    font-size: 14px;
    margin-left: 3px;
    color: #53bdeb;
    /* Blue ticks */
}

/* Input Area */
.input-area {
    background-color: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    z-index: 10;
}

.icon-btn {
    background: none;
    border: none;
    color: #54656f;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: #111b21;
}

#messageInput {
    flex: 1;
    margin: 0 10px;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
}

#sendBtn {
    color: #54656f;
}

#sendBtn:hover {
    color: #111b21;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}


/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 14px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    margin: 0 2px;
    background-color: #b5b5b5;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 60px;
    left: 0px;
    background: #fff;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    /* Hidden by default */
    grid-template-columns: repeat(8, 1fr);
    padding: 10px;
    gap: 5px;
    z-index: 100;
}

.emoji-picker.active {
    display: grid;
}

.emoji-item {
    font-size: 22px;
    cursor: pointer;
    text-align: center;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.emoji-item:hover {
    background-color: #f0f2f5;
}