/* ============================================================
   BOTZAPI — CONVERSAS (Layout WhatsApp Web)
   Cores oficiais WhatsApp:
   - Light: bg=#efeae2 (bege pattern), out=#d9fdd3, in=#ffffff
   - Dark:  bg=#0b141a, out=#005c4b, in=#202c33, panel=#111b21
   ============================================================ */

:root {
    --wa-bg:        #efeae2;
    --wa-panel:     #ffffff;
    --wa-panel-alt: #f0f2f5;
    --wa-list-hover:#f5f6f6;
    --wa-list-active:#f0f2f5;
    --wa-border:    #e9edef;
    --wa-text:      #111b21;
    --wa-text-mut:  #667781;
    --wa-msg-out:   #d9fdd3;
    --wa-msg-in:    #ffffff;
    --wa-msg-shadow:0 1px 0.5px rgba(11,20,26,0.13);
    --wa-accent:    #00a884;
    --wa-accent-dk: #008069;
    --wa-check:     #53bdeb;
    --wa-badge:     #25d366;
    --wa-topbar:    #f0f2f5;
    --wa-composer:  #f0f2f5;
}

[data-theme="dark"] {
    --wa-bg:        #0b141a;
    --wa-panel:     #111b21;
    --wa-panel-alt: #202c33;
    --wa-list-hover:#202c33;
    --wa-list-active:#2a3942;
    --wa-border:    #2a3942;
    --wa-text:      #e9edef;
    --wa-text-mut:  #8696a0;
    --wa-msg-out:   #005c4b;
    --wa-msg-in:    #202c33;
    --wa-msg-shadow:0 1px 0.5px rgba(0,0,0,0.4);
    --wa-topbar:    #202c33;
    --wa-composer:  #202c33;
}

/* ============ LAYOUT ============ */
.conv-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    height: 100%;
    min-height: 0;
    background: var(--wa-bg);
    border: 1px solid var(--wa-border);
    border-radius: 0;
    overflow: hidden;
}

/* ============ COLUNA 1: LISTA ============ */
.conv-list {
    background: var(--wa-panel);
    border-right: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.conv-search {
    padding: 8px 12px;
    background: var(--wa-panel);
    border-bottom: 1px solid var(--wa-border);
}
.conv-search .input {
    width: 100%;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: var(--wa-panel-alt);
    color: var(--wa-text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}
.conv-search .input::placeholder { color: var(--wa-text-mut); }
.conv-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.conv-list-items::-webkit-scrollbar { width: 8px; }
.conv-list-items::-webkit-scrollbar-thumb { background: var(--wa-border); border-radius: 4px; }
.conv-list-items::-webkit-scrollbar-track { background: transparent; }

.conv-item {
    display: flex;
    gap: 12px;
    padding: 10px 15px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--wa-border);
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-family: inherit;
    color: var(--wa-text);
    transition: background 0.1s;
    align-items: center;
}
.conv-item:hover { background: var(--wa-list-hover); }
.conv-item.active { background: var(--wa-list-active); }

.conv-avatar {
    width: 49px;
    height: 49px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: white;
    display: grid;
    place-items: center;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.conv-item-body { flex: 1; min-width: 0; }
.conv-item-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 3px;
}
.conv-item-nome {
    font-size: 15px;
    font-weight: 400;
    color: var(--wa-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}
.conv-item-hora {
    font-size: 11.5px;
    color: var(--wa-text-mut);
    flex-shrink: 0;
    font-weight: 400;
}
.conv-item-bot {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    align-items: center;
}
.conv-item-msg {
    font-size: 13.5px;
    color: var(--wa-text-mut);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}
.conv-item-badges { display: flex; gap: 4px; align-items: center; }
.conv-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 100px;
    font-weight: 500;
    line-height: 1.5;
    min-width: 20px;
    text-align: center;
}
.conv-badge.naolidas { background: var(--wa-badge); color: white; }
.conv-badge.pausado { background: #fef3c7; color: #92400e; padding: 1px 6px; font-size: 12px; }
[data-theme="dark"] .conv-badge.pausado { background: rgba(251,191,36,0.2); color: #fbbf24; }

/* ============ COLUNA 2: CHAT ============ */
.conv-chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    background: var(--wa-bg);
    position: relative;
}

/* Fundo pattern estilo WhatsApp */
.conv-chat::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(0,0,0,0.02) 1px, transparent 1px),
        radial-gradient(circle at 60% 70%, rgba(0,0,0,0.02) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
    z-index: 0;
}
[data-theme="dark"] .conv-chat::before {
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.015) 1px, transparent 1px),
        radial-gradient(circle at 60% 70%, rgba(255,255,255,0.015) 1px, transparent 1px);
}

.conv-chat-head {
    padding: 10px 16px;
    background: var(--wa-topbar);
    border-bottom: 1px solid var(--wa-border);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 2;
}
.conv-back {
    display: none;
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--wa-text);
    padding: 4px 8px;
    border-radius: 50%;
    font-family: inherit;
}
.conv-back:hover { background: var(--wa-list-hover); }
.conv-chat-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.conv-chat-nome {
    font-size: 16px;
    font-weight: 400;
    color: var(--wa-text);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.conv-chat-num {
    font-size: 12.5px;
    color: var(--wa-text-mut);
    line-height: 1.3;
    margin-top: 2px;
}
.conv-chat-actions { flex-shrink: 0; }

/* Toggle bot ativo/pausado */
.conv-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--wa-panel);
    border: 1px solid var(--wa-border);
    font-size: 12.5px;
    user-select: none;
    color: var(--wa-text);
    transition: background 0.15s;
}
.conv-toggle:hover { background: var(--wa-list-hover); }
.conv-toggle input { display: none; }
.conv-toggle-slider {
    width: 32px;
    height: 18px;
    background: #94a3b8;
    border-radius: 100px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.conv-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.conv-toggle input:checked + .conv-toggle-slider { background: var(--wa-accent); }
.conv-toggle input:checked + .conv-toggle-slider::after { transform: translateX(14px); }
.conv-toggle-label { font-weight: 500; font-size: 12.5px; }

/* ============ MENSAGENS ============ */
.conv-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    z-index: 1;
}
.conv-msgs::-webkit-scrollbar { width: 8px; }
.conv-msgs::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
[data-theme="dark"] .conv-msgs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.msg-linha { display: flex; margin-top: 2px; }
.msg-linha.me { justify-content: flex-end; }
.msg-linha.them { justify-content: flex-start; }
/* Adiciona gap maior quando alterna direção (visual de "novo bloco") */
.msg-linha.me + .msg-linha.them,
.msg-linha.them + .msg-linha.me { margin-top: 8px; }

.msg-bolha {
    max-width: 65%;
    padding: 6px 8px 8px;
    border-radius: 8px;
    position: relative;
    line-height: 1.35;
    font-size: 14.2px;
    word-wrap: break-word;
    box-shadow: var(--wa-msg-shadow);
    min-width: 68px;
}

/* Bolha "me" (verde) — tail à direita */
.msg-linha.me .msg-bolha {
    background: var(--wa-msg-out);
    color: var(--wa-text);
    border-top-right-radius: 0;
}
.msg-linha.me .msg-bolha::before {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 0; height: 0;
    border: 8px solid transparent;
    border-top-color: var(--wa-msg-out);
    border-right: 0;
}

/* Bolha "them" (branca/dark) — tail à esquerda */
.msg-linha.them .msg-bolha {
    background: var(--wa-msg-in);
    color: var(--wa-text);
    border-top-left-radius: 0;
}
.msg-linha.them .msg-bolha::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0; height: 0;
    border: 8px solid transparent;
    border-top-color: var(--wa-msg-in);
    border-left: 0;
}

.msg-texto {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 2px 6px 0 0;
}
.msg-hora {
    display: inline-block;
    font-size: 11px;
    color: var(--wa-text-mut);
    margin-left: 8px;
    float: right;
    margin-top: 4px;
    line-height: 1;
    opacity: 0.85;
}

/* Badge origem (bot vs painel) */
.msg-origem {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 8px;
    margin-bottom: 4px;
    opacity: 0.9;
}
.msg-origem.bot {
    background: rgba(0,0,0,0.08);
    color: var(--wa-text-mut);
}
.msg-origem.painel {
    background: rgba(0,168,132,0.15);
    color: var(--wa-accent-dk);
}
[data-theme="dark"] .msg-origem.bot { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.6); }
[data-theme="dark"] .msg-origem.painel { background: rgba(37,211,102,0.2); color: #7ed99f; }

/* Mídias */
.msg-img { max-width: 320px; max-height: 320px; border-radius: 6px; display: block; cursor: pointer; margin: 2px 0; }
.msg-audio { max-width: 300px; margin: 4px 0; height: 40px; }
.msg-video { max-width: 320px; max-height: 320px; border-radius: 6px; display: block; margin: 2px 0; }
.msg-midia {
    font-style: italic;
    color: var(--wa-text-mut);
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============ COMPOSER ============ */
.conv-composer {
    padding: 10px 16px;
    background: var(--wa-composer);
    border-top: 1px solid var(--wa-border);
    position: relative;
    z-index: 2;
}
.conv-aviso-bot {
    font-size: 12px;
    color: #92400e;
    background: #fef3c7;
    padding: 7px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    text-align: center;
}
[data-theme="dark"] .conv-aviso-bot {
    background: rgba(251,191,36,0.15);
    color: #fbbf24;
}
.conv-composer-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.conv-input {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: var(--wa-panel);
    color: var(--wa-text);
    font-family: inherit;
    font-size: 14.5px;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    outline: none;
    box-shadow: var(--wa-msg-shadow);
}
.conv-input::placeholder { color: var(--wa-text-mut); }
.conv-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--wa-accent);
    color: white;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: transform 0.1s, background 0.15s;
}
.conv-send:hover:not(:disabled) { background: var(--wa-accent-dk); transform: scale(1.05); }
.conv-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ ESTADOS VAZIOS ============ */
.conv-empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 60px 20px;
    height: 100%;
    color: var(--wa-text);
    background: var(--wa-panel-alt);
}
.conv-empty h3 { color: var(--wa-text); font-weight: 400; }
.conv-empty p { color: var(--wa-text-mut); }
.conv-empty-list {
    text-align: center;
    padding: 40px 20px;
    color: var(--wa-text-mut);
}
.conv-loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--wa-text-mut);
    font-size: 13px;
}

/* ============ MOBILE ============ */
@media (max-width: 768px) {
    .conv-layout {
        grid-template-columns: 1fr;
        position: relative;
        border: none;
    }
    .conv-list { display: flex; }
    .conv-chat { display: none; }
    .conv-layout.chat-aberto .conv-list { display: none; }
    .conv-layout.chat-aberto .conv-chat { display: flex; }
    .conv-back { display: inline-flex; }
    .msg-bolha { max-width: 85%; }
    .conv-item-nome { max-width: 60vw; }
    .conv-msgs { padding: 12px 4%; }
    .conv-chat-nome { font-size: 15px; }
    .conv-toggle-label { display: none; } /* Só slider no mobile */
    .conv-toggle { padding: 6px 8px; }
}

/* ============ AJUSTE PRO APP DO PAINEL ============ */
/* Remove padding do container principal na tela de conversas */
body[data-active="conversas"] .content { padding: 0 !important; }
body[data-active="conversas"] .content.fit { height: 100%; }

/* ============ V3: TABS + FILTROS + LOCK + MODAL + ETIQUETAS ============ */

.conv-tabs {
    display: flex;
    border-bottom: 1px solid var(--wa-border);
    background: var(--wa-panel);
}
.conv-tab {
    flex: 1;
    padding: 12px 8px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--wa-text-mut);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.conv-tab:hover { color: var(--wa-text); background: var(--wa-list-hover); }
.conv-tab.active { color: var(--wa-accent); border-bottom-color: var(--wa-accent); }
.conv-tab-count {
    background: var(--wa-panel-alt);
    color: var(--wa-text-mut);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.conv-tab.active .conv-tab-count { background: var(--wa-accent); color: white; }

.conv-filtros {
    padding: 8px 12px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    background: var(--wa-panel);
    border-bottom: 1px solid var(--wa-border);
    scrollbar-width: none;
}
.conv-filtros::-webkit-scrollbar { display: none; }
.conv-filtros:empty { display: none; }
.conv-chip-etiq {
    background: var(--wa-panel);
    border: 1px solid var(--wa-border);
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11.5px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.12s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}
.conv-chip-etiq:hover { transform: translateY(-1px); }
.conv-chip-etiq.clear {
    background: var(--wa-panel-alt);
    color: var(--wa-text-mut);
    border-color: var(--wa-border);
}

.conv-mini-etiq {
    display: inline-flex;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.4;
    font-weight: 500;
}

.conv-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--wa-text-mut);
    transition: background 0.15s, transform 0.1s;
    font-family: inherit;
    padding: 0;
    display: grid;
    place-items: center;
    line-height: 1;
}
.conv-icon-btn:hover { background: var(--wa-list-hover); color: var(--wa-text); transform: scale(1.05); }
.conv-icon-btn.danger:hover { background: rgba(239,68,68,0.1); color: #ef4444; }
.conv-chat-actions { display: flex; gap: 4px; align-items: center; }

.conv-etiq-bar {
    padding: 6px 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    background: var(--wa-panel-alt);
    border-bottom: 1px solid var(--wa-border);
    min-height: 8px;
}
.conv-etiq-bar:empty { display: none; }
.conv-etiq-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
}
.conv-etiq-remove {
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 0 2px;
    font-size: 11px;
    opacity: 0.7;
    font-family: inherit;
}
.conv-etiq-remove:hover { opacity: 1; }

.conv-badge.arquivada { background: #d4d4d8; color: #52525b; padding: 1px 5px; font-size: 12px; }
[data-theme="dark"] .conv-badge.arquivada { background: rgba(212,212,216,0.15); color: #a1a1aa; }

/* ============ LOCK OVERLAY (composer bloqueado quando bot ativo) ============ */
.conv-lock-overlay {
    padding: 16px;
    background: var(--wa-panel);
    border: 1px dashed var(--wa-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.conv-lock-msg {
    font-size: 13px;
    color: var(--wa-text-mut);
    font-weight: 500;
}
.conv-lock-btn {
    background: linear-gradient(135deg, var(--wa-accent), var(--wa-accent-dk));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 100px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(0,168,132,0.35);
    transition: all 0.15s;
}
.conv-lock-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,168,132,0.5); }
.conv-lock-btn:active { transform: translateY(0); }
.conv-lock-btn span { font-size: 16px; }

/* ============ MODAL ============ */
.conv-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 20px;
    animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.conv-modal {
    background: var(--wa-panel);
    border-radius: 14px;
    max-width: 480px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.conv-modal-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--wa-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.conv-modal-head h3 { font-size: 16px; font-weight: 600; margin: 0; color: var(--wa-text); }
.conv-modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--wa-text-mut);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: inherit;
}
.conv-modal-close:hover { background: var(--wa-list-hover); color: var(--wa-text); }
.conv-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.conv-modal-sep {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--wa-text-mut);
    margin: 20px 0 10px;
    padding-top: 16px;
    border-top: 1px solid var(--wa-border);
}
.conv-modal-criar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.conv-modal-criar .input {
    padding: 8px 12px;
    border: 1px solid var(--wa-border);
    border-radius: 6px;
    background: var(--wa-panel-alt);
    color: var(--wa-text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}
#etiqLista {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.conv-etiq-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.conv-etiq-check:hover { background: var(--wa-list-hover); }
.conv-etiq-check input { cursor: pointer; }
.conv-etiq-check-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid;
}

/* ============ V3.1: FILTER DROPDOWN LIMPO ============ */

.conv-search-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    background: var(--wa-panel);
    border-bottom: 1px solid var(--wa-border);
}
.conv-search-bar .conv-search {
    flex: 1;
    padding: 0;
    border: none;
    background: transparent;
}

.conv-filter-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--wa-panel-alt);
    border: 1px solid transparent;
    color: var(--wa-text-mut);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.15s;
    flex-shrink: 0;
    font-family: inherit;
}
.conv-filter-btn:hover { background: var(--wa-list-hover); color: var(--wa-text); }
.conv-filter-btn.has-filter { background: var(--wa-accent); color: white; border-color: var(--wa-accent); }
.conv-filter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 100px;
    line-height: 1.4;
    min-width: 16px;
    text-align: center;
}

.conv-filter-active {
    padding: 6px 12px;
    background: var(--wa-panel-alt);
    border-bottom: 1px solid var(--wa-border);
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    min-height: 0;
}
.conv-filter-active:empty { display: none; padding: 0; border-bottom: none; }
.conv-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 500;
    background: var(--wa-panel);
    border: 1px solid var(--wa-border);
    color: var(--wa-text);
}
.conv-filter-tag button {
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 0 2px;
    opacity: 0.6;
    font-family: inherit;
}
.conv-filter-tag button:hover { opacity: 1; }

/* Popover de filtros */
.conv-filter-popover {
    position: fixed;
    background: var(--wa-panel);
    border: 1px solid var(--wa-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    min-width: 260px;
    max-height: 500px;
    overflow-y: auto;
    z-index: 9999;
    animation: popIn 0.12s;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.96) } to { opacity: 1; transform: scale(1) } }
.conv-filter-popover-section {
    padding: 8px 4px;
    border-bottom: 1px solid var(--wa-border);
}
.conv-filter-popover-section:last-child { border-bottom: none; }
.conv-filter-popover-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--wa-text-mut);
    padding: 4px 12px 6px;
}
.conv-filter-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--wa-text);
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    border-radius: 6px;
    margin: 1px 4px;
}
.conv-filter-opt:hover { background: var(--wa-list-hover); }
.conv-filter-opt.selected { background: var(--wa-list-active); color: var(--wa-accent); font-weight: 500; }
.conv-filter-opt-check {
    width: 16px;
    height: 16px;
    display: grid;
    place-items: center;
    color: var(--wa-accent);
    flex-shrink: 0;
    font-weight: 700;
}
.conv-filter-opt-badge {
    margin-left: auto;
    background: var(--wa-panel-alt);
    color: var(--wa-text-mut);
    padding: 1px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
}

/* Some com o CSS antigo dos tabs/chips */
.conv-tabs, .conv-filtros { display: none !important; }

/* ============ V3.2: HEADER CHIPS (botões sempre visíveis) ============ */

.conv-header-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--wa-panel-alt);
    border: 1px solid var(--wa-border);
    border-radius: 100px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--wa-text);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.conv-header-chip:hover {
    background: var(--wa-list-hover);
    transform: translateY(-1px);
}
.conv-header-chip.active {
    background: var(--wa-accent);
    border-color: var(--wa-accent);
    color: white;
    box-shadow: 0 2px 8px rgba(0,168,132,0.25);
}
.conv-header-chip-count {
    background: rgba(0,0,0,0.15);
    padding: 1px 7px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    line-height: 1.5;
}
[data-theme="dark"] .conv-header-chip-count {
    background: rgba(255,255,255,0.15);
}
.conv-header-chip.active .conv-header-chip-count {
    background: rgba(255,255,255,0.25);
}

/* Esconde chips antigos que ainda podem existir */
.conv-filter-btn { display: none !important; }
.conv-filter-active { display: none !important; }

/* Mobile: economiza espaço */
@media (max-width: 768px) {
    .conv-header-chip {
        padding: 5px 10px;
        font-size: 11.5px;
    }
    .conv-header-chip span:nth-child(2) {
        display: none; /* esconde texto, deixa só ícone + count */
    }
    .conv-header-chip-count {
        margin-left: -2px;
    }
}

/* ============================================================
   V3.3 — Minimalista + Ux (Linear/Superhuman style)
   ============================================================ */

/* Segmentos: 3 abas de texto puro no topo da lista */
.conv-segments {
    display: flex;
    gap: 2px;
    padding: 10px 12px 8px;
    background: var(--wa-panel);
    border-bottom: 1px solid var(--wa-border);
    align-items: center;
}
.conv-seg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--wa-text-mut);
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
}
.conv-seg:hover {
    background: var(--wa-list-hover);
    color: var(--wa-text);
}
.conv-seg.active {
    background: var(--wa-list-active);
    color: var(--wa-text);
    font-weight: 600;
}
/* Etiqueta ativa: usa cor da etiqueta */
.conv-seg.active[data-view="etiqueta"] {
    background: color-mix(in srgb, var(--seg-color, var(--wa-accent)) 20%, transparent);
    color: var(--seg-color, var(--wa-accent));
}
.conv-seg-count {
    background: var(--wa-panel-alt);
    color: var(--wa-text-mut);
    padding: 0px 6px;
    border-radius: 100px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.6;
    min-width: 18px;
    text-align: center;
}
.conv-seg.active .conv-seg-count {
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
}
[data-theme="dark"] .conv-seg.active .conv-seg-count {
    background: rgba(255, 255, 255, 0.15);
}
.conv-seg-dropdown {
    margin-left: auto;
}
.conv-seg-dropdown svg { opacity: 0.5; }

/* Search bar simplificada */
.conv-search-bar {
    padding: 6px 12px 10px;
    background: var(--wa-panel);
    border-bottom: 1px solid var(--wa-border);
}
.conv-search-input {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid var(--wa-border);
    border-radius: 8px;
    background: var(--wa-panel-alt);
    color: var(--wa-text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.12s;
}
.conv-search-input:focus { border-color: var(--wa-accent); }
.conv-search-input::placeholder { color: var(--wa-text-mut); }

/* Toast */
.conv-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--wa-text);
    color: var(--wa-panel);
    padding: 10px 20px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10000;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
    white-space: nowrap;
}
.conv-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Esconde widget de suporte nesta tela */
body.conversas-page #zsw { display: none !important; }

/* Esconde qualquer resto de UI antiga */
.conv-tabs, .conv-filtros, .conv-filter-btn, .conv-filter-active,
.conv-header-chip { display: none !important; }

/* Popover reutilizado — só ajusta posição pra abrir pra baixo/esquerda */
.conv-filter-popover { min-width: 220px; }

/* ============ V3.4 — STATUS BADGES ============ */

.conv-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    margin-right: 4px;
    line-height: 1;
    vertical-align: middle;
}
.conv-status-badge.status-ok {
    opacity: 0.65;
    filter: grayscale(0.2);
}
.conv-status-badge.status-alerta {
    filter: none;
}
.conv-status-badge.status-pausada {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
}

/* ============ V3.5 FIXES ============ */

/* Widget de suporte não pode cobrir conteúdo nas outras telas.
   Adiciona espaço reservado no bottom para que o widget "flutue" sem sobrepor. */
body[data-active="dashboard"] .content,
body[data-active="config"] .content,
body[data-active="base"] .content,
body[data-active="metricas"] .content,
body[data-active="conta"] .content {
    padding-bottom: 90px !important;
}

/* Já esconde em conversas — reafirma pra garantir */
body.conversas-page #zsw,
body[data-active="conversas"] #zsw {
    display: none !important;
}

/* ============ V3.6 — AJUSTES DE STATUS BADGE ============ */

/* Alerta discreto, do lado da última mensagem (não competindo com hora) */
.conv-item-badges .conv-status-badge.status-alerta {
    font-size: 12px;
    opacity: 0.7;
}
.conv-item-badges .conv-status-badge.status-pausada {
    font-size: 11px;
    color: #94a3b8;
}

/* Aumenta um pouco a coluna de badges pra caber alerta + etiquetas */
.conv-item-badges {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

/* ============ V3.7 — Widget reposicionado + espaço garantido ============ */

/* Widget: canto inferior direito, com backdrop sutil pra não misturar com texto */
#zsw {
    bottom: 20px !important;
    right: 20px !important;
    z-index: 100 !important;
}
#zsw .zsw-btn {
    box-shadow: 0 4px 20px rgba(0,0,0,0.25), 0 0 0 6px rgba(255,255,255,0.05) !important;
}

/* (removido padding-bottom que forçava scroll — página inteira agora é sem scroll) */

/* ============ NOTIFICAÇÕES ============ */
.notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 100px;
    position: absolute;
    top: 6px;
    right: 8px;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--bg, #09090b);
    animation: notifPulse 2s ease-in-out infinite;
}
@keyframes notifPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Badge no bottom nav mobile */
.bottom-nav a .notif-badge {
    top: 4px;
    right: 20%;
}

/* ============ V4.6 — Sem scroll na página, scroll interno nos containers ============ */

/* Página inteira NUNCA rola. Só scroll interno em cards/inputs. */
body[data-active="dashboard"] .content.fit,
body[data-active="config"] .content.fit,
body[data-active="base"] .content.fit,
body[data-active="conta"] .content.fit {
    overflow: hidden !important;
    min-height: 0 !important;
    max-height: 100% !important;
}

/* Cards no dashboard: podem ter scroll interno se conteúdo passar */
body[data-active="dashboard"] .card {
    min-height: 0 !important;
    overflow: hidden;
}
body[data-active="dashboard"] .card-body {
    overflow-y: auto;
    max-height: 100%;
}

/* Colunas do configurar-bot: scroll interno se necessário */
body[data-active="config"] .content.fit > div {
    min-height: 0;
    max-height: 100%;
}

/* V4.3: garante scroll no configurar-bot mesmo com style inline overflow:hidden */
body[data-active="config"] .content.fit[style*="overflow"] {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: calc(100vh - 60px);
}

/* ============ V4.4 — Widget mobile no menu ============ */
/* No mobile, o widget flutuante some (ficará dentro do menu "Mais") */
@media (max-width: 900px) {
    #zsw {
        display: none !important;
    }
}

/* ============ Modal genérico (usado no editor de templates) ============ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s;
}
.modal-backdrop.show { display: flex; }
.modal {
    background: var(--bg, #fff);
    border-radius: 14px;
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    color: var(--text);
}
.modal-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-head h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: inherit;
}
.modal-close:hover { background: var(--bg-hover, rgba(0,0,0,0.05)); color: var(--text); }
.modal-body {
    overflow-y: auto;
    flex: 1;
}
