/* ==========================================================================
   1. VARIÁVEIS E RESET GLOBAL
   ========================================================================== */
:root {
    --wa-bg-main: #0b141a;
    --wa-sidebar: #111b21;
    --wa-header: #202c33;
    --wa-bubble-in: #202c33;
    --wa-bubble-out: #005c4b;
    --wa-text: #e9edef;
    --wa-text-dim: #8696a0;
    --wa-teal: #00a884;
    --wa-red: #f15c5c;
    --wa-yellow: #ffc107;
    --wa-blue: #53bdeb;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    height: 100% !important;
    /* CRÍTICO: Previne que modais redimensionem a janela */
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    background-color: var(--wa-bg-main);
    color: var(--wa-text);
    overflow: hidden !important;
    /* SPA Feel: Sem scroll na página nunca */
}

/* Neutraliza comportamento do SweetAlert */
body.swal2-shown {
    padding-right: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* Fix: Form Elements inherit font */
input,
textarea,
button,
select {
    font-family: inherit;
}

/* Scrollbar Bonita (Dark Mode) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #374045;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4b555b;
}

/* ==========================================================================
   2. LAYOUT PRINCIPAL (3 COLUNAS)
   ========================================================================== */

/* COLUNA 1: Lista de Contatos (Esquerda) */
.sidebar-left {
    width: 25%;
    min-width: 300px;
    /* Removido max-width para respeitar os 25% em telas grandes */
    background: var(--wa-sidebar);
    border-right: 1px solid #222d34;
    display: flex;
    flex-direction: column;
    z-index: 2;
}

/* COLUNA 2: Janela de Chat (Centro) */
main {
    flex: 1;
    /* Ocupa o espaço restante (50% se as laterais forem 25+25) */
    display: flex;
    flex-direction: column;
    background-color: var(--wa-bg-main);
    position: relative;
    border-right: 1px solid #222d34;
    min-width: 0;
    /* CRÍTICO: Permite que a coluna central encolha sem empurrar as outras */
    overflow: hidden;
}

/* COLUNA 3: CRM (Direita) */
.sidebar-right {
    width: 25%;
    min-width: 280px;
    background: var(--wa-sidebar);
    display: flex;
    flex-direction: column;
}

/* Header Genérico */
.sidebar-header,
#chat-header {
    background: var(--wa-header);
    height: 60px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    width: 100%;
    overflow: hidden;
}

/* ==========================================================================
   3. COLUNA DA ESQUERDA (BUSCA E LISTA)
   ========================================================================== */
.search-container {
    padding: 10px;
    border-bottom: 1px solid #222d34;
}

.search-bar {
    background: #202c33;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    position: relative;
    margin-bottom: 12px;
}

.search-icon {
    color: var(--wa-text-dim);
    margin-right: 10px;
    z-index: 1;
}

#contact-search {
    background: transparent;
    border: none;
    color: var(--wa-text);
    width: 100%;
    padding: 10px 0;
    outline: none;
}

.filter-chips {
    display: flex;
    gap: 8px;
    padding: 0 10px 10px 10px;
    overflow-x: auto;
}

.filter-chip {
    background: #202c33;
    border: none;
    color: var(--wa-text-dim);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
    position: relative;
    margin-top: 5px;
}

.filter-chip:hover {
    background: #2a3942;
}

.filter-chip.active {
    background: rgba(0, 168, 132, 0.15);
    color: var(--wa-teal);
}

.filter-chip::after,
.filter-dropdown-item::after {
    content: attr(data-count);
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--wa-teal);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    display: none;
    z-index: 5;
}

/* Ajuste específico para o badge dentro do dropdown */
.filter-dropdown-item::after {
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
}

/* 🔥 ESTILOS PARA DROPDOWN DE FILTROS */
.filter-dropdown {
    position: relative;
    display: inline-block;
}

.filter-dropdown-content {
    display: none;
    position: absolute;
    background-color: #233138;
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    border-radius: 8px;
    top: 40px;
    left: 0;
    padding: 8px 0;
    border: 1px solid #3b4a54;
}

.filter-dropdown-content.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.filter-dropdown-item {
    color: var(--wa-text);
    padding: 10px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
    position: relative;
}

.filter-dropdown-item i {
    width: 20px;
    text-align: center;
    color: var(--wa-text-dim);
}

.filter-dropdown-item:hover {
    background-color: #111b21;
}

.filter-dropdown-item.active {
    background-color: rgba(0, 168, 132, 0.1);
    color: var(--wa-teal);
}

.filter-dropdown-item.active i {
    color: var(--wa-teal);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-chip[data-count]:not([data-count="0"]):not([data-count=""])::after,
.filter-dropdown-item[data-count]:not([data-count="0"]):not([data-count=""])::after {
    display: block;
}

#contact-list {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    /* border-bottom: 1px solid rgba(255, 255, 255, 0.05); */
    transition: background-color 0.2s;
    height: 72px;
    /* Alterado conforme solicitado: Bordas redondas e margem */
    margin: 5px;
    border-radius: 10px;
}

.contact-item:hover {
    background-color: #202c33;
}

.contact-item.active {
    background-color: #2a3942;
}

.avatar-container {
    margin-right: 15px;
    position: relative;
    flex-shrink: 0;
}

.contact-avatar {
    width: 49px;
    height: 49px;
    border-radius: 50%;
    object-fit: cover;
    background: #202c33;
    margin-right: 15px;
    /* Fix: Espaçamento para o texto */
}

/* Fix: Contador de Mensagens não Lidas (Estilo WhatsApp) */
.unread-badge {
    background-color: #25d366;
    color: #0b141a;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0 4px;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
    /* Garante que o truncamento funcione */
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.contact-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--wa-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.contact-time {
    font-size: 11px;
    color: var(--wa-text-dim);
    margin-left: 8px;
    flex-shrink: 0;
}

.contact-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.contact-last-msg {
    color: var(--wa-text-dim);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.contact-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.unread-count {
    background-color: #25d366;
    color: #0b141a;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 12px;
    min-width: 18px;
    text-align: center;
}

.contact-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.contact-item:hover .contact-actions {
    opacity: 0.7;
}

.action-icon {
    font-size: 12px;
    color: var(--wa-text-dim);
    cursor: pointer;
    transition: color 0.2s;
}

.action-icon:hover {
    color: var(--wa-teal);
}

/* ==========================================================================
   4. CHAT CENTRAL
   ========================================================================== */
#chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-bottom: 6px solid var(--wa-teal);
}

#chat-window {
    display: none;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    position: relative; /* Base para o fundo fixo */
    overflow: hidden;
}

#chat-window::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png");
    background-repeat: repeat;
    opacity: 0.06; /* Levemente mais visível a pedido anterior */
    pointer-events: none;
    z-index: 0;
}

#chat-info-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
    cursor: pointer;
}

#message-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    z-index: 1; /* Acima do fundo */
    background: transparent; /* Permite ver o fundo do pai */
}

#message-history::-webkit-scrollbar {
    width: 6px;
}

#message-history::-webkit-scrollbar-thumb {
    background: #2a3942;
    border-radius: 10px;
}

#message-history::-webkit-scrollbar-track {
    background: transparent;
}

/* Papel de parede movido para #chat-window::before */

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg {
    animation: messageIn 0.18s ease-out;
    border-radius: 7.5px;
    max-width: 65%;
    width: fit-content;
    font-size: 14.2px;
    padding: 6px 8px 24px 9px; /* Aumentado o padding-bottom de 8 para 24px */
    position: relative;
    z-index: 1; /* Cria contexto de empilhamento para a seta do menu */
    line-height: 19px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);

    /* Espaço horizontal extra não é mais tão necessário com o bottom padding, mas mantido para textos curtos */
    min-width: 80px;

    /* Fix Overflow without extra margins */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.msg:hover {
    filter: brightness(1.05);
}

/* Margem interna do conteúdo da mensagem */
.msg>div:not(.msg-meta):not(.msg-menu-trigger) {
    margin-right: 5px;
}

/* Ensure text content wraps but metadata stays aligned */
.msg div {
    max-width: 100%;
}

.msg-in {
    align-self: flex-start;
    background-color: #202c33;
    color: #e9edef;
}

.msg-in::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 8px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent #202c33 transparent transparent;
}

.msg-out {
    align-self: flex-end;
    background-color: #005c4b;
    color: #e9edef;
}

.msg-out::before {
    content: "";
    position: absolute;
    right: -6px;
    top: 8px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent transparent #005c4b;
}

/* Meta-informações (Hora + Check) */
.msg-meta {
    position: absolute;
    bottom: 4px;
    right: 9px;
    display: flex;
    align-items: center;
    pointer-events: none;
    user-select: none;
}

.message-time {
    font-size: 11px;
    color: #8696a0;
    margin-left: 6px;
    align-self: flex-end;
}

.message-status {
    font-size: 12px;
    margin-left: 4px;
    color: #8696a0;
    align-self: flex-end; /* Adicionado para empurrar o check pra baixo igual a hora */
}

.message-status.read {
    color: #53bdeb;
}

/* Menu de Contexto (Trigger) */
.msg-menu-trigger {
    position: absolute;
    top: 0px;
    right: 0px;
    width: 32px;
    height: 32px;
    display: flex !important; /* Sempre flex para garantir presença */
    opacity: 0.2; /* Sutilmente visível por padrão para sabermos que está lá */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #8696a0;
    background: linear-gradient(to bottom, rgba(32, 44, 51, 0.9) 0%, rgba(32, 44, 51, 0.4) 70%, transparent 100%);
    border-radius: 0 7.5px 0 50%;
    z-index: 1000; /* Aumentado para garantir prioridade total */
    transition: opacity 0.2s, background 0.2s, transform 0.2s;
    pointer-events: auto !important;
}

.msg-out .msg-menu-trigger {
    background: linear-gradient(to bottom, rgba(0, 92, 75, 0.9) 0%, rgba(0, 92, 75, 0.4) 70%, transparent 100%);
    border-radius: 7.5px 0 50% 0;
}

.msg:hover .msg-menu-trigger {
    opacity: 1;
    background: rgba(32, 44, 51, 0.95);
    border-radius: 0 7.5px 0 50%;
    box-shadow: -2px 2px 5px rgba(0,0,0,0.2);
}

.msg-out:hover .msg-menu-trigger {
    background: rgba(0, 92, 75, 0.95);
    border-radius: 7.5px 0 50% 0;
}

.msg-menu-trigger:hover {
    background-color: #3b4a54 !important;
    color: #fff !important;
    transform: scale(1.1);
}

.msg-out .msg-menu-trigger:hover {
    background-color: #00735e !important;
}

.msg-menu-trigger i {
    font-size: 14px;
    pointer-events: none; /* Garante que o clique passe para a div */
}

/* Menu dropdown de contexto das mensagens */
.msg-dropdown {
    position: fixed;
    background: #233138;
    border: 1px solid #3b4a54;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    min-width: 180px;
    padding: 4px 0;
    display: none;
}

.msg-dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--wa-text);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
}

.msg-dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.msg-dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--wa-text-dim);
}

.msg-dropdown-divider {
    border: 0;
    border-top: 1px solid #3b4a54;
    margin: 4px 0;
}


/* Reações de mensagens (minimalista - apenas emoji) */
.reaction-bubble {
    position: absolute;
    bottom: -10px;
    right: -15px;
    font-size: 15px;
    /* Um pouco maior */
    z-index: 5;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
}


/* --- ALBUM DE FOTOS (GRID) --- */
.media-album {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    max-width: 320px;
    /* Aumentado de 260px para 320px */
    margin-bottom: 2px;
}

.media-album img {
    width: 100%;
    height: 150px;
    /* Aumentado de 100px para 150px */
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s;
}

.media-album img:hover {
    transform: scale(1.05);
}

/* Se for sticker ou video, mantem tamanho normal */
.media-album .msg-sticker,
.media-album video {
    grid-column: span 2;
    /* Ocupa tudo */
}



@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.date-divider {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    position: sticky;
    top: 10px;
    z-index: 10;
}

/* Menus do Chat (Emoji, Sticker, Templates) */
.emoji-wrapper,
#general-menu,
#sticker-wrapper,
#template-menu {
    z-index: 2100 !important;
}

.date-pill {
    background: #182229;
    color: #8696a0;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
}

footer {
    background: var(--wa-header);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 100;
    /* CRÍTICO: Mantém barra visível sobre overlays */
    flex-shrink: 0;
    /* IMPEDE QUE O FOOTER SEJA ESMAGADO (SUMA) */
}

#msg-input {
    flex: 1;
    padding: 12px 15px;
    border-radius: 8px;
    border: none;
    background: #2a3942;
    color: white;
    outline: none;
    font-size: 15px;
}

.btn-action {
    background: none;
    border: none;
    color: var(--wa-text-dim);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-action:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--wa-text);
}

.btn-send {
    color: var(--wa-teal);
}

.btn-send:hover {
    transform: scale(1.1);
}

.recording {
    color: var(--wa-red) !important;
    animation: pulse 1s infinite;
}


/* ==========================================================================
   5. CRM E TAGS (CORRIGIDO)
   ========================================================================== */
.crm-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    overflow: hidden;
}

.sidebar-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding-right: 5px;
    /* Espaço para scrollbar */
}

.crm-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-label {
    font-size: 12px;
    color: var(--wa-teal);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crm-input,
.crm-textarea {
    background: #2a3942;
    border: 1px solid #3b4a54;
    border-radius: 8px;
    color: var(--wa-text);
    padding: 10px;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
}

.crm-input:focus,
.crm-textarea:focus {
    border-color: var(--wa-teal);
}

.crm-textarea {
    height: 80px;
    resize: none;
}

.crm-divider {
    border: 0;
    border-top: 1px solid #222d34;
    margin: 5px 0;
}

.btn-crm {
    background: var(--wa-teal);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.btn-crm:hover {
    filter: brightness(1.1);
}

/* --- BOTÕES DE TAG (No painel CRM) --- */
.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.btn-tag {
    border: 1px solid transparent;
    outline: none;
    background: #202c33;
    color: #aebac1;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-tag:hover {
    background: #2a3942;
    color: #fff;
    transform: translateY(-1px);
}

/* --- CORES DAS TAGS (CORRIGIDO) --- */


/* 1. INADIMPLENTE (Vermelho) - Estava faltando! */
.tag-Inadimplente,
.tag-inadimplente {
    background-color: rgba(220, 53, 69, 0.15) !important;
    color: #dc3545 !important;
    border: 1px solid #dc3545 !important;

}

/* Garante que o texto fique legível e padronizado */
.tag-badge.tag-Inadimplente {
    font-weight: bold;
    text-transform: uppercase;
}

/* 2. CRÍTICO (Roxo Neon - Conforme seu código) */
.tag-critico {
    background-color: rgba(190, 82, 242, 0.15) !important;
    color: #be52f2 !important;
    border: 1px solid #be52f2 !important;
}

/* 3. NEGOCIAÇÃO (Amarelo) */
.tag-negociacao {
    background-color: rgba(255, 193, 7, 0.15) !important;
    color: var(--wa-yellow) !important;
    border: 1px solid var(--wa-yellow) !important;
}

/* 4. PAGO (Verde) */
.tag-pago {
    background-color: rgba(0, 168, 132, 0.15) !important;
    color: var(--wa-teal) !important;
    border: 1px solid var(--wa-teal) !important;
}

/* 5. RETORNAR (Azul) */
.tag-retornar {
    background-color: rgba(83, 189, 235, 0.15) !important;
    color: var(--wa-blue) !important;
    border: 1px solid var(--wa-blue) !important;
}

/* 6. EQUIPAMENTO (Laranja) */
.tag-equipamento {
    background-color: rgba(253, 126, 20, 0.15) !important;
    color: #fd7e14 !important;
    border: 1px solid #fd7e14 !important;
}

/* Estilo da Tag na Lista Lateral */
.tag-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 8px;
    white-space: nowrap;
    vertical-align: middle;
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1;
}



/* ==========================================================================
   6. EXTRAS (MODAIS E STATUS)
   ========================================================================== */


.btn-new-contact {
    background: var(--wa-header);
    border: 1px solid #3b4a54;
    color: var(--wa-teal);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    font-size: 18px;
}

.btn-new-contact:hover {
    background: #2a3942;
    border-color: var(--wa-teal);
}

/* Agendamento Cards */
.ag-card {
    background: #2a3942;
    border-left: 3px solid var(--wa-teal);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    position: relative;
    transition: transform 0.2s ease;
}

.ag-card:hover {
    transform: translateX(3px);
    background: #323f47;
}

/* ==========================================================================
   7. UTILITY CLASSES (MISSING)
   ========================================================================== */
.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-row {
    display: flex;
    flex-direction: row;
}

.h-100 {
    height: 100%;
}

.w-100 {
    width: 100%;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-5 {
    gap: 5px;
}

.gap-8 {
    gap: 8px;
}

.gap-10 {
    gap: 10px;
}

.gap-15 {
    gap: 15px;
}

.gap-20 {
    gap: 20px;
}

.mt-20 {
    margin-top: 20px;
}

.bg-panel {
    background-color: var(--wa-sidebar);
}

.text-center {
    text-align: center;
}

.overflow-hidden {
    overflow: hidden;
}

.overflow-y-auto {
    overflow-y: auto;
}

.flex-1 {
    flex: 1;
}

.btn-icon-text {
    background: transparent;
    border: 1px solid transparent;
    color: var(--wa-text-dim);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.btn-icon-text:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--wa-text);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--wa-text-dim);
    font-size: 16px;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--wa-text);
}

.ag-card strong {
    display: block;
    font-size: 12px;
    color: var(--wa-blue);
    margin-bottom: 4px;
}

.ag-card p {
    font-size: 13px;
    color: #d1d7db;
    margin: 4px 0;
}

.ag-card small {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.2);
}

.status-pendente {
    color: var(--wa-yellow);
}

.status-enviado {
    color: var(--wa-teal);
}

.status-falhou {
    color: var(--wa-red);
}

.ag-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.btn-reenviar {
    background-color: #00a884;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: 0.2s;
}

.btn-reenviar:hover {
    background-color: #008f6f;
}

.btn-cancelar {
    background-color: transparent;
    color: #f15c5c;
    border: 1px solid #f15c5c;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: 0.2s;
}

.btn-cancelar:hover {
    background-color: rgba(241, 92, 92, 0.1);
}

/* --- TOPO E LUZ DE STATUS --- */
.topo-acoes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    background-color: #202c33;
    border-bottom: 1px solid #2a3942;
}

.status-led {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: gray;
    /* Cor padrão */
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    cursor: help;
}

.status-online {
    background-color: #00ff00;
    box-shadow: 0 0 8px #00ff00;
}

.status-reconectando {
    background-color: #ffcc00;
    animation: piscar 1s infinite;
}

.status-offline {
    background-color: #ff0000;
    box-shadow: 0 0 8px #ff0000;
}

@keyframes piscar {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

/* ==========================================================================
   8. ANIMAÇÕES E FEEDBACK (NOVO)
   ========================================================================== */

/* Animação de Rotação (Loading) */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Ícone girando */
.fa-spin-fast {
    animation: spin 1s infinite linear;
}

/* Estado do botão quando está carregando */
.btn-loading {
    opacity: 0.7;
    pointer-events: none;
    /* Impede clicar 2 vezes */
    cursor: wait !important;
}

/* Central de Notificações (Estilo extra pro SweetAlert) */
div:where(.swal2-container).swal2-top-end>.swal2-popup,
div:where(.swal2-container).swal2-top-right>.swal2-popup {
    grid-column: 3;
    align-self: start;
    justify-self: end;
    margin-top: 60px;
    /* Para não ficar em cima do cabeçalho */
}

/* ==========================================================================
   9. CORREÇÕES DE SETUP (USER FEEDBACK)
   ========================================================================== */

/* SweetAlert2 Reduzido e Padronizado */
div:where(.swal2-container) div:where(.swal2-popup) {
    font-size: 12px !important;
    width: 320px !important;
    padding: 10px !important;
    background-color: #111b21 !important;
    color: #d1d7db !important;
    border: 1px solid #222d34 !important;
}

div:where(.swal2-container) .swal2-title {
    font-size: 16px !important;
    padding: 5px !important;
    color: #e9edef !important;
}

div:where(.swal2-container) .swal2-html-container {
    margin: 5px !important;
    font-size: 13px !important;
    color: #8696a0 !important;
}

div:where(.swal2-container) .swal2-actions {
    margin: 10px 0 0 !important;
    gap: 5px;
}

div:where(.swal2-container) button.swal2-styled {
    padding: 6px 15px !important;
    font-size: 12px !important;
    border-radius: 4px !important;
}

div:where(.swal2-container) button.swal2-confirm {
    background-color: #00a884 !important;
}

div:where(.swal2-container) button.swal2-cancel {
    background-color: #202c33 !important;
    color: #f15c5c !important;
}

div:where(.swal2-container) input.swal2-input {
    height: 35px !important;
    font-size: 13px !important;
    margin: 10px auto !important;
    background: #202c33 !important;
    color: white !important;
    border: 1px solid #2a3942 !important;
}

/* 🔥 CORREÇÃO DE Z-INDEX DO SWEETALERT (Para ficar sobre o Dossiê/Modais) */
div:where(.swal2-container) {
    z-index: 20000 !important;
}

/* Botões de Agendamento Padronizados */
.btn-del-ag {
    border: none !important;
    border-radius: 4px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    cursor: pointer !important;
    background: #202c33 !important;
    /* Cinza escuro */
    color: #aebac1 !important;
    transition: 0.2s !important;
    text-transform: uppercase !important;
    font-weight: bold !important;
    box-shadow: none !important;
    margin-right: 5px;
}

.btn-del-ag:hover {
    background: #00a884 !important;
    /* Verde Zap */
    color: #fff !important;
}

/* --- Scrollbar Customizada (Tema Escuro) --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #3b4a54;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #54656f;
}

/* --- Itens Interativos (Protocolos e Busca) --- */
.protocolo-item {
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #3b4a54;
    padding: 8px;
    border-radius: 4px;
}

.protocolo-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.resultado-item {
    padding: 10px;
    border-bottom: 1px solid #2a3942;
    cursor: pointer;
    transition: background 0.2s;
}

.resultado-item:hover {
    background-color: #202c33;
}

.resultado-origem {
    font-weight: bold;
    color: #00a884;
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
}

.resultado-data {
    font-size: 11px;
    color: #8696a0;
    text-align: right;
    margin-top: 5px;
}

/* Highlight na mensagem encontrada */
.msg-highlight {
    animation: highlightAnim 2s ease-out;
}

@keyframes highlightAnim {
    0% {
        background-color: rgba(0, 168, 132, 0.5);
        transform: scale(1.02);
    }

    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

/* --- Controles de Protocolo --- */
.prot-btn-nav {
    background: #202c33;
    border: 1px solid #3b4a54;
    color: #8696a0;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
}

.prot-btn-nav:hover {
    background: #00a884;
    color: white;
    border-color: #00a884;
}

.prot-btn-vertudo {
    background: transparent;
    border: 1px solid #3b4a54;
    color: #8696a0;
    border-radius: 4px;
    padding: 2px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    width: 100%;
    font-size: 10px;
}

.prot-btn-vertudo:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e9edef;
}

/* ==========================================================================
   BOTÕES DE AÇÃO DO HEADER (Padronização)
   ========================================================================== */
.header-action-btn {
    border: none;
    border-radius: 6px;
    padding: 0 12px;
    height: 32px;
    font-size: 13px;
    /* Legível e uniforme */
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-transform: capitalize;
    transition: background 0.2s;
    background: #3b4a54;
    color: #e9edef;
    white-space: nowrap;
}

.header-action-btn:hover {
    background: #4b555b;
}

.header-action-btn i {
    font-size: 14px;
}

/* Botão de Finalizar tem estilo red */
.header-action-btn.btn-finalizar {
    background: rgba(241, 92, 92, 0.1);
    color: #f15c5c;
}

.header-action-btn.btn-finalizar:hover {
    background: rgba(241, 92, 92, 0.2);
}

/* Ajuste do Nome para harmonizar */
#chat-info-name {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #e9edef;
}

/* --- Correção Visual Botões Tags (Quadrados) --- */
.btn-tag {
    border-radius: 6px !important;
    /* Padronizado com input/cards */
    padding: 8px 10px !important;
    /* Ajuste para não ficar muito gordo */
    font-size: 11px !important;
    text-transform: uppercase;
    font-weight: bold;
    color: #e9edef !important;
    /* Texto claro padrão dark */
    background: #202c33;
    /* Fundo padrão botões dark */
    border: 1px solid #3b4a54;
    /* Borda sutil */
    transition: 0.2s;
    cursor: pointer;
    box-shadow: none !important;
}

.btn-tag:hover {
    background: #3b4a54;
    border-color: #00a884;
}

/* --- CRM Dark Theme Overrides (Tabela e Janela) --- */
#crm-tabela-corpo tr {
    background-color: transparent !important;
    color: var(--wa-text) !important;
    border-bottom: 1px solid rgba(134, 150, 160, 0.15) !important;
    /* Linha bem sutil */
    transition: background 0.2s;
}

#crm-tabela-corpo tr:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

#crm-tabela-corpo td {
    padding: 10px 15px !important;
    /* Mais compacto */
    color: var(--wa-text) !important;
    border-color: #2a3942;
    font-size: 12px !important;
    /* Fonte reduzida (aprox 20% menor que 14/15px) */
}

/* Scrollbar da tabela */
#crm-window ::-webkit-scrollbar-track {
    background: var(--wa-bg-main);
}

/* ==========================================================================
   8. REFATORAÇÃO CSS - NOVAS CLASSES
   ========================================================================== */

/* --- Utilitários Flex --- */
.flex-row {
    display: flex;
    flex-direction: row;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-1 {
    flex: 1;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.items-end {
    align-items: flex-end;
}

.justify-end {
    justify-content: flex-end;
}

.gap-5 {
    gap: 5px;
}

.gap-10 {
    gap: 10px;
}

.gap-15 {
    gap: 15px;
}

.w-100 {
    width: 100%;
}

.mt-5 {
    margin-top: 5px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-5 {
    margin-bottom: 5px;
}

.p-20 {
    padding: 20px;
}

/* --- Modais (Overlay e Conteúdo) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
}

.z-1100 {
    z-index: 3100;
}

.z-1200 {
    z-index: 3200;
}

/* Modal Edição */
.modal-content-edit {
    background: #202c33;
    width: 600px;
    max-width: 90%;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    color: #e9edef;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Modal Dossiê */
.modal-content-dossie {
    background: #202c33;
    width: 1000px;
    max-width: 95%;
    height: 85vh;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    color: #e9edef;
}

/* Header de Modal */
.modal-header-custom {
    padding: 15px;
    border-bottom: 1px solid #374045;
    background: #202c33;
}

.modal-header-dossie {
    padding: 15px;
    border-bottom: 1px solid #374045;
    background: #2a3942;
}


.modal-header-title,
.crm-window-title {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--wa-text);
}

.modal-close-btn {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #f15c5c;
}

/* Abas de Modal */
.modal-tabs-bar {
    display: flex;
    background: #111b21;
}

.tab-btn,
.tab-btn-dossie {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    color: #8696a0;
}

.tab-btn.active,
.tab-btn-dossie.active {
    color: #e9edef;
    border-bottom-color: #00a884;
}

.tab-btn-dossie {
    padding: 15px 20px;
    font-weight: normal;
}

.tab-btn-dossie.active {
    font-weight: bold;
    border-bottom-width: 3px;
}

/* Conteúdo de Tabs */
.tab-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* --- CRM Components --- */
.crm-window-container {
    display: none;
    /* Toggled by JS */
    flex: 1;
    flex-direction: column;
    background: var(--wa-bg-main);
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 200;
}

.crm-header-bar {
    background: var(--wa-header);
    color: var(--wa-text);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    border-bottom: 1px solid #374045;
}

.crm-window-container {
    display: none;
    /* Inicia oculto */
    flex-direction: column;
    background: var(--wa-bg-main);
    z-index: 1000;
    /* Ajustado para ficar atrás dos modais */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}



.crm-sub-header {
    padding: 8px 15px;
    background: var(--wa-header);
    border-bottom: 1px solid #374045;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.crm-search-input {
    padding: 8px 15px;
    padding-right: 40px !important;
    /* Espaço para o botâo X */
    width: 100%;
    /* max-width removido para preencher o wrapper */
    background: #111b21;
    color: var(--wa-text);
    border: 1px solid #3b4a54;
    border-radius: 6px;
    outline: none;
    font-size: 13px;
    transition: border-color 0.2s;
}

.crm-search-input:focus {
    border-color: #00a884;
}

.crm-search-input::placeholder {
    color: #8696a0;
}

.crm-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #3b4a54;
    background: #233138;
    color: #aebac1;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.crm-search-btn:hover {
    background: #2a3942;
    color: #e9edef;
    border-color: #00a884;
}

/* Paginação no rodapé */
.crm-pagination-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: var(--wa-header);
    border-top: 1px solid #374045;
}

/* Tabela CRM - Header Sticky */
.crm-table-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: #111b21;
}

.crm-table-head {
    position: sticky;
    top: 0;
    background: #233138;
    z-index: 10;
    border-bottom: 2px solid #374045;
}

.crm-th {
    padding: 16px 15px;
    text-align: left;
    color: #8696a0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Busca */
.crm-search-wrapper {
    position: relative;
    flex: 1;
    max-width: 450px;
    /* Limita o wrapper em vez do input */
    display: flex;
    align-items: center;
}

.crm-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #8696a0;
    cursor: pointer;
    font-size: 16px;
    z-index: 5;
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    transition: color 0.1s;
}

.crm-clear-btn:hover {
    color: #f15c5c;
}

.crm-tr {
    background: transparent;
    transition: background 0.1s;
    position: relative;
    border-bottom: none;
    /* Borda customizada no ::after */
}

/* Efeito de borda "solta" das laterais */
.crm-tr::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 15px;
    /* Espaço à esquerda */
    right: 15px;
    /* Espaço à direita */
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    /* Borda mais sutil */
}

.crm-tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.crm-td {
    padding: 12px 15px;
    vertical-align: middle;
    font-size: 13px;
}

/* --- Dossiê (360º View) --- */
.dossie-col-summary {
    width: 320px;
    background: #111b21;
    border-right: 1px solid #374045;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.dossie-profile-section {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #374045;
}

.dossie-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #00a884;
    margin-bottom: 10px;
}

.dossie-data-list {
    padding: 20px;
}

.dossie-section-header {
    color: #00a884;
    border-bottom: 1px solid #2a3942;
    padding-bottom: 5px;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 14px;
}

/* Botões com ícones e texto (Genérico) */
.btn-icon-text {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    border: 1px solid #3b4a54;
    background: var(--wa-sidebar);
    color: var(--wa-text);
}

.btn-icon-text.primary {
    background: var(--wa-sidebar);
    color: var(--wa-teal);
    font-weight: bold;
}

/* Botões com ícones e texto (Genérico) */
.btn-icon-text.crm-action {
    background: var(--wa-sidebar);
    color: var(--wa-text);
}

.crm-btn-action {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: #8696a0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crm-btn-action:hover {
    background: rgba(37, 211, 102, 0.2);
    color: #00a884;
}

/* --- CRM Filter Dropdown --- */
.crm-filter-dropdown-wrap {
    position: relative;
    display: inline-block;
}

.crm-filter-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: #233138;
    border: 1px solid #3b4a54;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    min-width: 170px;
    z-index: 999;
    overflow: hidden;
}

.crm-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    color: #aebac1;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.crm-filter-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e9edef;
}

.crm-filter-item.active {
    background: rgba(0, 168, 132, 0.1);
    color: #00a884;
    border-left-color: #00a884;
    font-weight: 600;
}

/* --- CRM View Toggle --- */
.crm-view-toggle {
    display: flex;
    gap: 2px;
    border: 1px solid #3b4a54;
    border-radius: 6px;
    overflow: hidden;
}

.crm-toggle-btn {
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: #8696a0;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
}

.crm-toggle-btn:hover {
    color: #e9edef;
}

.crm-toggle-btn.active {
    background: #00a884;
    color: #fff;
}

/* --- CRM Grid Cards --- */
.crm-grid {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    align-content: start;
}

.crm-card {
    background: #1e2a31;
    border: 1px solid #2a3942;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.crm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    border-color: #3b4a54;
}

.crm-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 10px;
}

.crm-card-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.crm-card-avatar-fallback {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #2a3942;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #8696a0;
    font-size: 16px;
}

.crm-card-info {
    flex: 1;
    min-width: 0;
}

.crm-card-name {
    font-weight: 600;
    color: #e9edef;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-card-status {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 5px;
    border: 1px solid;
    border-radius: 4px;
    margin-top: 3px;
}

.crm-card-body {
    padding: 0 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.crm-card-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #aebac1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-card-row i {
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.crm-card-menu-wrap {
    position: relative;
    flex-shrink: 0;
}

.crm-card-dots {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crm-card-dots:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e9edef;
}

.crm-card-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #233138;
    border: 1px solid #3b4a54;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    min-width: 150px;
    z-index: 1000;
    overflow: hidden;
    padding: 4px 0;
}

.crm-card-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: #aebac1;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, color 0.12s;
}

.crm-card-menu button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e9edef;
}

.crm-card-menu button i {
    width: 16px;
    text-align: center;
}

/* Form Groups */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    color: #8696a0;
    font-size: 12px;
    margin-bottom: 5px;
}

.form-input {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid #3b4a54;
    color: #e9edef;
    border-radius: 4px;
    /* Sobrescrever estilo crm-input legacy */
}

.form-input:focus {
    border-color: #00a884;
    outline: none;
}

/* ==========================================================================
   6. ESTILO DE MENSAGENS E BALÕES (RESTAURADO)
   ========================================================================== */

.message {
    display: flex;
    flex-direction: column;
    max-width: 65%;
    margin-bottom: 5px;
    position: relative;
    font-size: 14.2px;
    line-height: 19px;
    color: var(--wa-text);
}

.message.sent {
    align-self: flex-end;
    background-color: #005c4b;
    /* Verde escuro do WhatsApp (Tema Escuro) */
    border-radius: 8px 0px 8px 8px;
    margin-right: 5px;
}

.message.received {
    align-self: flex-start;
    background-color: #202c33;
    /* Cinza escuro do WhatsApp */
    border-radius: 0px 8px 8px 8px;
    margin-left: 5px;
}

.message-content {
    padding: 6px 7px 8px 9px;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    margin-top: -4px;
    min-height: 15px;
}

.message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-right: 2px;
}

.message-status {
    font-size: 11px;
    display: flex;
    align-items: center;
}

/* Animação suave para novas mensagens */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.3s ease-out forwards;
}

/* Estilo para links nas mensagens */
.message a {
    color: #53bdeb;
    text-decoration: none;
}

.message a:hover {
    text-decoration: underline;
}

/* Estilo para mídias */
.media-container {
    margin: -3px -4px 5px -4px;
    border-radius: 7px;
    overflow: hidden;
    cursor: pointer;
}

.media-content {
    width: 100%;
    height: auto;
    object-fit: cover;
    max-height: 300px;
}

/* ==========================================================================
   7. TEMPLATE MENU & MODAL (NOVO)
   ========================================================================== */

.template-popup {
    position: absolute;
    bottom: 70px;
    /* Acima do input */
    left: 10px;
    width: 300px;
    background: #2a3942;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    z-index: 2000;
    /* Garante que fique acima de tudo */
    border: 1px solid #374045;
    overflow: hidden;
}

.template-popup.active {
    display: flex;
}

.template-popup header {
    padding: 12px 15px;
    background: #202c33;
    border-bottom: 1px solid #374045;
    font-weight: 600;
    color: var(--wa-teal);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#template-options {
    max-height: 250px;
    overflow-y: auto;
    padding: 5px 0;
}

.template-option {
    padding: 10px 15px;
    cursor: pointer;
    color: var(--wa-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.template-option:hover {
    background: #202c33;
}

.template-option:last-child {
    border-bottom: none;
}

/* Modal Template Editor (Dark Premium) */
#modal-template .modal-content-edit {
    background: #2a3942;
    border: 1px solid #374045;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

#modal-template textarea {
    background: #111b21;
    border: 1px solid #374045;
    color: #e9edef;
    padding: 10px;
    border-radius: 6px;
    outline: none;
    width: 100%;
}

@keyframes pulse-siren {
    0% {
        opacity: 0.5;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.5;
        transform: scale(0.9);
    }
}

/* ==========================================================================
   HOVER EFFECTS & ANIMATIONS
   ========================================================================== */
.protocolo-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s;
}

.protocolo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    background-color: #374045 !important;
    z-index: 10;
}



.nota-anexo-link {
    font-size: 11px;
    color: #00a884;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 2px 6px;
    background: rgba(0, 168, 132, 0.1);
    border-radius: 4px;
    transition: background 0.2s;
}

.nota-anexo-link:hover {
    background: rgba(0, 168, 132, 0.2);
    text-decoration: underline;
}

.btn-ver-mais-notas {
    width: 100%;
    background: #202c33;
    border: 1px solid #374045;
    color: #00a884;
    font-size: 11px;
    padding: 6px;
    margin-top: 5px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
}

.btn-ver-mais-notas:hover {
    background: #2a3942;
    border-color: #00a884;
    color: #fff;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}


/* 🔥 Floating Scroll Letter Indicator */
#scroll-indicator {
    position: absolute;
    top: 80px;
    /* Abaixo da busca */
    right: 2px;
    background-color: rgba(32, 44, 51, 0.9);
    color: #00a884;
    font-size: 24px;
    font-weight: bold;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 9999;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 168, 132, 0.3);
}

#scroll-indicator.visible {
    opacity: 1;
}

/* ==========================================================================
   9. MEDIA VIEWER (LIGHTBOX)
   ========================================================================== */
.media-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 20, 26, 0.95);
    z-index: 99999;
    /* Acima de tudo (inclusive SweetAlert) */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.media-viewer-overlay.active {
    opacity: 1;
}

.viewer-content-wrapper {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: grab;
}

.viewer-content-wrapper:active {
    cursor: grabbing;
}

#viewer-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.1s ease-out;
    /* Suave para zoom */
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Toolbar (Topo) */
.viewer-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    z-index: 10;
}

.viewer-counter {
    color: #e9edef;
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.viewer-actions {
    display: flex;
    gap: 15px;
}

.viewer-actions button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #e9edef;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.viewer-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.btn-close-viewer {
    background: rgba(241, 92, 92, 0.2) !important;
    color: #f15c5c !important;
}

.btn-close-viewer:hover {
    background: rgba(241, 92, 92, 0.4) !important;
}

/* Navegação (Setas) */
.viewer-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(32, 44, 51, 0.5);
    border: none;
    color: #e9edef;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}

.viewer-nav-btn:hover {
    background: rgba(0, 168, 132, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.viewer-nav-btn.prev {
    left: 20px;
}

.viewer-nav-btn.next {
    right: 20px;
}

/* Legenda (Rodapé) */
.viewer-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    text-align: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: #e9edef;
    font-size: 14px;
    pointer-events: none;
    /* Permite clicar através */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* --- COLUNAS OPCIONAIS CRM (Toggled) --- */
.col-optional {
    display: none;
}

.crm-show-details .col-optional {
    display: table-cell;
    /* ou block, dependendo do elemento, mas é td/th */
}

/* --- RESPONSIVIDADE TABELA CRM --- */
@media (max-width: 768px) {
    .responsive-hide {
        display: none !important;
    }

    .crm-window-title {
        font-size: 18px !important;
    }

    .crm-th,
    .crm-td {
        padding: 10px !important;
        font-size: 12px !important;
    }

    /* Stack controls on mobile */
    .crm-sub-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    #crm-pagination-container {
        justify-content: center;
        width: 100%;
    }
}

/* --- PREVIEW DOCUMENTOS A4 (FIX) --- */
.swal-page-preview {
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
    width: 90vw !important;
    max-width: 1200px !important;
}

.preview-paper-a4 {
    background: white !important;
    color: black !important;
    padding: 50px !important;
    width: 210mm !important;
    /* Largura A4 Fixa */
    min-width: 210mm !important;
    /* IMPEDE COLAPSO */
    min-height: 297mm !important;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3) !important;
    font-family: 'Times New Roman', serif !important;
    font-size: 12pt !important;
    line-height: 1.5 !important;
    text-align: left !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    /* CRÍTICO: Impede que o flexbox esmague a folha */
    margin: 20px auto !important;
}

/* Força reset nos filhos para evitar que estilos do Word quebrem tudo */
.preview-paper-a4 * {
    max-width: 100% !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    /* Garante quebras de linha */
}

/* Sobrescreve larguras fixas malucas do Word */
.preview-paper-a4 div,
.preview-paper-a4 p,
.preview-paper-a4 span {
    width: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    text-indent: 0 !important;
}

/* RODAPÉ DA SIDEBAR (PARA BUSCA GLOBAL) */
.sidebar-footer {
    padding: 10px;
    background: var(--wa-header);
    border-top: 1px solid #222d34;
    flex-shrink: 0;
}

.busca-global-wrapper {
    position: relative;
    width: 100%;
}

.busca-global-input-container {
    background: #2a3942;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 35px;
    border: 1px solid transparent;
    transition: 0.2s;
}

.busca-global-wrapper:focus-within .busca-global-input-container {
    border-color: var(--wa-teal);
    background: #3b4a54;
}

#busca-global-input {
    background: transparent;
    border: none;
    color: var(--wa-text);
    width: 100%;
    padding: 8px 0;
    outline: none;
    font-size: 14px;
}

.busca-global-painel {
    position: absolute;
    bottom: 50px;
    /* Abre para CIMA */
    left: 0;
    right: 0;
    background: #233138;
    border-radius: 12px;
    /* Mais arredondado: estilo balão */
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6);
    /* Sombra para cima */
    z-index: 9999;
    max-height: 500px;
    overflow-y: auto;
    display: none;
    border: 1px solid #3b4a54;
    padding: 4px;
}

.busca-global-painel.ativo {
    display: block;
    animation: fadeIn 0.2s ease;
}

.busca-global-header {
    padding: 12px 16px;
    border-bottom: 1px solid #3b4a54;
    font-size: 12px;
    color: var(--wa-text-dim);
}

.busca-global-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    transition: 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.busca-global-item:hover {
    background: #111b21;
}

.busca-global-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #3b4a54;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.busca-global-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.busca-global-info {
    flex: 1;
    min-width: 0;
}

.busca-global-nome {
    font-size: 14px;
    font-weight: 500;
    color: var(--wa-text);
    margin-bottom: 2px;
}

.busca-global-texto {
    font-size: 13px;
    color: var(--wa-text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.busca-global-texto mark {
    background: rgba(0, 168, 132, 0.3);
    color: #fff;
    border-radius: 2px;
    padding: 0 2px;
}

.origem-op {
    color: var(--wa-teal);
}

.busca-global-data {
    font-size: 11px;
    color: var(--wa-text-dim);
    white-space: nowrap;
}

.busca-global-vazio,
.busca-global-loading {
    padding: 30px;
    text-align: center;
    color: var(--wa-text-dim);
    font-size: 14px;
}

/* ==========================================================================
    AUDITORIA (UI)
   ========================================================================== */
.audit-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
}

.audit-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: #202c33;
    padding: 15px;
    border-radius: 8px;
}

.audit-table-wrapper {
    flex: 1;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid #3b4a54;
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.audit-table th {
    background: #2a3942;
    color: var(--wa-teal);
    text-align: left;
    padding: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    font-size: 11px;
}

.audit-row {
    border-bottom: 1px solid #222d34;
    transition: 0.1s;
}

.audit-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.audit-row td {
    padding: 12px;
    vertical-align: middle;
}

.audit-data {
    color: var(--wa-text-dim);
    white-space: nowrap;
}

.audit-contato {
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audit-detalhes {
    color: var(--wa-text-dim);
    font-style: italic;
    font-size: 12px;
}

/* Badges de Auditoria */
.audit-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.badge-azul {
    background: rgba(83, 189, 235, 0.15);
    color: #53bdeb;
}

.badge-vermelho {
    background: rgba(241, 92, 92, 0.15);
    color: #f15c5c;
}

.badge-amarelo {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.badge-verde {
    background: rgba(0, 168, 132, 0.15);
    color: #00a884;
}

.badge-roxo {
    background: rgba(190, 82, 242, 0.15);
    color: #be52f2;
}

.badge-laranja {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
}

.badge-cinza {
    background: rgba(134, 150, 160, 0.15);
    color: #8696a0;
}

.audit-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding-bottom: 20px;
}

/* ?? SISTEMA DE ARQUIVAMENTO */
.archived-chats-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.archived-chats-row:hover {
    background: #202c33;
}

.archived-chats-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wa-teal);
    font-size: 18px;
}

.archived-chats-label {
    flex: 1;
    font-size: 15px;
    color: #e9edef;
}

.archived-chats-count {
    background: #00a884;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 15px;
    text-align: center;
}

.archived-header {
    background: #202c33;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.archived-header i {
    cursor: pointer;
    color: #00a884;
    font-size: 18px;
}