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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    overflow: hidden;
    background: #111b21;
}

.hidden {
    display: none !important;
}

/* ==================== LOADING SCREEN ==================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #111b21;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 40vh 0 8vh 0;
}

.whatsapp-logo {
    width: 80px;
    height: 80px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.meta-logo {
    width: 120px;
    opacity: 0.6;
}

/* ==================== CHAT CONTAINER ==================== */
#chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #0b141a;
}

/* ==================== HEADER ==================== */
.chat-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #202c33;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-button {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.back-button:hover {
    color: #d1d7db;
}

.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-info {
    display: flex;
    flex-direction: column;
}

.contact-name {
    color: #e9edef;
    font-size: 16px;
    font-weight: 400;
}

.contact-status {
    color: #8696a0;
    font-size: 13px;
}

.header-right {
    display: flex;
    gap: 20px;
}

.icon-button {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.icon-button:hover {
    color: #d1d7db;
}

/* ==================== MESSAGES AREA ==================== */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 80px 8% 120px 8%; /* 80px top para header, 120px bottom para footer (aumentado para Android) */
    background-color: #0b141a;
    position: relative;
}

/* Papel de parede - Tema Escuro */
.messages-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://i.ibb.co/YFyKHX97/62.webp');
    background-repeat: repeat;
    background-size: auto;
    opacity: 0.1;
    z-index: 0;
    pointer-events: none;
}

.message {
    display: flex;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    position: relative;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: #005c4b;
    color: #e9edef;
}

.message.received .message-bubble {
    background: #202c33;
    color: #e9edef;
}

.message-text {
    font-size: 14.2px;
    line-height: 19px;
    margin-bottom: 2px;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    color: #8696a0;
    text-align: right;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
}

.message.sent .message-time {
    color: #8696a0;
}

.checkmark {
    display: inline-flex;
    align-items: center;
}

.checkmark svg {
    width: 16px;
    height: 16px;
}

/* Checkmark cinza - enviada (1 visto) */
.checkmark-sent svg path {
    fill: #8696a0;
}

/* Checkmark cinza - recebida (2 vistos) */
.checkmark-received svg path {
    fill: #8696a0;
}

/* Checkmark azul - lida (2 vistos azuis) */
.checkmark-read svg path {
    fill: #53bdeb;
}

/* ==================== AUDIO MESSAGE ==================== */
.audio-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 7px 8px 9px;
    min-width: 280px;
}

.audio-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.audio-play-button {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.audio-waveform {
    flex: 1;
    height: 30px;
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.waveform-bar {
    width: 3px;
    background: #8696a0;
    border-radius: 2px;
    transition: background 0.1s ease;
    flex-shrink: 0;
}

.waveform-bar.played {
    background: #53bdeb;
}

.audio-duration {
    font-size: 11px;
    color: #8696a0;
    flex-shrink: 0;
    min-width: 30px;
}

.audio-profile-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    margin-left: 4px;
}

.audio-profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==================== IMAGE MESSAGE ==================== */
.image-message {
    max-width: 300px;
    border-radius: 7.5px;
    overflow: hidden;
    background: #202c33;
}

.image-message img {
    width: 100%;
    display: block;
}

.image-caption {
    padding: 6px 7px 8px 9px;
}

/* ==================== BUTTON MESSAGE ==================== */
.button-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.message-button {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    color: #00a884;
    font-size: 14px;
    font-weight: 400;
    padding: 10px 16px;
    cursor: pointer;
    text-align: center;
    border-radius: 6px;
    transition: background 0.2s;
    box-shadow: none;
}

.message-button:hover {
    background: #f5f5f5;
}

.message-button:active {
    background: #eeeeee;
}

/* ==================== DATE DIVIDER ==================== */
.date-divider {
    text-align: center;
    margin: 16px 0;
}

.date-badge {
    display: inline-block;
    background: #202c33;
    color: #8696a0;
    padding: 5px 12px;
    border-radius: 7.5px;
    font-size: 12.5px;
}

/* ==================== FOOTER ==================== */
.chat-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #202c33;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 62px;
    z-index: 100;
}

.input-container {
    flex: 1;
    background: #2a3942;
    border-radius: 21px;
    padding: 9px 12px;
}

#message-input {
    width: 100%;
    background: none;
    border: none;
    color: #e9edef;
    font-size: 15px;
    outline: none;
}

#message-input::placeholder {
    color: #8696a0;
}

#message-input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==================== LIGHT THEME ==================== */
body.light-theme {
    background: #f0f2f5;
}

body.light-theme #loading-screen {
    background: #f0f2f5;
}

body.light-theme #chat-container {
    background: #efeae2;
}

body.light-theme .chat-header {
    background: #f0f2f5;
}

body.light-theme .contact-name {
    color: #111b21;
}

body.light-theme .contact-status {
    color: #667781;
}

body.light-theme .icon-button,
body.light-theme .back-button {
    color: #54656f;
}

body.light-theme .icon-button:hover,
body.light-theme .back-button:hover {
    color: #111b21;
}

body.light-theme .messages-area {
    background-color: #efeae2;
}

/* Papel de parede - Tema Claro */
body.light-theme .messages-area::before {
    background-image: url('https://i.ibb.co/YFyKHX97/62.webp');
    opacity: 0.25; /* Opacidade um pouco maior no tema claro */
}

body.light-theme .message.sent .message-bubble {
    background: #d9fdd3;
    color: #111b21;
}

body.light-theme .message.received .message-bubble {
    background: #ffffff;
    color: #111b21;
}

body.light-theme .message-time {
    color: #667781;
}

body.light-theme .message.sent .message-time {
    color: #667781;
}

body.light-theme .date-badge {
    background: #ffffff;
    color: #667781;
}

body.light-theme .chat-footer {
    background: #f0f2f5;
}

body.light-theme .input-container {
    background: #ffffff;
}

body.light-theme #message-input {
    color: #111b21;
}

body.light-theme #message-input::placeholder {
    color: #667781;
}

body.light-theme .audio-play-button,
body.light-theme .audio-duration,
body.light-theme .waveform-bar {
    color: #667781;
}

body.light-theme .image-message {
    background: #ffffff;
}

body.light-theme .message-button {
    color: #027eb5;
}

body.light-theme .message-button:hover {
    background: rgba(2, 126, 181, 0.1);
}

/* Checkmarks no tema claro */
body.light-theme .checkmark-sent svg path {
    fill: #667781;
}

body.light-theme .checkmark-received svg path {
    fill: #667781;
}

body.light-theme .checkmark-read svg path {
    fill: #53bdeb;
}

/* Waveform no tema claro */
body.light-theme .waveform-bar.played {
    background: #09d261;
}

/* ==================== SCROLLBAR ==================== */
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: rgba(134, 150, 160, 0.3);
    border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(134, 150, 160, 0.5);
}

body.light-theme .messages-area::-webkit-scrollbar-thumb {
    background: rgba(102, 119, 129, 0.3);
}

body.light-theme .messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 119, 129, 0.5);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .messages-area {
        padding: 80px 5% 150px 5%; /* 150px bottom para evitar corte no Android */
    }
    
    /* Ajuste para barra do navegador mobile (iPhone) */
    .chat-footer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    
    .message-bubble {
        max-width: 80%;
    }
    
    .audio-message {
        min-width: 260px;
    }
    
    .audio-waveform {
        gap: 1px;
    }
    
    .waveform-bar {
        width: 2px;
    }
}

/* ==================== VIDEO MESSAGE ==================== */
.video-message {
    position: relative;
    max-width: 300px;
}

.video-message video {
    width: 100%;
    max-width: 300px;
    border-radius: 8px 8px 0 0;
    display: block;
}

.video-caption {
    padding: 8px 12px;
    background: transparent;
}

.video-caption .message-text {
    margin-bottom: 4px;
}

.video-caption .message-time {
    font-size: 11px;
    color: #8696a0;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

/* Video no tema claro */
body.light-theme .video-caption .message-time {
    color: #667781;
}

