* {
    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: fixed; /* Alterado de absolute para fixed para acompanhar o scroll */
    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;
    transition: color 0.2s;
}

/* Status do Áudio (Cores WhatsApp) */
.message[data-read-status="unseen"] .audio-play-button {
    color: #00a884; /* Verde para não visualizado */
}

.message[data-read-status="seen"] .audio-play-button,
.message[data-read-status="playing"] .audio-play-button {
    color: #53bdeb; /* Azul para visualizado/visualizando */
}

.message[data-read-status="seen"] .audio-duration,
.message[data-read-status="playing"] .audio-duration {
    color: #53bdeb; /* Azul para visualizado/visualizando */
}

.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;
}

/* Status do Áudio Tema Claro */
body.light-theme .message[data-read-status="unseen"] .audio-play-button {
    color: #00a884;
}

body.light-theme .message[data-read-status="seen"] .audio-play-button,
body.light-theme .message[data-read-status="playing"] .audio-play-button {
    color: #027eb5;
}

body.light-theme .message[data-read-status="seen"] .audio-duration,
body.light-theme .message[data-read-status="playing"] .audio-duration {
    color: #027eb5;
}

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 {
    position: fixed; /* Garante que no tema claro também seja fixo */
    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;
}


/* ==================== POPUP DE AVISO DE CHAMADAS ==================== */
.call-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 14px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    max-width: 90%;
    width: auto;
    opacity: 0;
    transition: all 0.3s ease-out;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

.call-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 0.85;
    pointer-events: auto;
}

.call-notification-text {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    text-align: center;
}

/* Tema claro */
body.light-theme .call-notification {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
}

/* Responsive */
@media (max-width: 768px) {
    .call-notification {
        bottom: 90px;
        max-width: 85%;
        padding: 12px 18px;
    }
    
    .call-notification-text {
        font-size: 13px;
    }
}

/* ==================== PIX PAYMENT STYLES ==================== */
.pix-payment-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.pix-qrcode {
    background: white;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pix-qrcode img {
    display: block;
    width: 200px;
    height: 200px;
    border-radius: 8px;
}

.pix-info {
    width: 100%;
}

.pix-info p {
    color: #e9edef;
    margin: 8px 0;
    font-size: 14px;
    text-align: center;
}

.pix-code-container {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    margin: 8px 0;
    word-break: break-all;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: #e9edef;
    max-height: 80px;
    overflow-y: auto;
}

.pix-waiting-indicator {
    display: inline-block;
    animation: pulse-waiting 1.5s ease-in-out infinite;
    margin-right: 5px;
}

#pix-waiting-message .message-bubble {
    display: flex;
    min-width: 180px;
}

#pix-waiting-message .message-text {
    display: flex;
    gap: 8px;
}

@keyframes pulse-waiting {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Tema claro - PIX */
body.light-theme .pix-info p {
    color: #111b21;
}

body.light-theme .pix-code-container {
    background: rgba(0, 0, 0, 0.05);
    color: #111b21;
}

/* Estilo para botões de mensagem desabilitados */
.message-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.5);
}


/* ==================== MODAL DE CHAMADA DE VIDEO ==================== */
.video-call-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    background: #000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.video-call-modal.visible {
    opacity: 1;
    pointer-events: all;
}
.call-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}
.call-bg-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 0;
}
.call-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 80px;
    flex: 1;
}
.call-avatar-wrapper {
    position: relative;
    width: 130px;
    height: 130px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.call-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255,255,255,0.3);
    position: relative;
    z-index: 2;
}
.call-avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.call-avatar-ring {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    animation: ringPulse 2s ease-out infinite;
    z-index: 1;
}
.call-avatar-ring.ring1 { width: 150px; height: 150px; animation-delay: 0s; }
.call-avatar-ring.ring2 { width: 180px; height: 180px; animation-delay: 0.5s; }
.call-avatar-ring.ring3 { width: 210px; height: 210px; animation-delay: 1s; }
@keyframes ringPulse {
    0% { opacity: 0.6; transform: translate(-50%,-50%) scale(0.9); }
    100% { opacity: 0; transform: translate(-50%,-50%) scale(1.2); }
}
.call-contact-name { color: #fff; font-size: 24px; font-weight: 300; margin-bottom: 8px; text-align: center; }
.call-status-text { color: rgba(255,255,255,0.8); font-size: 16px; margin-bottom: 6px; display: flex; align-items: center; gap: 2px; }
.call-info-text { color: rgba(255,255,255,0.5); font-size: 13px; }
.typing-dots { display: inline-flex; gap: 2px; margin-left: 2px; }
.typing-dots span { animation: dotBlink 1.4s infinite; opacity: 0; }
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBlink { 0%,80%,100% { opacity: 0; } 40% { opacity: 1; } }
.call-actions-ringing {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 40px 0 60px 0;
    display: flex;
    justify-content: center;
}
.call-btn-group { display: flex; gap: 60px; align-items: center; justify-content: center; }
.call-btn-decline, .call-btn-answer {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    background: none; border: none; cursor: pointer; color: white; font-size: 13px; font-weight: 400;
}
.call-btn-icon {
    width: 68px; height: 68px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.call-btn-decline .call-btn-icon { background: #f44336; }
.call-btn-answer .call-btn-icon { background: #4caf50; animation: answerPulse 1.5s ease-in-out infinite; }
@keyframes answerPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(76,175,80,0.4); }
    50% { box-shadow: 0 0 0 12px rgba(76,175,80,0); }
}
.call-btn-decline:active .call-btn-icon,
.call-btn-answer:active .call-btn-icon { transform: scale(0.92); opacity: 0.85; }
#call-active-screen { background: #000; position: relative; }
#call-video {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover; z-index: 0;
}
.call-timer {
    position: absolute; top: 20px; right: 16px; z-index: 10;
    background: rgba(0,0,0,0.45); color: #fff;
    font-size: 14px; font-weight: 500; padding: 4px 10px;
    border-radius: 12px; font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px; backdrop-filter: blur(4px);
}
.call-active-controls {
    position: absolute; bottom: 40px; left: 50%;
    transform: translateX(-50%); z-index: 10;
}
.call-btn-camera {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff; font-size: 14px; font-weight: 500;
    padding: 10px 24px; border-radius: 24px; cursor: pointer;
    backdrop-filter: blur(8px); transition: background 0.2s, opacity 0.3s;
}
.call-btn-camera:hover { background: rgba(255,255,255,0.3); }
.security-verification-container {
    display: flex; flex-direction: column; align-items: center; padding: 4px 0; gap: 10px;
}
.security-icon { font-size: 32px; margin-bottom: 4px; }
.security-title { font-size: 16px; font-weight: 600; color: #e9edef; text-align: center; }
.security-text { font-size: 13.5px; color: #e9edef; line-height: 1.5; text-align: center; }
.security-pix-btn {
    background: #25D366 !important; color: #fff !important; border: none !important;
    font-weight: 600 !important; font-size: 13px !important; padding: 12px 16px !important;
    width: 100%; margin-top: 6px;
}
.security-pix-btn:hover { background: #1ebe5a !important; }
.security-pix-btn:disabled { background: #8696a0 !important; cursor: not-allowed !important; }
body.light-theme .security-title, body.light-theme .security-text { color: #111b21; }
.upsell-btn {
    background: linear-gradient(135deg, #ff6b35, #f7c59f) !important;
    color: #fff !important; border: none !important;
    font-weight: 700 !important; font-size: 13px !important; padding: 12px 16px !important;
    animation: upsellGlow 2s ease-in-out infinite;
}
@keyframes upsellGlow {
    0%,100% { box-shadow: 0 0 0 0 rgba(255,107,53,0.3); }
    50% { box-shadow: 0 0 12px 4px rgba(255,107,53,0.2); }
}
@media (max-width: 768px) {
    .call-contact-name { font-size: 20px; }
    .call-avatar-large { width: 100px; height: 100px; }
    .call-avatar-wrapper { width: 110px; height: 110px; }
    .call-btn-icon { width: 60px; height: 60px; }
    .call-btn-group { gap: 50px; }
    .call-timer { top: 16px; right: 12px; font-size: 13px; }
}

/* Miniatura do Vídeo do Usuário (Estilo WhatsApp) */
.user-video-container {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 100px;
    height: 150px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 100;
    border: 2px solid rgba(255,255,255,0.2);
    transition: opacity 0.5s ease;
}

.user-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Espelhar a câmera frontal */
}

.user-video-container.hidden {
    display: none !important;
    opacity: 0;
}
