/* ============================================
   WHATSAPP - Apenas Área de Mensagens
   (Sem header/input - usa header principal)
   ============================================ */

/* Container Principal */
#view-whatsapp {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: transparent !important;
    display: none;
    z-index: 50 !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    overflow: hidden;
}

#view-whatsapp.active-view {
    display: block !important;
}

/* ============================================
   MENSAGENS - Estilo idêntico ao #chatMessages
   ============================================ */

.wa-messages {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    padding-top: 100px; /* Espaço para o header principal */
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); /* Espaço para a dock */
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: transparent;
    z-index: 100;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.wa-messages::-webkit-scrollbar {
    width: 3px;
}

.wa-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

/* Mensagens - Estilo idêntico ao chat AI */
.wa-messages .msg {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.35;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.wa-messages .msg:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.wa-messages .msg.user {
    background: transparent;
    border: 1px solid var(--nav-border-color);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.wa-messages .msg.bot {
    background: transparent;
    border: 1px solid var(--text);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Loading message */
.wa-loading-msg {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

/* Empty state */
.wa-empty-msg {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* ============================================
   INPUT AREA - Para enviar mensagens
   ============================================ */

.wa-input-area {
    position: fixed;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 150;
    display: none;
}

/* Mostrar input quando WhatsApp chat está ativo */
body.wa-chat-active .wa-input-area {
    display: block;
}

/* Ajustar mensagens quando input está visível */
body.wa-chat-active .wa-messages {
    padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

.wa-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
}

.wa-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 15px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    font-family: inherit;
}

.wa-input:focus {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

.wa-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.wa-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    border-radius: 50%;
    background: var(--accent, #25D366);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, opacity 0.15s;
}

.wa-send-btn:active {
    transform: scale(0.92);
}

.wa-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wa-send-btn svg {
    width: 18px;
    height: 18px;
    stroke: #fff;
    fill: none;
}

/* Sending state */
.wa-send-btn.sending {
    pointer-events: none;
    opacity: 0.6;
}

.wa-send-btn.sending svg {
    animation: waSpin 1s linear infinite;
}

@keyframes waSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .wa-messages .msg {
        max-width: 85%;
        font-size: 14px;
    }

    .wa-messages {
        padding: 12px;
        padding-top: 90px;
        padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    }

    body.wa-chat-active .wa-messages {
        padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
    }

    .wa-input-area {
        padding: 10px 12px;
    }

    .wa-input {
        font-size: 16px; /* Prevent iOS zoom */
    }
}
