/* ==========================================================
   GHR PULSE — PULSE CHAT
   Central de atendimento WhatsApp
   ========================================================== */

.pulse-chat {
    display: flex;
    gap: 14px;
    height: calc(100vh - 210px);
    min-height: 560px;
}

.pulse-chat-column {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pulse-chat-list-column {
    flex: 0 0 320px;
}

.pulse-chat-panel-column {
    flex: 1 1 auto;
    min-width: 0;
}

.pulse-chat-resident-column {
    flex: 0 0 300px;
    overflow-y: auto;
}

/* ---------- Lista de conversas ---------- */

.pulse-chat-list-header {
    padding: 14px 14px 10px 14px;
    border-bottom: 1px solid var(--border);
}

.pulse-chat-list-header h5 {
    font-size: 16px;
    font-weight: 700;
    color: var(--wine);
    margin-bottom: 10px;
}

.pulse-chat-list {
    overflow-y: auto;
    flex: 1 1 auto;
}

.pulse-chat-list-item {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background-color .15s ease;
}

.pulse-chat-list-item:hover {
    background-color: rgba(155, 0, 50, .04);
}

.pulse-chat-list-item.active {
    background-color: rgba(155, 0, 50, .08);
    border-left: 3px solid var(--wine);
}

.pulse-chat-list-item-avatar {
    font-size: 30px;
    color: var(--muted);
    flex: 0 0 auto;
}

.pulse-chat-list-item-avatar .pulse-chat-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.pulse-chat-list-item-body {
    min-width: 0;
    flex: 1 1 auto;
}

.pulse-chat-list-item-top {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.pulse-chat-list-item-name {
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pulse-chat-list-item-time {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.pulse-chat-list-item-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.pulse-chat-list-item-preview {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}

.pulse-chat-list-item-indicators {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    padding-top: 2px;
}

.pulse-chat-mode-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.pulse-chat-mode-dot.pulse-chat-mode-bot {
    background-color: var(--green);
}

.pulse-chat-mode-dot.pulse-chat-mode-human {
    background-color: var(--wine);
}

.pulse-chat-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--red);
    display: inline-block;
}

/* ---------- Painel central ---------- */

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

.pulse-chat-panel-empty,
.pulse-chat-resident-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted);
    text-align: center;
    padding: 20px;
}

.pulse-chat-panel-empty i,
.pulse-chat-resident-panel-empty i {
    font-size: 34px;
    margin-bottom: 10px;
    opacity: .5;
}

.pulse-chat-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.pulse-chat-panel-header-info strong {
    font-size: 15px;
}

.pulse-chat-panel-header-sub {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

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

.pulse-chat-mode-badge {
    font-size: 11px;
    padding: 5px 9px;
}

.pulse-chat-mode-badge-bot {
    background-color: var(--green) !important;
}

.pulse-chat-mode-badge-human {
    background-color: var(--wine) !important;
}

.pulse-chat-panel-header-actions .btn-outline-light {
    color: var(--text);
    border-color: var(--border);
    font-size: 12px;
}

.pulse-chat-panel-header-actions .btn-outline-light:hover {
    background-color: var(--bg);
}

/* ---------- Mensagens ---------- */

.pulse-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    background-color: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pulse-chat-bubble-row {
    display: flex;
}

.pulse-chat-bubble-row-inbound {
    justify-content: flex-start;
}

.pulse-chat-bubble-row-outbound {
    justify-content: flex-end;
}

.pulse-chat-bubble {
    max-width: 62%;
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

.pulse-chat-bubble-resident {
    background-color: #ffffff;
    border: 1px solid var(--border);
}

.pulse-chat-bubble-bot {
    background-color: #e7f3ec;
    border: 1px solid #bfe3cd;
}

.pulse-chat-bubble-attendant {
    background-color: #fdeaf0;
    border: 1px solid #f3c4d6;
}

.pulse-chat-bubble-sender {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    margin-bottom: 3px;
}

.pulse-chat-bubble-body {
    font-size: 13.5px;
    white-space: pre-wrap;
    word-break: break-word;
}

.pulse-chat-bubble-media {
    display: block;
    max-width: 260px;
    max-height: 320px;
    border-radius: 8px;
}

.pulse-chat-bubble-media-error {
    font-size: 13.5px;
    font-style: italic;
    opacity: 0.75;
}

.pulse-chat-bubble-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.pulse-chat-bubble-time {
    font-size: 10px;
    color: var(--muted);
}

.pulse-chat-bubble-failed {
    font-size: 10px;
    color: var(--red);
    font-weight: 600;
}

/* Estado de entrega (Pacote 1) -- ✓ Enviada / ✓✓ Entregue / ✓✓ Lida. */
.pulse-chat-bubble-status {
    font-size: 10px;
    color: var(--muted);
    font-weight: 600;
}

.pulse-chat-bubble-status-read {
    color: #34b7f1;
}

.pulse-chat-resend-btn {
    font-size: 10px;
    font-weight: 600;
    color: var(--red);
    background: none;
    border: 1px solid var(--red);
    border-radius: 4px;
    padding: 1px 6px;
    cursor: pointer;
    line-height: 1.4;
}

.pulse-chat-resend-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Documento recebido (Pacote 2). */
.pulse-chat-bubble-document {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: underline;
}

/* ---------- Composer ---------- */

.pulse-chat-composer {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex: 0 0 auto;
    align-items: flex-end;
}

.pulse-chat-composer textarea {
    resize: none;
}

.pulse-chat-composer-hint {
    padding: 0 16px 10px 16px;
    font-size: 12px;
    color: var(--red);
    min-height: 4px;
}

/* ---------- Janela de 24h encerrada (reabertura por template) ---------- */

/* Card institucional exibido no lugar do compositor de texto livre
   quando a Conversation esta CLOSED (ver conversation_panel.html e
   updateComposerState() em pulse_chat.js -- este arquivo so estiliza,
   nao decide visibilidade). */

.pulse-chat-closed-notice {
    flex: 0 0 auto;
    padding: 24px 24px 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    text-align: center;
}

.pulse-chat-closed-notice-logo {
    display: block;
    height: 34px;
    width: auto;
    margin: 0 auto 16px auto;
}

.pulse-chat-closed-notice-brand {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--wine);
    margin-bottom: 12px;
}

.pulse-chat-closed-notice-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.pulse-chat-closed-notice-text {
    max-width: 420px;
    margin: 0 auto;
    font-size: 13px;
    line-height: 1.55;
    color: var(--muted);
}

.pulse-chat-closed-notice-footer {
    max-width: 420px;
    margin: 18px auto 0 auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--muted);
}

/* Botao de reabertura -- unico filho visivel do compositor quando
   CLOSED, por isso o `margin: 0 auto` o centraliza sem depender de
   nenhum atributo de estado no compositor. */

#pulseChatReopenBtn {
    margin: 0 auto;
    padding: 9px 22px;
    border: 1px solid var(--wine);
    border-radius: 8px;
    background: var(--wine);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    box-shadow: none;
}

#pulseChatReopenBtn:hover:not(:disabled),
#pulseChatReopenBtn:focus:not(:disabled) {
    background: #fff;
    color: var(--wine);
}

#pulseChatReopenBtn:disabled {
    opacity: .55;
}

/* ---------- Painel do morador ---------- */

.pulse-chat-resident-panel {
    padding: 16px;
}

.pulse-chat-resident-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--wine);
    margin-bottom: 10px;
}

.pulse-chat-resident-block {
    margin-bottom: 12px;
}

.pulse-chat-resident-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
    font-size: 12.5px;
}

.pulse-chat-resident-field .label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
}

.pulse-chat-resident-unidentified {
    font-size: 12.5px;
    color: var(--muted);
}

.pulse-chat-resident-unit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    padding: 5px 8px;
    background-color: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 4px;
}

.pulse-chat-resident-unit-code {
    font-weight: 600;
}

.pulse-chat-resident-unit-role {
    font-size: 10.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .02em;
}

.pulse-chat-request-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pulse-chat-request-item {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-size: 12px;
    padding: 6px 8px;
    background-color: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.pulse-chat-request-status {
    color: var(--muted);
}

.pulse-chat-request-time {
    color: var(--muted);
    white-space: nowrap;
}

/* ---------- Estados vazios / genéricos ---------- */

.pulse-chat-empty {
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
}

.pulse-chat-empty-small {
    padding: 10px 4px;
}

@media (max-width: 1200px) {

    .pulse-chat-resident-column {
        display: none;
    }

}

@media (max-width: 860px) {

    .pulse-chat {
        flex-direction: column;
        height: auto;
    }

    .pulse-chat-list-column {
        flex: 0 0 260px;
    }

    .pulse-chat-panel-column {
        flex: 0 0 520px;
    }

}

/* ----------------------------------------------------------------------
   ELEMENTO OCULTO NAO OCUPA ESPACO.

   A barra de citacao (#pulseChatReplyBar) e a de anexo
   (#pulseChatAttachmentBar) sao marcadas com o atributo `hidden` e so
   aparecem quando a recepcao clica em "Responder" numa bolha ou escolhe
   um arquivo. As duas carregam a classe `d-flex` do Bootstrap, cuja
   regra `display:flex` tem a MESMA especificidade do `[hidden]` do
   reset e vem depois na cascata -- entao vencia, e as duas ficavam
   visiveis e vazias (~73px somados) com um "x" solto cada, logo acima
   do compositor, em todas as conversas.

   Isto so ficou evidente agora que o compositor esta sempre na tela.
   Nenhum JS muda: setComposerReply()/limparCitacao() e o fluxo de anexo
   continuam alternando `hidden` exatamente como antes -- e o atributo
   agora de fato esconde.

   Escopo deliberadamente restrito a estes dois elementos -- uma regra
   [hidden] global neste arquivo alcancaria outras telas que carregam
   o mesmo CSS, fora do que foi pedido.
   ---------------------------------------------------------------------- */
#pulseChatReplyBar[hidden],
#pulseChatAttachmentBar[hidden] {
    display: none !important;
}
