/* Chat V4 - Grid Layout WhatsApp Premium */
:root {
    --wa-bg: #0b141a;
    --wa-header: #202c33;
    --wa-input: #2a3942;
    --wa-green: #00a884;
    --wa-text: #e9edef;
    --wa-bubble-sent: #056162;
    --wa-bubble-recv: #262d31;
}

.chat-fab-btn {
    position: relative;
    /* Para ancorar o badge */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wa-green);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff5252;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid var(--wa-bg);
}

.chat-modal {
    position: fixed;
    bottom: 95px;
    right: 25px;
    width: 380px;
    height: 600px;
    background: var(--wa-bg);
    border-radius: 12px;
    display: grid;
    grid-template-rows: 60px 1fr;
    /* Header + Content(List/Win) */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    z-index: 10001;
}

@media (max-width: 600px) {
    .chat-modal {
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
    }
}

.chat-modal.hidden {
    display: none !important;
}

/* Header - Garantir Alinhamento à Esquerda */
.chat-header {
    background: var(--wa-header);
    color: var(--wa-text);
    padding: 0 4px;
    /* Reduzido ao máximo */
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-back-btn {
    background: none;
    border: none;
    color: var(--wa-green) !important;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    margin-left: -4px;
    /* No corner */
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header-info h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#chat-subtitle {
    font-size: 0.75rem;
    color: #8696a0;
}

.chat-header-actions {
    display: flex;
    gap: 10px;
}

.chat-header-actions button {
    background: none;
    border: none;
    color: #8696a0;
    font-size: 1.2rem;
    cursor: pointer;
}

/* User List */
.chat-user-list {
    overflow-y: auto;
    background: #111;
}

.chat-user-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #222;
    cursor: pointer;
}

.chat-user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 15px;
    background: #333;
    object-fit: cover;
}

.chat-user-name {
    font-weight: 500;
    color: white;
}

/* Window */
.chat-window {
    display: grid;
    grid-template-rows: 1fr 65px;
    /* Messages + Footer */
    height: 100%;
    overflow: hidden;
}

.chat-messages {
    overflow-y: auto;
    padding: 15px;
    background: var(--wa-bg) url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    position: relative;
}

.msg-sent {
    background: var(--wa-bubble-sent);
    color: white;
    align-self: flex-end;
    border-top-right-radius: 2px;
}

.msg-received {
    background: var(--wa-bubble-recv);
    color: white;
    align-self: flex-start;
    border-top-left-radius: 2px;
}

.msg-time {
    display: block;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: right;
    margin-top: 4px;
}

/* Footer - Garantir Visibilidade */
.chat-input-area {
    background: var(--wa-header);
    padding: 0 4px;
    /* Extremo esquerdo absoluto */
    display: flex;
    align-items: center;
    gap: 4px;
    /* Mínimo espaço entre + e input */
    height: 65px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#chat-media-btn {
    border: none;
    background: none;
    color: #8696a0;
    font-size: 26px;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-input-container {
    flex: 1;
    background: var(--wa-input);
    border-radius: 20px;
    /* Mais oval para caber mais texto */
    padding: 8px 15px;
    display: flex;
    align-items: center;
    min-height: 40px;
    max-height: 120px;
    /* Aproximadamente 3-4 linhas */
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.25;
    height: 24px;
    max-height: 100px;
    overflow-y: auto;
    scrollbar-width: none !important;
    /* Firefox */
    -ms-overflow-style: none !important;
    /* IE and Edge */
}

#chat-input::-webkit-scrollbar {
    display: none !important;
    /* Safari/Chrome */
    width: 0 !important;
}

#chat-send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--wa-green);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

#chat-input::-webkit-scrollbar {
    display: none;
}