*{
    margin:0;
    padding:0;
    box-sizing:border-box;
    font-family:Arial, sans-serif;
}

body{
    min-height:100vh;
    background:#f3f6ff;
    color:#111827;
    overflow:hidden;
}

.btn-perfil-chat{
    position:fixed;
    top:20px;
    right:22px;
    z-index:1000;
}

.btn-perfil-chat img{
    width:52px;
    height:52px;
    border-radius:50%;
    object-fit:cover;
    cursor:pointer;
    border:3px solid #fff;
    box-shadow:0 6px 18px rgba(0,0,0,.12);
}

.chat-page{
    margin-left:92px;
    height:100vh;
    padding:24px 86px 24px 28px;
    display:grid;
    grid-template-columns:360px minmax(0, 1fr);
    gap:22px;
}

.chat-sidebar,
.chat-main{
    background:#fff;
    border-radius:26px;
    box-shadow:0 10px 26px rgba(0,0,0,.07);
    overflow:hidden;
    min-height:0;
}

.chat-sidebar{
    display:flex;
    flex-direction:column;
}

.chat-sidebar-header{
    padding:24px;
    display:flex;
    justify-content:space-between;
    gap:14px;
    align-items:flex-start;
    border-bottom:1px solid #edf0f7;
}

.chat-sidebar-header h1{
    font-size:28px;
    margin-bottom:6px;
}

.chat-sidebar-header p{
    color:#6b7280;
    font-size:14px;
    line-height:1.4;
}

.btn-refresh{
    width:42px;
    height:42px;
    border:0;
    border-radius:14px;
    background:#edf2ff;
    color:#5277e8;
    cursor:pointer;
    font-size:19px;
}

.chat-search{
    margin:18px;
    height:44px;
    border-radius:18px;
    background:#f4f6fb;
    display:flex;
    align-items:center;
    padding:0 14px;
    gap:10px;
}

.chat-search input{
    border:0;
    outline:0;
    background:transparent;
    width:100%;
    font-size:15px;
}

.conversas-lista{
    overflow-y:auto;
    padding:0 14px 18px;
}

.conversa-item{
    width:100%;
    border:0;
    background:transparent;
    display:flex;
    gap:12px;
    text-align:left;
    padding:13px;
    border-radius:18px;
    cursor:pointer;
    align-items:center;
}

.conversa-item:hover,
.conversa-item.ativa{
    background:#edf2ff;
}

.conversa-avatar{
    width:48px;
    height:48px;
    border-radius:50%;
    object-fit:cover;
    flex:0 0 auto;
}

.conversa-info{
    min-width:0;
    flex:1;
}

.conversa-top{
    display:flex;
    justify-content:space-between;
    gap:8px;
    align-items:center;
}

.conversa-nome{
    font-weight:800;
    color:#111827;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.conversa-data{
    font-size:12px;
    color:#6b7280;
    flex:0 0 auto;
}

.conversa-preview{
    color:#6b7280;
    font-size:13px;
    margin-top:4px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.badge-lidas{
    background:#7494ec;
    color:white;
    font-size:12px;
    min-width:22px;
    height:22px;
    border-radius:999px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    margin-left:6px;
}

.chat-main{
    min-width:0;
}

.chat-empty{
    height:100%;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    padding:36px;
    color:#6b7280;
}

.chat-empty i{
    font-size:82px;
    color:#7494ec;
    margin-bottom:14px;
}

.chat-empty h2{
    color:#111827;
    font-size:30px;
    margin-bottom:8px;
}

.chat-box{
    height:100%;
    display:flex;
    flex-direction:column;
}

.chat-header{
    min-height:82px;
    padding:18px 24px;
    border-bottom:1px solid #edf0f7;
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:16px;
}

.chat-user-info{
    display:flex;
    align-items:center;
    gap:14px;
    min-width:0;
}

.chat-user-info img{
    width:52px;
    height:52px;
    border-radius:50%;
    object-fit:cover;
}

.chat-user-info h2{
    font-size:22px;
}

.chat-user-info p{
    color:#6b7280;
    font-size:14px;
}

.btn-profile{
    color:#5277e8;
    background:#edf2ff;
    text-decoration:none;
    padding:10px 14px;
    border-radius:16px;
    font-weight:700;
    white-space:nowrap;
}

.mensagens{
    flex:1;
    overflow-y:auto;
    padding:24px;
    background:linear-gradient(180deg, #f8faff 0%, #f3f6ff 100%);
}

.msg-row{
    display:flex;
    margin-bottom:12px;
}

.msg-row.minha{
    justify-content:flex-end;
}

.msg-bolha{
    max-width:min(620px, 78%);
    padding:12px 14px;
    border-radius:18px;
    background:#fff;
    color:#111827;
    box-shadow:0 4px 14px rgba(0,0,0,.06);
    line-height:1.45;
}

.msg-row.minha .msg-bolha{
    background:#7494ec;
    color:#fff;
    border-bottom-right-radius:6px;
}

.msg-row.outra .msg-bolha{
    border-bottom-left-radius:6px;
}

.msg-texto{
    white-space:pre-wrap;
    overflow-wrap:anywhere;
}

.msg-anexo{
    display:flex;
    align-items:center;
    gap:8px;
    margin-top:8px;
    padding:10px;
    border-radius:14px;
    background:rgba(17,24,39,.08);
    color:inherit;
    text-decoration:none;
    font-weight:700;
}

.msg-hora{
    display:block;
    margin-top:6px;
    font-size:11px;
    opacity:.75;
    text-align:right;
}

.composer{
    min-height:82px;
    padding:14px 18px;
    border-top:1px solid #edf0f7;
    display:flex;
    align-items:flex-end;
    gap:12px;
    background:#fff;
}

.btn-anexo,
.btn-enviar{
    width:46px;
    height:46px;
    border-radius:16px;
    border:0;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    font-size:21px;
    flex:0 0 auto;
}

.btn-anexo{
    background:#edf2ff;
    color:#5277e8;
}

.btn-enviar{
    background:#7494ec;
    color:#fff;
}

.composer-centro{
    flex:1;
    min-width:0;
}

#inputMensagem{
    width:100%;
    min-height:46px;
    max-height:130px;
    resize:none;
    border:0;
    outline:0;
    background:#f4f6fb;
    border-radius:18px;
    padding:13px 16px;
    font-size:15px;
}

.anexo-preview{
    margin-bottom:8px;
    background:#edf2ff;
    color:#3659c9;
    padding:8px 12px;
    border-radius:14px;
    font-size:13px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
}

.anexo-preview button{
    border:0;
    background:transparent;
    cursor:pointer;
    color:#3659c9;
    font-size:16px;
}

.estado-vazio{
    padding:22px;
    text-align:center;
    color:#6b7280;
}

body.dark-mode{
    background:#121212;
    color:#e0e0e0;
}

body.dark-mode .chat-sidebar,
body.dark-mode .chat-main,
body.dark-mode .composer{
    background:#1f1f1f;
    color:#e0e0e0;
}

body.dark-mode .chat-header,
body.dark-mode .chat-sidebar-header{
    border-color:#333;
}

body.dark-mode .mensagens{
    background:#151515;
}

body.dark-mode .conversa-nome,
body.dark-mode .chat-empty h2,
body.dark-mode .chat-user-info h2{
    color:#f3f4f6;
}

body.dark-mode .conversa-item:hover,
body.dark-mode .conversa-item.ativa,
body.dark-mode .btn-refresh,
body.dark-mode .btn-profile,
body.dark-mode .btn-anexo,
body.dark-mode .chat-search,
body.dark-mode #inputMensagem{
    background:#2a2a2a;
}

body.dark-mode .msg-bolha{
    background:#2b2b2b;
    color:#f3f4f6;
}

body.dark-mode .msg-row.minha .msg-bolha{
    background:#5277e8;
}

@media(max-width:900px){
    body{ overflow:auto; }

    .chat-page{
        margin-left:76px;
        padding:18px;
        height:auto;
        min-height:100vh;
        grid-template-columns:1fr;
    }

    .chat-sidebar{
        min-height:360px;
    }

    .chat-main{
        min-height:620px;
    }
}


/* ===== BOTAO APAGAR CONVERSA - INICIO ===== */

.chat-header-actions{
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;
    justify-content:flex-end;
}

.btn-delete-chat{
    border:none;
    background:#fee2e2;
    color:#b91c1c;
    padding:10px 14px;
    border-radius:16px;
    font-weight:800;
    cursor:pointer;
    white-space:nowrap;
}

.btn-delete-chat:hover{
    background:#dc2626;
    color:white;
}

body.dark-mode .btn-delete-chat{
    background:#3a1f1f;
    color:#fca5a5;
}

body.dark-mode .btn-delete-chat:hover{
    background:#dc2626;
    color:white;
}

@media(max-width:700px){
    .chat-header-actions{
        width:100%;
        justify-content:flex-start;
    }
}

/* ===== BOTAO APAGAR CONVERSA - FIM ===== */


/* ===== APAGAR MENSAGEM ESPECIFICA - INICIO ===== */

.msg-bolha{
    position:relative;
}

.btn-delete-msg{
    position:absolute;
    top:-8px;
    right:-8px;
    width:28px;
    height:28px;
    border:none;
    border-radius:50%;
    background:#fee2e2;
    color:#b91c1c;
    display:none;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    font-size:13px;
    box-shadow:0 4px 12px rgba(0,0,0,.18);
}

.msg-row.minha .msg-bolha:hover .btn-delete-msg{
    display:flex;
}

.btn-delete-msg:hover{
    background:#dc2626;
    color:white;
}

body.dark-mode .btn-delete-msg{
    background:#3a1f1f;
    color:#fca5a5;
}

body.dark-mode .btn-delete-msg:hover{
    background:#dc2626;
    color:white;
}

/* ===== APAGAR MENSAGEM ESPECIFICA - FIM ===== */





/* ===== FIX SIMPLES CHAT ALTURA - INICIO ===== */

html,
body{
    min-height:100%;
    overflow-x:hidden !important;
    overflow-y:auto !important;
}

.chat-page{
    height:calc(100vh - 36px) !important;
    min-height:650px !important;
    padding-bottom:36px !important;
}

.chat-main,
.chat-sidebar{
    height:100% !important;
    min-height:0 !important;
}

.chat-box{
    height:100% !important;
    min-height:0 !important;
    display:flex !important;
    flex-direction:column !important;
}

.chat-header{
    flex:0 0 auto !important;
}

.mensagens{
    flex:1 1 auto !important;
    min-height:0 !important;
    overflow-y:auto !important;
    padding-bottom:30px !important;
}

.composer{
    flex:0 0 auto !important;
    position:relative !important;
    bottom:auto !important;
    z-index:20 !important;
}

/* ===== FIX SIMPLES CHAT ALTURA - FIM ===== */


/* ===== FIX PREVIEW CONVERSA OVERFLOW - INICIO ===== */

.chat-sidebar{
    overflow:hidden !important;
}

.conversas-lista{
    overflow-y:auto !important;
    overflow-x:hidden !important;
}

.conversa-item{
    width:100% !important;
    max-width:100% !important;
    overflow:hidden !important;
}

.conversa-info{
    min-width:0 !important;
    max-width:100% !important;
    overflow:hidden !important;
    display:block !important;
}

.conversa-top{
    min-width:0 !important;
    max-width:100% !important;
    overflow:hidden !important;
}

.conversa-nome{
    min-width:0 !important;
    max-width:160px !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    white-space:nowrap !important;
}

.conversa-preview{
    display:block !important;
    width:100% !important;
    max-width:210px !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    white-space:nowrap !important;
}

/* Remove scrollbar horizontal que apareceu no bloco das conversas */
.conversas-lista::-webkit-scrollbar:horizontal{
    display:none !important;
}

/* ===== FIX PREVIEW CONVERSA OVERFLOW - FIM ===== */


/* ===== BOTAO BLOQUEAR UTILIZADOR - INICIO ===== */

.btn-block-user{
    border:none;
    background:#fff7ed;
    color:#c2410c;
    padding:10px 14px;
    border-radius:16px;
    font-weight:800;
    cursor:pointer;
    white-space:nowrap;
}

.btn-block-user:hover{
    background:#ea580c;
    color:white;
}

.btn-block-user.bloqueado{
    background:#e5e7eb;
    color:#374151;
}

body.dark-mode .btn-block-user{
    background:#3a2a1f;
    color:#fdba74;
}

body.dark-mode .btn-block-user:hover{
    background:#ea580c;
    color:white;
}

body.dark-mode .btn-block-user.bloqueado{
    background:#374151;
    color:#e5e7eb;
}

/* ===== BOTAO BLOQUEAR UTILIZADOR - FIM ===== */
