/* chat-widget.css — Chat interno estilo Facebook Messenger */

#cw-root {
    --cw-gold: var(--primary-gold, #d4af37);
    --cw-bg: #1a1a1f;
    --cw-bg-2: #25252d;
    --cw-bg-3: #2f2f38;
    --cw-text: #e8e8ec;
    --cw-text-muted: #9090a0;
    --cw-border: #38384a;
    --cw-online: #22c55e;
    --cw-blue: #3b82f6;
    --cw-radius: 12px;
}

/* FAB — posicionado à esquerda do FAB nativo das páginas (que fica em right: 20px) */
.cw-fab {
    position: fixed;
    right: 90px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cw-gold), #b8941f);
    color: #1a1a1f;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(212, 175, 55, 0.25);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: transform 0.12s, box-shadow 0.12s;
}
.cw-fab:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 3px 8px rgba(212, 175, 55, 0.35);
}
.cw-fab:active { transform: scale(0.96); }
/* Estado desconectado: só dessatura a FAB, sem ponto vermelho.
   O ponto vermelho fica reservado pra notificação de mensagem nova. */
.cw-fab.cw-disconnected {
    filter: grayscale(0.5) brightness(0.85);
    opacity: 0.85;
}

.cw-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 999px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1a1a1f;
    line-height: 1;
    pointer-events: none;
}
/* Garante que badge sem texto desaparece (evita ponto vazio) */
.cw-fab-badge:empty { display: none !important; }

/* LIST */
.cw-list {
    position: fixed;
    right: 90px;
    bottom: 90px;
    width: 360px;
    /* Altura fixa: header (~50px) + busca (~50px) + ~5 conversas (5×72px) ~= 460px */
    height: 460px;
    max-height: calc(100vh - 130px);
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 9001;
    display: flex;
    flex-direction: column;
    color: var(--cw-text);
    animation: cw-list-in 0.10s ease-out;
    overflow: hidden;
}
.cw-list[hidden] { display: none !important; }
@keyframes cw-list-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cw-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--cw-border);
}
.cw-list-head h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}
.cw-list-actions { display: flex; gap: 4px; }
.cw-list-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--cw-border);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--cw-text-muted);
}
.cw-list-search i { font-size: 0.85rem; padding-left: 6px; }
.cw-list-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--cw-text);
    padding: 6px 0;
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
}
.cw-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: thin;
}
.cw-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.12s;
    border-radius: 8px;
    margin: 0 6px;
}
.cw-list-item:hover { background: var(--cw-bg-2); }
.cw-list-item.cw-unread .cw-list-name { font-weight: 700; }
.cw-list-item.cw-unread .cw-list-preview { color: var(--cw-text); font-weight: 500; }

.cw-list-avatar { position: relative; flex-shrink: 0; }
.cw-list-avatar.cw-online::after,
.cw-popup-avatar.cw-online::after,
.cw-msg-avatar.cw-online::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    background: var(--cw-online);
    border-radius: 50%;
    border: 2px solid var(--cw-bg);
}

.cw-list-info {
    flex: 1;
    min-width: 0;
}
.cw-list-name {
    font-size: 0.92rem;
    color: var(--cw-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-list-preview {
    font-size: 0.78rem;
    color: var(--cw-text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-list-meta {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.cw-list-time {
    font-size: 0.7rem;
    color: var(--cw-text-muted);
}
.cw-unread-dot {
    background: var(--cw-gold);
    color: #1a1a1f;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 999px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* DOCK + POPUPS */
.cw-dock {
    position: fixed;
    right: 160px;
    bottom: 0;
    z-index: 9002;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}
.cw-popup {
    pointer-events: auto;
    width: 320px;
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius) var(--cw-radius) 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    color: var(--cw-text);
    display: flex;
    flex-direction: column;
    height: 440px;
    transition: height 0.12s ease-out;
    animation: cw-popup-in 0.10s ease-out;
}
@keyframes cw-popup-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cw-popup.cw-minimized {
    height: 48px;
    overflow: hidden;
}
.cw-popup.cw-drag-over {
    outline: 2px dashed var(--cw-gold);
    outline-offset: -4px;
    background: rgba(212, 175, 55, 0.06);
}
.cw-popup.cw-drag-over::before {
    content: '📎 Solte para enviar';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 175, 55, 0.1);
    color: var(--cw-gold);
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
    border-radius: var(--cw-radius) var(--cw-radius) 0 0;
}
.cw-popup { position: relative; }
.cw-popup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--cw-bg-2);
    border-bottom: 1px solid var(--cw-border);
    border-radius: var(--cw-radius) var(--cw-radius) 0 0;
    cursor: pointer;
    user-select: none;
}
.cw-popup-head-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}
.cw-popup-avatar { position: relative; flex-shrink: 0; }
.cw-popup-titles { min-width: 0; flex: 1; }
.cw-popup-name {
    font-size: 0.92rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-popup-presence {
    font-size: 0.7rem;
    color: var(--cw-text-muted);
}
.cw-popup-actions { display: flex; gap: 2px; }

.cw-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    scrollbar-width: thin;
    background: var(--cw-bg);
}
.cw-popup-body::-webkit-scrollbar { width: 6px; }
.cw-popup-body::-webkit-scrollbar-thumb { background: var(--cw-border); border-radius: 3px; }

/* MESSAGES */
.cw-msg-sep {
    text-align: center;
    color: var(--cw-text-muted);
    font-size: 0.7rem;
    margin: 12px 0 8px;
    text-transform: capitalize;
}
.cw-msg-system {
    text-align: center;
    color: var(--cw-text-muted);
    font-size: 0.72rem;
    font-style: italic;
    padding: 4px 0;
}
.cw-msg {
    display: flex;
    gap: 6px;
    margin-bottom: 3px;
    align-items: flex-end;
}
.cw-msg.cw-me { flex-direction: row-reverse; }
.cw-msg-avatar, .cw-msg-avatar-spacer {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    align-self: flex-end;
}
.cw-msg-bubble-wrap {
    max-width: 72%;
    display: flex;
    flex-direction: column;
}
.cw-msg.cw-me .cw-msg-bubble-wrap { align-items: flex-end; }
.cw-msg-sender {
    font-size: 0.68rem;
    color: var(--cw-text-muted);
    margin-bottom: 2px;
    padding-left: 10px;
    font-weight: 500;
}
.cw-msg-bubble {
    background: var(--cw-bg-3);
    color: var(--cw-text);
    padding: 6px 11px;
    border-radius: 14px;
    font-size: 0.84rem;
    line-height: 1.3;
    word-break: break-word;
    white-space: pre-wrap;
}
.cw-msg.cw-me .cw-msg-bubble {
    background: var(--cw-gold);
    color: #1a1a1f;
}
/* Bubbles consecutivas do mesmo sender: cantos mais retos */
.cw-msg + .cw-msg.cw-me .cw-msg-bubble { border-top-right-radius: 6px; }
.cw-msg.cw-me + .cw-msg.cw-me .cw-msg-bubble { border-bottom-right-radius: 6px; }
.cw-msg.cw-me + .cw-msg.cw-me + .cw-msg.cw-me .cw-msg-bubble { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.cw-msg.cw-other + .cw-msg.cw-other .cw-msg-bubble { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.cw-msg-time {
    font-size: 0.64rem;
    color: var(--cw-text-muted);
    margin-top: 1px;
    padding: 0 8px;
    opacity: 0.75;
}
.cw-msg-image {
    display: block;
    max-width: 220px;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    background: transparent;
    border: none;
    padding: 0;
    cursor: zoom-in;
}
.cw-msg-image img {
    display: block;
    width: 100%;
    height: auto;
}
.cw-msg-image .cw-msg-bubble {
    border-radius: 0 0 12px 12px;
    margin-top: -2px;
}
.cw-img-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 220px;
    height: 130px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed var(--cw-border);
    border-radius: 12px;
    color: var(--cw-text-muted);
    font-size: 0.8rem;
}
.cw-img-fallback i { font-size: 1.6rem; opacity: 0.7; }
.cw-msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 12px 14px;
    min-width: 200px;
}
.cw-msg-file i { font-size: 1.4rem; color: var(--cw-gold); }
.cw-msg-file-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}
.cw-msg-file-size {
    font-size: 0.7rem;
    color: var(--cw-text-muted);
    margin-top: 2px;
}

/* Reply: bar acima do input + preview na bolha */
.cw-reply-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 0 8px;
    background: rgba(212, 175, 55, 0.12);
    border-left: 3px solid var(--cw-gold);
    border-radius: 6px;
    margin-bottom: 4px;
}
.cw-reply-bar > i { color: var(--cw-gold); font-size: 0.85rem; }
.cw-reply-info { flex: 1; min-width: 0; }
.cw-reply-to { font-size: 0.72rem; color: var(--cw-gold); font-weight: 600; }
.cw-reply-snippet {
    font-size: 0.78rem;
    color: var(--cw-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

/* Preview de mensagem respondida — sempre sobre fundo escuro do popup */
.cw-msg-reply {
    background: rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--cw-gold);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.78rem;
    margin-bottom: 4px;
    cursor: pointer;
    max-width: 280px;
    transition: background 0.12s;
}
.cw-msg-reply:hover {
    background: rgba(255, 255, 255, 0.14);
}
.cw-msg-reply-sender {
    color: var(--cw-gold);
    font-weight: 600;
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-msg-reply-content {
    color: var(--cw-text);
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Clamp mensagens muito longas (>500 chars) com "Ver mais..." */
.cw-msg-bubble.cw-long {
    max-height: 240px;
    overflow: hidden;
    position: relative;
}
.cw-msg-bubble.cw-long.cw-expanded {
    max-height: none;
}
.cw-msg-bubble.cw-long::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.5));
    pointer-events: none;
}
.cw-msg-bubble.cw-long.cw-expanded::after { display: none; }
.cw-msg-toggle {
    background: transparent;
    border: 1px solid var(--cw-border);
    color: var(--cw-text-muted);
    font-size: 0.72rem;
    border-radius: 10px;
    padding: 2px 8px;
    margin-top: 4px;
    cursor: pointer;
}
.cw-msg-toggle:hover { color: var(--cw-text); border-color: var(--cw-text-muted); }

/* Auto-linkify URLs em mensagens */
.cw-msg-bubble .cw-link {
    color: var(--cw-blue);
    text-decoration: underline;
    word-break: break-all;
}
.cw-msg.cw-me .cw-msg-bubble .cw-link { color: #0c4a6e; }
.cw-msg-bubble .cw-link:hover { opacity: 0.85; }

/* Group info modal — estilo WhatsApp */
.cw-grp-modal { max-width: 460px; }
.cw-grp-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px 16px;
    border-bottom: 1px solid var(--cw-border);
    margin-bottom: 12px;
}
.cw-grp-name-display { flex: 1; min-width: 0; }
.cw-grp-name-label {
    font-size: 0.72rem;
    color: var(--cw-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.cw-grp-name-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--cw-text);
    word-break: break-word;
}
.cw-grp-members-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 10px;
    color: var(--cw-text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.cw-btn-link {
    background: transparent;
    border: none;
    color: var(--cw-gold);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.12s;
}
.cw-btn-link:hover { background: rgba(212, 175, 55, 0.1); }
.cw-grp-members {
    display: flex;
    flex-direction: column;
}
.cw-grp-member {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px;
    border-radius: 8px;
    transition: background 0.12s;
}
.cw-grp-member:hover { background: rgba(255, 255, 255, 0.03); }
.cw-grp-member-avatar { position: relative; flex-shrink: 0; }
.cw-grp-member-avatar.cw-online::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--cw-online);
    border: 2px solid #1f1f26;
}
.cw-grp-member-info { flex: 1; min-width: 0; }
.cw-grp-member-name {
    font-size: 0.92rem;
    color: var(--cw-text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-grp-tag-you {
    color: var(--cw-text-muted);
    font-weight: 400;
    font-size: 0.78rem;
}
.cw-grp-member-meta {
    font-size: 0.74rem;
    color: var(--cw-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-grp-admin-badge {
    background: rgba(212, 175, 55, 0.18);
    color: var(--cw-gold);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cw-grp-menu-btn { color: var(--cw-text-muted); }
.cw-grp-menu-btn:hover { color: var(--cw-text); background: rgba(255, 255, 255, 0.08); }

.cw-grp-menu {
    background: #25252d;
    border: 1px solid var(--cw-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 4px;
    min-width: 220px;
    display: flex;
    flex-direction: column;
}
.cw-grp-menu button {
    background: transparent;
    border: none;
    color: var(--cw-text);
    font-family: inherit;
    font-size: 0.85rem;
    text-align: left;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.12s;
}
.cw-grp-menu button:hover { background: rgba(255, 255, 255, 0.06); }
.cw-grp-menu button.danger { color: #f87171; }
.cw-grp-menu button.danger:hover { background: rgba(248, 113, 113, 0.1); }
.cw-grp-menu button i { width: 16px; text-align: center; opacity: 0.8; }

.cw-btn-danger {
    background: transparent;
    color: #f87171;
    border: 1px solid #f8717155;
}
.cw-btn-danger:hover { background: rgba(248, 113, 113, 0.1); border-color: #f87171; }
/* .cw-btn-primary é definido mais abaixo (final do arquivo) com todas regras */

/* Linha "Visto às HH:MM" — estilo WhatsApp, abaixo da última msg lida */
.cw-msg-seenline {
    text-align: right;
    color: var(--cw-blue);
    font-size: 0.7rem;
    padding: 2px 14px 6px;
    opacity: 0.85;
    font-weight: 500;
}
.cw-msg-seenline::before {
    content: '\2713\2713  ';
    font-weight: 700;
    margin-right: 2px;
}

/* Read receipts (✓ entregue / ✓✓ lida) */
.cw-msg-status {
    display: inline-flex;
    margin-left: 4px;
    font-size: 0.7rem;
    color: var(--cw-text-muted);
    opacity: 0.75;
}
.cw-msg-status.cw-read { color: var(--cw-blue); opacity: 1; }
.cw-msg.cw-me .cw-msg-status { color: rgba(26, 26, 31, 0.6); }
.cw-msg.cw-me .cw-msg-status.cw-read { color: #0c4a6e; }

/* Botão "responder" — aparece no hover da mensagem */
.cw-msg-action {
    background: transparent;
    border: none;
    color: var(--cw-text-muted);
    padding: 0 4px;
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.12s;
}
.cw-msg:hover .cw-msg-action { opacity: 0.6; }
.cw-msg-action:hover { opacity: 1; color: var(--cw-gold); }

/* Highlight ao pular pra msg respondida */
.cw-msg-highlight .cw-msg-bubble {
    animation: cw-highlight-pulse 1.5s ease;
}
@keyframes cw-highlight-pulse {
    0%, 100% { box-shadow: none; }
    20%, 80% { box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.5); }
}

/* Reactions */
.cw-msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 3px;
}
.cw-msg-reaction {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 1px 7px;
    font-size: 0.78rem;
    color: var(--cw-text);
    cursor: pointer;
    transition: background 0.12s, transform 0.08s;
}
.cw-msg-reaction:hover { background: rgba(255, 255, 255, 0.16); }
.cw-msg-reaction.mine {
    background: rgba(212, 175, 55, 0.22);
    border-color: var(--cw-gold);
}
.cw-msg-reaction span { font-size: 0.7rem; opacity: 0.85; }
.cw-msg.cw-me .cw-msg-reactions { justify-content: flex-end; }

.cw-reaction-picker {
    display: flex;
    gap: 4px;
    background: var(--cw-bg-elev);
    border: 1px solid var(--cw-border);
    border-radius: 22px;
    padding: 6px 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.cw-reaction-picker button {
    background: transparent;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
    transition: background 0.1s, transform 0.08s;
}
.cw-reaction-picker button:hover { background: rgba(255, 255, 255, 0.1); transform: scale(1.2); }

/* Search dentro da conversa */
.cw-popup-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--cw-bg-elev);
    border-bottom: 1px solid var(--cw-border);
}
.cw-popup-search > i { color: var(--cw-text-muted); font-size: 0.8rem; }
.cw-popup-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--cw-text);
    font-size: 0.85rem;
    outline: none;
}
.cw-search-results {
    max-height: 200px;
    overflow-y: auto;
    background: var(--cw-bg);
    border-bottom: 1px solid var(--cw-border);
}
.cw-search-empty {
    padding: 14px;
    text-align: center;
    color: var(--cw-text-muted);
    font-size: 0.8rem;
}
.cw-search-result {
    padding: 8px 12px;
    border-bottom: 1px solid var(--cw-border);
    cursor: pointer;
    transition: background 0.12s;
}
.cw-search-result:hover { background: rgba(255, 255, 255, 0.04); }
.cw-search-sender { font-size: 0.72rem; color: var(--cw-gold); font-weight: 600; }
.cw-search-snippet {
    font-size: 0.82rem;
    color: var(--cw-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-search-time { font-size: 0.68rem; color: var(--cw-text-muted); }

/* Forward modal */
.cw-fwd-preview {
    background: rgba(255, 255, 255, 0.06);
    border-left: 3px solid var(--cw-gold);
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--cw-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cw-fwd-list { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.cw-fwd-item {
    background: transparent;
    border: 1px solid var(--cw-border);
    color: var(--cw-text);
    padding: 8px 12px;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}
.cw-fwd-item:hover { background: rgba(255, 255, 255, 0.05); }
.cw-fwd-item:disabled { opacity: 0.5; cursor: wait; }

/* Lightbox de imagem */
.cw-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
    animation: cw-lb-fade 0.15s ease;
}
@keyframes cw-lb-fade { from { opacity: 0; } to { opacity: 1; } }
.cw-lightbox-inner {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    cursor: default;
}
.cw-lightbox-inner img {
    display: block;
    max-width: 95vw;
    max-height: 95vh;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
}
.cw-lightbox-toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
}
.cw-lightbox-btn {
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}
.cw-lightbox-btn:hover { background: rgba(212, 175, 55, 0.9); color: #1a1a1f; }

/* Typing */
.cw-popup-typing {
    padding: 4px 16px;
    font-size: 0.75rem;
    color: var(--cw-text-muted);
    min-height: 22px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cw-typing-dots {
    display: inline-flex;
    gap: 2px;
}
.cw-typing-dots i {
    width: 5px;
    height: 5px;
    background: var(--cw-text-muted);
    border-radius: 50%;
    display: inline-block;
    animation: cw-typing 1.2s infinite;
}
.cw-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.cw-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes cw-typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* INPUT */
.cw-popup-input {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 6px;
    border-top: 1px solid var(--cw-border);
    background: var(--cw-bg-2);
}
.cw-popup-input textarea {
    flex: 1;
    background: var(--cw-bg-3);
    border: 1px solid var(--cw-border);
    border-radius: 16px;
    color: var(--cw-text);
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    resize: none;
    min-height: 32px;
    max-height: 96px;
    line-height: 1.25;
}
.cw-popup-input textarea:focus { border-color: var(--cw-gold); }
.cw-btn-send {
    background: var(--cw-gold);
    color: #1a1a1f;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.15s;
}
.cw-btn-send:hover { filter: brightness(1.1); }

.cw-btn-icon {
    background: transparent;
    border: none;
    color: var(--cw-text-muted);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.12s;
}
.cw-btn-icon:hover {
    background: var(--cw-bg-3);
    color: var(--cw-text);
}

/* AVATARS */
.cw-avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.cw-avatar-letters {
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

/* MODAL (nova conversa, info grupo) — sólido, sem transparência */
.cw-modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.cw-modal-bg.open { display: flex; animation: cw-fade 0.10s ease-out; }
@keyframes cw-fade { from { opacity: 0; } to { opacity: 1; } }
.cw-modal {
    background: #1f1f26;
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    color: var(--cw-text);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: cw-popup-in 0.12s ease-out;
    overflow: hidden;
}
.cw-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--cw-border);
}
.cw-modal-head h3 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.2;
}
.cw-modal-sub {
    font-size: 0.78rem;
    color: var(--cw-text-muted);
    margin-top: 4px;
}
.cw-modal-head .cw-btn-icon { flex-shrink: 0; margin-top: -2px; }
/* Tabs como segmented control (1:1 / Grupo) */
.cw-modal-tabs {
    display: flex;
    background: var(--cw-bg-2);
    padding: 4px;
    margin: 14px 18px 0;
    border-radius: 10px;
    gap: 2px;
}
.cw-mt {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--cw-text-muted);
    padding: 8px 14px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 7px;
    transition: background 0.12s, color 0.12s;
}
.cw-mt:hover { color: var(--cw-text); }
.cw-mt.active {
    background: var(--cw-bg-3);
    color: var(--cw-gold);
}
.cw-modal-body {
    padding: 14px 18px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.cw-modal-body input[type="search"],
.cw-modal-body input[type="text"] {
    width: 100%;
    background: var(--cw-bg-2);
    border: 1px solid var(--cw-border);
    color: var(--cw-text);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    margin-bottom: 12px;
}
.cw-nc-group-name { margin-bottom: 12px; }
.cw-nc-users {
    max-height: 360px;
    overflow-y: auto;
    margin: 0 -4px;
}
.cw-nc-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.12s;
    margin-bottom: 2px;
}
.cw-nc-user:hover { background: rgba(255, 255, 255, 0.04); }
.cw-nc-user.selected { background: rgba(212, 175, 55, 0.08); }
.cw-nc-user input[type="checkbox"],
.cw-nc-user input[type="radio"] {
    accent-color: var(--cw-gold);
    cursor: pointer;
    width: 18px;
    height: 18px;
}
.cw-nc-info { flex: 1; min-width: 0; }
.cw-nc-info > div:first-child {
    color: var(--cw-text);
    font-size: 0.9rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-nc-email {
    font-size: 0.76rem;
    color: var(--cw-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cw-presence-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--cw-text-muted);
    flex-shrink: 0;
}
.cw-presence-dot.cw-online { background: var(--cw-online); }

.cw-modal-foot {
    padding: 14px 18px;
    border-top: 1px solid var(--cw-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: rgba(0, 0, 0, 0.15);
}
.cw-btn {
    background: var(--cw-bg-2);
    border: 1px solid var(--cw-border);
    color: var(--cw-text);
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.cw-btn:hover { background: var(--cw-bg-3); }
.cw-btn-primary {
    background: var(--cw-gold) !important;
    color: #1a1a1f !important;
    border: 1px solid var(--cw-gold) !important;
    padding: 9px 22px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
}
.cw-btn-primary:disabled {
    background: var(--cw-bg-2) !important;
    color: var(--cw-text-muted) !important;
    border-color: var(--cw-border) !important;
    cursor: not-allowed;
}
.cw-btn-primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.cw-btn-primary:active:not(:disabled) { transform: translateY(0); }

/* EMPTY */
.cw-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--cw-text-muted);
}
.cw-empty i { font-size: 2rem; margin-bottom: 8px; display: block; opacity: 0.5; }
.cw-empty p { margin: 8px 0 14px; font-size: 0.88rem; }

/* PRINT — hide chat */
@media print {
    #cw-root { display: none !important; }
}

/* MOBILE */
@media (max-width: 640px) {
    /* FAB chat alinhado verticalmente com FAB nativo (.fab-btn é 50x50 @ bottom:20px right:20px no mobile)
       Espaço entre eles: 8px. iOS safe-area-inset-bottom adicionado. */
    .cw-fab {
        right: 78px;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        width: 50px;
        height: 50px;
    }
    .cw-list {
        right: 8px;
        left: 8px;
        bottom: calc(82px + env(safe-area-inset-bottom, 0px));
        width: auto;
        max-height: calc(100vh - 110px - env(safe-area-inset-bottom, 0px));
        border-radius: 16px;
    }
    .cw-list-head h4 { font-size: 0.95rem; }
    .cw-list-items { -webkit-overflow-scrolling: touch; }
    .cw-list-item { padding: 12px; min-height: 60px; } /* touch target maior */

    /* Dock: bottom sheet style — só 1 popup visível por vez no mobile */
    .cw-dock {
        right: 0;
        left: 0;
        bottom: 0;
        flex-direction: column;
        gap: 0;
        align-items: stretch;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .cw-popup {
        width: 100%;
        /* Fallback vh para browsers antigos; dvh para Chrome 108+/iOS 15.4+ */
        height: calc(85vh - env(safe-area-inset-bottom, 0px));
        height: calc(85dvh - env(safe-area-inset-bottom, 0px));
        border-radius: var(--cw-radius) var(--cw-radius) 0 0;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
    }
    .cw-popup.cw-minimized { height: 52px; }
    /* Múltiplos popups: mantém só o último expandido, outros minimizados */
    .cw-dock > .cw-popup:not(:last-child) { height: 48px; }
    .cw-dock > .cw-popup:not(:last-child) .cw-popup-body,
    .cw-dock > .cw-popup:not(:last-child) .cw-popup-input { display: none; }

    /* Mensagens com tamanho de fonte mais legível em telas pequenas */
    .cw-msg-bubble { max-width: 80%; }
    .cw-msg-content { font-size: 0.92rem; }

    /* Input: ajustes para teclado virtual não cobrir */
    .cw-popup-input textarea { font-size: 16px !important; /* evita zoom iOS */ }

    /* Modal de nova conversa: full-screen com dvh (anti keyboard cover) */
    .cw-modal-bg { padding: 0; align-items: stretch; }
    .cw-modal {
        max-width: 100%; width: 100%;
        height: 100vh; max-height: 100vh;
        height: 100dvh; max-height: 100dvh;
        border-radius: 0; margin: 0;
    }
    .cw-modal-head { padding: 16px; }
    .cw-modal-body { padding: 12px 14px; flex: 1; overflow-y: auto; }
    .cw-modal-foot { padding: 12px 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
    .cw-modal-foot button { width: 100%; }
}

/* Smartphones MUITO pequenos (iPhone SE etc) */
@media (max-width: 360px) {
    .cw-fab { right: 70px; width: 46px; height: 46px; font-size: 1.25rem; }
    .cw-list-head h4 { font-size: 0.9rem; }
}
