/* ==========================================================================
   INTERFACE DE CHAT WHATSAPP
   ========================================================================== */

/* ===== CONTAINER PRINCIPAL ===== */
.wa-chat-container {
    display: flex;
    /* 50px = altura real do <header class="main-header"> (padding 10+10 + h1 ~30).
       Originalmente era 80px (magic number sem medição), gerava ~30px de gap
       cinza embaixo. Se mudarem o header (font-size do h1, padding), reajustar. */
    height: calc(100vh - 50px);
    border: 1px solid var(--table-border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--content-bg-color);
}

/* ===== PAINEL ESQUERDO - LISTA DE CONVERSAS ===== */
.wa-chat-sidebar {
    width: 360px;
    min-width: 300px;
    border-right: 1px solid var(--table-border-color);
    display: flex;
    flex-direction: column;
    background: var(--content-bg-color);
}

.wa-chat-sidebar-header {
    padding: 12px 15px;
    background: var(--content-bg-color);
    border-bottom: 1px solid var(--table-border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.wa-chat-search-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.wa-chat-search-wrap > i {
    position: absolute;
    left: 12px;
    color: #8696a0;
    font-size: 13px;
    pointer-events: none;
}

.wa-chat-search {
    width: 100%;
    padding: 9px 12px 9px 35px;
    border: none;
    border-radius: 20px;
    background: var(--background-color);
    color: var(--text-color);
    font-size: 13px;
    outline: none;
}

.wa-chat-search::placeholder { color: #8696a0; }

/* Lista de chats */
.wa-chat-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
}

.wa-chat-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(128, 128, 128, 0.08);
    transition: background-color 0.15s;
}

.wa-chat-item { position: relative; }
.wa-chat-item:hover { background: rgba(128, 128, 128, 0.08); }
.wa-chat-item.active { background: rgba(37, 211, 102, 0.1); }

/* Fixado (pinned) */
.wa-chat-pin-icon {
    font-size: 9px;
    color: var(--text-muted, #8696a0);
    transform: rotate(45deg);
    margin-left: 4px;
}
/* Separador entre fixados e normais */
.wa-chat-pin-divider {
    display: flex;
    align-items: center;
    padding: 4px 16px;
    font-size: 11px;
    color: var(--text-muted, #8696a0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(128, 128, 128, 0.08);
    list-style: none;
}
/* Menu de contexto (clique direito) */
.wa-ctx-menu {
    position: fixed;
    background: var(--content-bg-color, #fff);
    border: 1px solid var(--table-border-color, #ddd);
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--box-shadow-color, rgba(0,0,0,0.15));
    z-index: 9999;
    min-width: 180px;
    padding: 4px 0;
    animation: wa-fadeIn 0.1s ease;
}
.wa-ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-color, #2c3e50);
    cursor: pointer;
    transition: background 0.1s;
}
.wa-ctx-item:hover { background: rgba(128, 128, 128, 0.12); }
.wa-ctx-item i { font-size: 12px; color: var(--text-color, #2c3e50); opacity: 0.6; width: 16px; text-align: center; }

/* Avatar */
.wa-chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dfe5e7, #c8d6da);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
    text-transform: uppercase;
}

.wa-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wa-chat-avatar.color-0 { background: linear-gradient(135deg, #25D366, #128C7E); }
.wa-chat-avatar.color-1 { background: linear-gradient(135deg, #7f66ff, #5b3fc5); }
.wa-chat-avatar.color-2 { background: linear-gradient(135deg, #ee5381, #c2185b); }
.wa-chat-avatar.color-3 { background: linear-gradient(135deg, #0795dc, #0277bd); }
.wa-chat-avatar.color-4 { background: linear-gradient(135deg, #ff9800, #ef6c00); }
.wa-chat-avatar.color-5 { background: linear-gradient(135deg, #26a69a, #00796b); }

/* Info do chat */
.wa-chat-info {
    flex: 1;
    margin-left: 12px;
    overflow: hidden;
    min-width: 0;
}

.wa-chat-name {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-last-msg {
    font-size: 12.5px;
    color: #8696a0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.wa-chat-meta {
    text-align: right;
    flex-shrink: 0;
    margin-left: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.wa-chat-time {
    font-size: 11px;
    color: #8696a0;
    white-space: nowrap;
}

.wa-chat-unread {
    background: #25D366;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
    padding: 0 4px;
}

/* ===== PAINEL DIREITO - ÁREA DE CHAT ===== */
.wa-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-color);
    min-width: 0;
    position: relative;
}

/* Drag & drop overlay */
.wa-chat-main.wa-drag-over::after {
    content: '📎 Solte o arquivo aqui';
    position: absolute;
    inset: 0;
    background: rgba(37, 211, 102, 0.12);
    border: 2px dashed #25D366;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #25D366;
    font-weight: 600;
    z-index: 50;
    pointer-events: none;
}

/* Header do chat ativo */
.wa-chat-header {
    padding: 10px 16px;
    background: var(--content-bg-color);
    border-bottom: 1px solid var(--table-border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.wa-chat-header .wa-chat-avatar {
    width: 40px;
    height: 40px;
    font-size: 15px;
}

.wa-chat-header-info { min-width: 0; }

.wa-chat-header-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-header-phone {
    font-size: 12px;
    color: #8696a0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.wa-copy-phone {
    font-size: 11px;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.15s;
}
.wa-copy-phone:hover {
    opacity: 1;
    color: var(--primary-color, #3498db);
}

/* Estado vazio */
.wa-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8696a0;
    padding: 40px;
}

.wa-chat-empty i {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.2;
}

.wa-chat-empty p {
    font-size: 18px;
    opacity: 0.6;
    margin: 0;
}

.wa-chat-empty small {
    opacity: 0.4;
    margin-top: 8px;
}

/* ===== BARRA LATERAL DE BOTÕES RÁPIDOS (VERTICAL) ===== */
.wa-quick-toolbar {
    display: none;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-left: 1px solid var(--table-border-color);
    border-right: 1px solid var(--table-border-color);
    background: var(--content-bg-color);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    width: 48px;
}

.wa-quick-toolbar::-webkit-scrollbar {
    width: 3px;
}

.wa-quick-toolbar::-webkit-scrollbar-thumb {
    background: rgba(128,128,128,0.3);
    border-radius: 2px;
}

.wa-quick-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 6px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.wa-quick-btn:hover {
    background: rgba(37, 211, 102, 0.2);
    color: #25D366;
}

.wa-quick-btn:active {
    background: rgba(37, 211, 102, 0.35);
}

.wa-quick-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.wa-quick-btn svg path {
    fill: currentColor;
}

.wa-quick-btn i {
    font-size: 16px;
}

/* ===== MODO EDIÇÃO DA TOOLBAR ===== */
/* Botão "Concluir" (check verde) — só aparece durante edit mode, no topo da toolbar */
.wa-quick-done-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 6px;
    border: none;
    border-radius: 4px;
    background: rgba(37, 211, 102, 0.25);
    color: #25D366;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
    margin-bottom: 4px;
    animation: waEditDonePulse 1.2s ease-in-out infinite;
}
.wa-quick-done-btn:hover {
    background: rgba(37, 211, 102, 0.4);
    transform: scale(1.08);
}
.wa-quick-done-btn i { font-size: 15px; }

@keyframes waEditDonePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5); }
    50%      { box-shadow: 0 0 0 6px rgba(37, 211, 102, 0); }
}

/* Botões em modo edição: wiggle sutil estilo iOS + cursor grab */
.wa-quick-toolbar.wa-quick-edit-mode .wa-quick-btn {
    cursor: grab;
    animation: waEditWiggle 0.6s ease-in-out infinite;
    transform-origin: center;
}
.wa-quick-toolbar.wa-quick-edit-mode .wa-quick-btn:nth-child(odd) {
    animation-delay: -0.3s; /* dessincroniza pra parecer "mais natural" */
}
.wa-quick-toolbar.wa-quick-edit-mode .wa-quick-btn:active,
.wa-quick-toolbar.wa-quick-edit-mode .wa-quick-btn.wa-quick-dragging {
    cursor: grabbing;
    animation: none; /* pára o wiggle durante o drag */
}

@keyframes waEditWiggle {
    0%, 100% { transform: rotate(-1.5deg); }
    50%      { transform: rotate(1.5deg); }
}

/* Durante drag: fica no topo com sombra grande */
.wa-quick-dragging {
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    opacity: 0.92;
    border-radius: 6px !important;
    background: rgba(37, 211, 102, 0.2) !important;
    color: #25D366 !important;
    transform: scale(1.08) !important;
}

/* Placeholder (espaço reservado pro item enquanto ele é arrastado) */
.wa-quick-placeholder {
    background: rgba(37, 211, 102, 0.08) !important;
    border: 1.5px dashed rgba(37, 211, 102, 0.5) !important;
    border-radius: 4px !important;
    animation: none !important;
    pointer-events: none;
    box-sizing: border-box;
}
.wa-quick-placeholder > * { visibility: hidden; }

/* Wiggle dentro do submenu em edit mode */
.wa-quick-submenu.wa-quick-submenu-edit .wa-quick-submenu-item {
    cursor: grab;
    animation: waEditWiggle 0.6s ease-in-out infinite;
}
.wa-quick-submenu.wa-quick-submenu-edit .wa-quick-submenu-item:nth-child(odd) {
    animation-delay: -0.3s;
}
.wa-quick-submenu.wa-quick-submenu-edit .wa-quick-submenu-item.wa-quick-dragging {
    cursor: grabbing;
    animation: none;
}

/* Tooltip flutuante (via JS) para botões da toolbar */
.wa-quick-tooltip {
    position: fixed;
    background: #222;
    color: #fff;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 5px;
    white-space: nowrap;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.wa-quick-tooltip.show {
    opacity: 1;
}

/* Setinha do tooltip */
.wa-quick-tooltip::after {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #222;
}

/* ===== SUBMENU POPUP ===== */
.wa-quick-submenu {
    position: fixed;
    background: var(--background-color, #222b35);
    border: 1px solid var(--table-border-color);
    border-radius: 8px;
    padding: 8px;
    min-width: 180px;
    max-width: 300px;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    z-index: 6000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: waSubmenuFadeIn 0.15s ease-out;
    width: max-content;
}

@keyframes waSubmenuFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wa-quick-submenu-title {
    color: var(--text-color);
    text-align: center;
    font-size: 13px;
    font-weight: bold;
    padding: 4px 8px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--table-border-color);
}

.wa-quick-submenu-empty {
    color: #8696a0;
    padding: 12px;
    text-align: center;
    font-size: 13px;
}

.wa-quick-submenu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin: 3px 0;
    background: #005C4B;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s;
}

.wa-quick-submenu-item:hover {
    background: #007A63;
}

.wa-quick-submenu::-webkit-scrollbar {
    width: 5px;
}

.wa-quick-submenu::-webkit-scrollbar-thumb {
    background: rgba(128,128,128,0.3);
    border-radius: 3px;
}

/* ===== MODAL DE CONFIGURAÇÃO DOS BOTÕES RÁPIDOS ===== */
.qb-settings-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9000;
    align-items: center;
    justify-content: center;
}

.qb-settings-modal.show {
    display: flex;
}

.qb-settings-content {
    background: var(--background-color, #222b35);
    border: 1px solid var(--table-border-color);
    border-radius: 10px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.qb-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--table-border-color);
}

.qb-settings-header h2 {
    margin: 0;
    font-size: 16px;
    color: var(--text-color);
}

.qb-settings-header h2 i {
    margin-right: 8px;
    color: #25D366;
}

.qb-settings-close {
    background: none;
    border: none;
    color: #8696a0;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.qb-settings-close:hover {
    background: rgba(128,128,128,0.12);
}

.qb-settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}

.qb-settings-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--table-border-color);
    text-align: right;
}

/* Tabs */
.qb-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--table-border-color);
    padding-bottom: 8px;
}

.qb-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #8696a0;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

.qb-tab:hover {
    background: rgba(128,128,128,0.08);
}

.qb-tab.active {
    background: rgba(37, 211, 102, 0.15);
    color: #25D366;
    font-weight: 600;
}

.qb-tab i { margin-right: 5px; }

.qb-tab-panel {
    display: none;
}

.qb-tab-panel.active {
    display: block;
}

/* Actions bar */
.qb-section-actions {
    margin-bottom: 12px;
}

.qb-add-btn {
    padding: 8px 16px;
    background: #25D366;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.qb-add-btn:hover {
    background: #1da851;
}

.qb-add-btn i { margin-right: 5px; }

.qb-save-btn {
    padding: 10px 24px;
    background: #25D366;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s;
}

.qb-save-btn:hover {
    background: #1da851;
}

.qb-save-btn i { margin-right: 6px; }

/* "Editar Posições" — fecha a modal e libera drag & drop dos botões na toolbar */
.qb-edit-positions-btn {
    padding: 10px 18px;
    background: transparent;
    color: var(--text-color, #e9edef);
    border: 1px solid var(--table-border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    margin-right: 8px;
    transition: background 0.15s, border-color 0.15s;
}
.qb-edit-positions-btn:hover {
    background: rgba(37, 211, 102, 0.12);
    border-color: #25D366;
    color: #25D366;
}
.qb-edit-positions-btn i { margin-right: 6px; }

/* Items list */
.qb-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.qb-item-card {
    background: var(--content-bg-color);
    border: 1px solid var(--table-border-color);
    border-radius: 8px;
    padding: 12px;
}

.qb-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.qb-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
}

.qb-item-actions {
    display: flex;
    gap: 6px;
}

.qb-item-actions button {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.qb-item-actions button:hover {
    background: rgba(128,128,128,0.12);
}

.qb-item-actions .qb-btn-delete:hover {
    color: #e74c3c;
}

/* Form groups */
.qb-form-group {
    margin-bottom: 10px;
}

.qb-form-group label {
    display: block;
    font-size: 12px;
    color: #8696a0;
    margin-bottom: 4px;
    font-weight: 600;
}

.qb-input,
.qb-textarea,
.qb-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--table-border-color);
    border-radius: 5px;
    background: var(--background-color, #222b35);
    color: var(--text-color);
    font-size: 13px;
    box-sizing: border-box;
}

.qb-textarea {
    resize: vertical;
    min-height: 60px;
}

.qb-select {
    cursor: pointer;
}

.qb-form-row {
    display: flex;
    gap: 8px;
}

.qb-form-row .qb-form-group {
    flex: 1;
}

/* Placeholder info */
.qb-placeholder-info {
    margin-top: 12px;
    padding: 8px 10px;
    background: rgba(37, 211, 102, 0.08);
    border-radius: 6px;
    color: #8696a0;
    font-size: 11px;
    line-height: 1.5;
}

/* Submenu buttons within card */
.qb-sub-buttons-list {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
}

.qb-sub-btn-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: var(--content-bg-color);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-color);
}

.qb-sub-btn-item:last-child {
    margin-bottom: 0;
}

.qb-sub-btn-item .qb-sub-btn-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qb-sub-btn-item button {
    background: none;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
}

.qb-sub-btn-item button:hover {
    color: #e74c3c;
}

.qb-add-sub-btn {
    margin-top: 6px;
    padding: 5px 10px;
    background: rgba(37, 211, 102, 0.2);
    color: #25D366;
    border: 1px dashed rgba(37, 211, 102, 0.4);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    width: 100%;
}

.qb-add-sub-btn:hover {
    background: rgba(37, 211, 102, 0.3);
}

/* Image preview */
.qb-image-preview {
    max-width: 80px;
    max-height: 60px;
    border-radius: 4px;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .qb-settings-content {
        width: 95%;
        max-height: 90vh;
    }
    .qb-form-row {
        flex-direction: column;
    }
}

/* ===== ÁREA DE MENSAGENS ===== */
.wa-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 15px 40px;
    display: flex;
    flex-direction: column;
}

.wa-messages-wrapper {
    display: flex;
    flex-direction: column;
    margin-top: auto;
}

/* Separador de data */
.wa-date-separator {
    text-align: center;
    margin: 12px 0;
}

.wa-date-separator span {
    background: rgba(128, 128, 128, 0.15);
    padding: 5px 14px;
    border-radius: 8px;
    font-size: 11.5px;
    color: #8696a0;
    font-weight: 500;
}

/* Bolha de mensagem */
.wa-message {
    max-width: 60%;
    margin-bottom: 3px;
    display: flex;
    flex-direction: column;
}

.wa-message.sent {
    align-self: flex-end;
}

.wa-message.received {
    align-self: flex-start;
}

.wa-message-bubble {
    padding: 6px 10px 4px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

.wa-message.sent .wa-message-bubble {
    background: #d9fdd3;
    color: #111b21;
    border-top-right-radius: 0;
}

.wa-message.received .wa-message-bubble {
    background: var(--content-bg-color);
    color: var(--text-color);
    border-top-left-radius: 0;
    border: 1px solid var(--table-border-color);
}

/* Tema escuro */
[data-theme="dark"] .wa-message.sent .wa-message-bubble {
    background: #005c4b;
    color: #e9edef;
}

/* Texto da mensagem */
.wa-message-text {
    white-space: pre-wrap;
}

.wa-message-text a {
    color: #039be5;
    text-decoration: underline;
}

/* Mensagem apagada */
.wa-message-deleted {
    font-style: italic;
    color: var(--text-muted, #8696a0);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    opacity: 0.8;
}
.wa-message-deleted i {
    font-size: 14px;
}

/* Reação (emoji inline) */
.wa-message-reaction {
    font-size: 2em;
    line-height: 1.3;
    text-align: center;
    min-width: 40px;
}

/* Menu de ações da mensagem (editar/apagar) */
.wa-message {
    position: relative;
}
.wa-msg-actions {
    position: absolute;
    top: 2px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 5;
}
.wa-message.sent .wa-msg-actions {
    left: -86px;
}
.wa-message.received .wa-msg-actions {
    right: -32px;
}
.wa-message:hover .wa-msg-actions {
    opacity: 1;
}
.wa-msg-action-btn {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: var(--card-bg-color, #2a2f3a);
    color: var(--text-muted, #8696a0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.wa-msg-action-btn:hover {
    transform: scale(1.15);
}
.wa-msg-action-btn[data-action="edit-msg"]:hover {
    background: #3498db;
    color: #fff;
}
.wa-msg-action-btn[data-action="delete-msg"]:hover {
    background: #e74c3c;
    color: #fff;
}
.wa-msg-action-btn[data-action="reply-msg"]:hover {
    background: #25D366;
    color: #fff;
}

/* Botão ⋮ mobile-only — inline dentro do .wa-message-footer, ao lado do timestamp */
.wa-msg-menu-btn {
    display: none; /* hidden por padrão (desktop); ativado só em <500px */
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    padding: 0;
    margin-left: 2px;
    -webkit-tap-highlight-color: transparent;
}
.wa-msg-menu-btn:active { opacity: 1; background: rgba(0, 0, 0, 0.15); }
/* Destaque pro item "Apagar" no popover reusando .wa-ctx-menu */
.wa-ctx-item[data-action="delete-msg"] i { color: #e74c3c; opacity: 0.85; }

/* Quoted message dentro da bolha */
.wa-quoted-msg {
    padding: 6px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.15);
    border-left: 3px solid #25D366;
    cursor: pointer;
    transition: background 0.15s;
    max-width: 100%;
    overflow: hidden;
}
.wa-quoted-msg:hover {
    background: rgba(0, 0, 0, 0.25);
}
.wa-quoted-self {
    border-left-color: #53bdeb;
}
.wa-quoted-other {
    border-left-color: #25D366;
}
.wa-quoted-sender {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    margin-bottom: 2px;
}
.wa-quoted-self .wa-quoted-sender { color: #53bdeb; }
.wa-quoted-other .wa-quoted-sender { color: #25D366; }
.wa-quoted-text {
    display: block;
    font-size: 12px;
    color: var(--text-muted, #8696a0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Highlight ao clicar no quote */
.wa-message.wa-highlight .wa-message-bubble {
    animation: wa-highlightPulse 2s ease;
}
@keyframes wa-highlightPulse {
    0%, 100% { box-shadow: none; }
    20%, 60% { box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.5); }
}

/* Reply preview acima do input */
#wa-reply-bar {
    display: none;
}
.wa-reply-preview {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--card-bg-color, #1f2c33);
    border-left: 3px solid #25D366;
    border-radius: 8px 8px 0 0;
    margin: 0 8px;
}
.wa-reply-self {
    border-left-color: #53bdeb;
}
.wa-reply-other {
    border-left-color: #25D366;
}
.wa-reply-preview-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.wa-reply-preview-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
}
.wa-reply-self .wa-reply-preview-name { color: #53bdeb; }
.wa-reply-other .wa-reply-preview-name { color: #25D366; }
.wa-reply-preview-text {
    display: block;
    font-size: 12px;
    color: var(--text-muted, #8696a0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wa-reply-cancel {
    background: none;
    border: none;
    color: var(--text-muted, #8696a0);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    transition: color 0.15s;
    flex-shrink: 0;
}
.wa-reply-cancel:hover { color: #e74c3c; }

/* Edição inline da mensagem */
.wa-edit-textarea {
    width: 100%;
    min-height: 36px;
    max-height: 200px;
    padding: 6px 8px;
    border: 1px solid var(--primary-color, #3498db);
    border-radius: 6px;
    background: var(--body-bg-color, #111b21);
    color: var(--text-color, #e9edef);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    resize: none;
    outline: none;
    box-sizing: border-box;
}
.wa-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}
.wa-edit-save, .wa-edit-cancel {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.15s;
}
.wa-edit-save {
    background: #25D366;
    color: #fff;
}
.wa-edit-save:hover { background: #1da851; transform: scale(1.1); }
.wa-edit-cancel {
    background: var(--card-bg-color, #2a2f3a);
    color: var(--text-muted, #8696a0);
}
.wa-edit-cancel:hover { background: #e74c3c; color: #fff; transform: scale(1.1); }

/* Modal de confirmação para apagar */
.wa-delete-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: wa-fadeIn 0.15s ease;
}
@keyframes wa-fadeIn { from { opacity: 0; } to { opacity: 1; } }
.wa-delete-modal {
    background: var(--card-bg-color, #233138);
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: wa-slideUp 0.2s ease;
}
@keyframes wa-slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.wa-delete-modal-text {
    font-size: 15px;
    color: var(--text-color, #e9edef);
    margin-bottom: 20px;
    text-align: center;
}
.wa-delete-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.wa-delete-modal-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}
.wa-delete-cancel-btn {
    background: var(--body-bg-color, #111b21);
    color: var(--text-muted, #8696a0);
}
.wa-delete-cancel-btn:hover { background: var(--table-border-color, #3a454d); color: var(--text-color, #e9edef); }
.wa-delete-confirm-btn {
    background: #e74c3c;
    color: #fff;
}
.wa-delete-confirm-btn:hover { background: #c0392b; }

/* Timestamp */
.wa-message-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.wa-message-time {
    font-size: 10.5px;
    color: rgba(128, 128, 128, 0.7);
}

.wa-message.sent .wa-message-time {
    color: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .wa-message.sent .wa-message-time {
    color: rgba(255, 255, 255, 0.5);
}

/* ===== MÍDIA NAS MENSAGENS ===== */

/* Imagem */
.wa-msg-media-img {
    max-width: 300px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 4px;
    cursor: pointer;
    position: relative;
}

.wa-msg-media-img img {
    width: 100%;
    display: block;
    border-radius: 4px;
}

/* Bolha com mídia — limita largura pelo conteúdo da imagem */
.wa-message-bubble:has(.wa-msg-media-img) {
    max-width: 320px;
}
.wa-message-bubble:has(.wa-msg-media-video) {
    max-width: 360px;
}
.wa-message-bubble:has(.wa-media-placeholder) {
    max-width: 320px;
}

/* Botão OCR nas imagens */
.wa-ocr-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, transform 0.2s;
    z-index: 5;
    backdrop-filter: blur(4px);
}
.wa-msg-media-img:hover .wa-ocr-btn { opacity: 1; }
.wa-ocr-btn:hover { background: rgba(52, 152, 219, 0.85); transform: scale(1.1); }
.wa-ocr-btn.wa-ocr-loading { opacity: 1; background: rgba(52, 152, 219, 0.85); pointer-events: none; }

/* Botão OCR no overlay de mídia */
.wa-overlay-ocr-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, transform 0.2s;
    backdrop-filter: blur(4px);
    z-index: 10;
}
.wa-overlay-ocr-btn:hover { background: rgba(52, 152, 219, 0.85); transform: scale(1.05); border-color: rgba(52, 152, 219, 0.5); }
.wa-overlay-ocr-btn.wa-ocr-loading { pointer-events: none; background: rgba(52, 152, 219, 0.85); }

/* Vídeo */
.wa-msg-media-video {
    max-width: 300px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 4px;
    cursor: pointer;
    position: relative;
}

.wa-msg-media-video video {
    width: 100%;
    display: block;
    border-radius: 4px;
}

.wa-msg-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    pointer-events: none;
}

/* Áudio */
/* Audio player estilo WhatsApp */
.wa-msg-audio-wrap {
    min-width: 280px;
    max-width: 360px;
}

.wa-msg-audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(128, 128, 128, 0.08);
}

.wa-msg-audio-player.wa-audio-loading {
    opacity: 0.8;
}

.wa-msg-audio-player.wa-audio-unavailable {
    opacity: 0.4;
}

.wa-audio-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #25D366;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.wa-audio-play-btn:hover {
    background: #1da851;
}

.wa-audio-play-btn:disabled {
    background: #555;
    cursor: default;
}

.wa-audio-loading .wa-audio-play-btn {
    background: rgba(128,128,128,0.2);
}

.wa-audio-wave {
    flex: 1;
    height: 6px;
    background: rgba(128,128,128,0.25);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.wa-audio-progress {
    height: 100%;
    width: 0%;
    background: #25D366;
    border-radius: 3px;
    transition: width 0.1s linear;
}

.wa-audio-time {
    font-size: 11px;
    color: #8696a0;
    min-width: 32px;
    text-align: right;
    flex-shrink: 0;
}

.wa-audio-transcribe-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(128,128,128,0.12);
    color: #8696a0;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.wa-audio-transcribe-btn:hover {
    background: rgba(37, 211, 102, 0.2);
    color: #25D366;
}

.wa-audio-transcription {
    display: none;
    padding: 8px 12px;
    margin-top: 6px;
    background: rgba(0, 92, 75, 0.15);
    border-left: 3px solid #005C4B;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-color);
    word-wrap: break-word;
}

.wa-audio-transcription.show {
    display: block;
}

.wa-audio-transcription strong {
    color: #25D366;
    font-size: 11px;
    display: block;
    margin-bottom: 4px;
}

/* Legacy fallback */
.wa-msg-audio {
    min-width: 260px;
    padding: 4px 0;
}

.wa-msg-audio audio {
    width: 100%;
    height: 36px;
    border-radius: 18px;
}

/* Documento */
/* Document card */
.wa-msg-document-card {
    border-radius: 8px;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.08);
    min-width: 220px;
    max-width: 320px;
    margin-bottom: 4px;
}

/* PDF embutido em miniatura */
.wa-msg-pdf-embed {
    position: relative;
    width: 100%;
    height: 260px;
    background: #fff;
}

.wa-msg-pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.wa-msg-doc-bar-action:hover {
    background: rgba(37, 211, 102, 0.1);
}

.wa-msg-doc-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}

.wa-msg-doc-bar > i:first-child {
    font-size: 28px;
    color: #8696a0;
    flex-shrink: 0;
}

.wa-msg-doc-info {
    flex: 1;
    min-width: 0;
}

.wa-msg-doc-name {
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-msg-doc-meta {
    font-size: 11px;
    color: #8696a0;
    margin-top: 2px;
}

/* Fallback sem thumbnail (layout antigo) */
.wa-msg-document {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(128, 128, 128, 0.08);
    border-radius: 6px;
    cursor: pointer;
    min-width: 200px;
    margin-bottom: 4px;
}

.wa-msg-document i {
    font-size: 28px;
    color: #8696a0;
    flex-shrink: 0;
}

/* Placeholder de mídia (carregando) */
.wa-media-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
    min-height: 100px;
    background: rgba(128, 128, 128, 0.08);
    border-radius: 6px;
    cursor: pointer;
    color: #8696a0;
    font-size: 12px;
    padding: 15px;
}

.wa-media-placeholder i {
    font-size: 24px;
    opacity: 0.5;
}

.wa-media-placeholder:hover {
    background: rgba(128, 128, 128, 0.15);
}

/* Sticker */
.wa-msg-sticker {
    max-width: 150px;
}

.wa-msg-sticker img {
    width: 100%;
    display: block;
}

/* ===== ÁREA DE INPUT ===== */
.wa-chat-input-area {
    padding: 8px 15px;
    background: var(--content-bg-color);
    border-top: 1px solid var(--table-border-color);
    flex-shrink: 0;
    position: relative;
}

.wa-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.wa-chat-input-btn {
    background: none;
    border: none;
    color: #8696a0;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wa-chat-input-btn:hover {
    background: rgba(128, 128, 128, 0.12);
    color: var(--text-color);
}

.wa-chat-input-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: var(--background-color);
    border-radius: 20px;
    border: 1px solid var(--table-border-color);
    padding: 4px 14px;
    min-width: 0;
}

.wa-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 13.5px;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    padding: 6px 0;
    outline: none;
    font-family: inherit;
    min-width: 0;
}

.wa-chat-input::placeholder { color: #8696a0; }

.wa-chat-send-btn {
    background: #25D366;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.wa-chat-send-btn:hover { background: #1da851; }

/* ===== MENU DE ANEXO ===== */
.wa-attach-menu {
    position: absolute;
    bottom: 60px;
    left: 12px;
    background: var(--content-bg-color);
    border: 1px solid var(--table-border-color);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    padding: 8px 0;
    display: none;
    z-index: 100;
}

.wa-attach-menu.show { display: block; }

.wa-attach-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-color);
    font-size: 13.5px;
    white-space: nowrap;
}

.wa-attach-menu-item:hover { background: rgba(128, 128, 128, 0.1); }

.wa-attach-menu-item i {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.wa-attach-icon-image    { background: #7f66ff; }
.wa-attach-icon-video    { background: #ee5381; }
.wa-attach-icon-document { background: #5157ae; }
.wa-attach-icon-audio    { background: #0795dc; }
.wa-attach-icon-sticker  { background: #f39c12; }

/* ===== PANEL DE FIGURINHAS ===== */
.wa-sticker-panel {
    position: absolute;
    bottom: 60px;
    left: 10px;
    right: 10px;
    max-height: 320px;
    background: var(--content-bg-color, #fff);
    border: 1px solid var(--table-border-color, #ddd);
    border-radius: 10px;
    box-shadow: 0 4px 20px var(--box-shadow-color, rgba(0,0,0,0.2));
    z-index: 20;
    display: flex;
    flex-direction: column;
}
.wa-sticker-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--table-border-color, #ddd);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color, #2c3e50);
}
.wa-sticker-panel-close {
    background: transparent;
    border: none;
    color: var(--text-muted, #8696a0);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
}
.wa-sticker-grid {
    overflow-y: auto;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}
.wa-sticker-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(128,128,128,0.08);
    transition: transform 0.1s, background 0.1s;
}
.wa-sticker-item:hover {
    transform: scale(1.05);
    background: rgba(128,128,128,0.15);
}
.wa-sticker-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.wa-sticker-item-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    cursor: pointer;
    opacity: 0;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}
.wa-sticker-item:hover .wa-sticker-item-delete { opacity: 1; }
.wa-sticker-panel-empty {
    text-align: center;
    padding: 30px 16px;
    color: var(--text-muted, #8696a0);
    font-size: 13px;
    grid-column: 1 / -1;
}

/* ===== PREVIEW DE ENVIO ===== */
.wa-send-preview {
    display: none;
    padding: 10px 15px;
    border-top: 1px solid var(--table-border-color);
    background: var(--content-bg-color);
}

.wa-send-preview.show { display: block; }

.wa-send-preview-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wa-send-preview-thumb {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-send-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wa-send-preview-thumb i {
    font-size: 26px;
    color: #8696a0;
}

.wa-send-preview-info {
    flex: 1;
    min-width: 0;
}

.wa-send-preview-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-send-preview-size {
    font-size: 11.5px;
    color: #8696a0;
    margin-top: 2px;
}

.wa-send-preview-cancel {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.15s;
}

.wa-send-preview-cancel:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* ===== GRAVAÇÃO DE ÁUDIO ===== */
.wa-recording {
    display: none;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.wa-recording.active { display: flex; }

.wa-recording-dot {
    width: 10px;
    height: 10px;
    background: #e74c3c;
    border-radius: 50%;
    animation: wa-blink 1s infinite;
    flex-shrink: 0;
}

@keyframes wa-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

.wa-recording-time {
    font-size: 14px;
    color: var(--text-color);
    font-family: monospace;
    flex-shrink: 0;
}

.wa-recording-cancel {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 16px;
    transition: background 0.15s;
    margin-left: auto;
}

.wa-recording-cancel:hover { background: rgba(231, 76, 60, 0.1); }

/* ===== OVERLAY DE MÍDIA (visualizar imagem/vídeo ampliado) ===== */
.wa-media-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.wa-media-overlay.show { display: flex; }

.wa-media-overlay-close {
    position: absolute;
    top: 18px;
    right: 22px;
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    z-index: 10;
    padding: 8px;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.wa-media-overlay-close:hover { opacity: 1; }

.wa-media-overlay-content {
    max-width: 85%;
    max-height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.wa-media-overlay-content img,
.wa-media-overlay-content video {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 6px;
    object-fit: contain;
}

/* ===== LOADING ===== */
.wa-loading {
    text-align: center;
    padding: 30px;
    color: #8696a0;
    font-size: 13px;
}

.wa-loading i { margin-right: 6px; }

.wa-chat-list-empty {
    text-align: center;
    padding: 40px 20px;
    color: #8696a0;
    font-size: 13px;
}

/* ===== BOTÃO VOLTAR (mobile) ===== */
.wa-chat-back-btn {
    display: none;
}

/* ===== SCROLLBAR ===== */
.wa-chat-list::-webkit-scrollbar,
.wa-messages-area::-webkit-scrollbar {
    width: 5px;
}

.wa-chat-list::-webkit-scrollbar-track,
.wa-messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.wa-chat-list::-webkit-scrollbar-thumb,
.wa-messages-area::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.25);
    border-radius: 3px;
}

.wa-chat-list::-webkit-scrollbar-thumb:hover,
.wa-messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.4);
}

/* ===== FORMATAÇÃO DE TEXTO (negrito, itálico, etc.) ===== */
.wa-message-text b { font-weight: 700; }
.wa-message-text i { font-style: italic; }
.wa-message-text s { text-decoration: line-through; }
.wa-message-text code {
    background: rgba(128, 128, 128, 0.12);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 12.5px;
}

/* ===== NOVO CHAT - MODAL SIMPLES ===== */
.wa-new-chat-bar {
    display: none;
    padding: 10px 15px;
    background: var(--background-color);
    border-bottom: 1px solid var(--table-border-color);
    gap: 8px;
    align-items: center;
}

.wa-new-chat-bar.show { display: flex; }

.wa-new-chat-input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid var(--table-border-color);
    border-radius: 20px;
    background: var(--content-bg-color);
    color: var(--text-color);
    font-size: 13px;
    outline: none;
}

.wa-new-chat-input::placeholder { color: #8696a0; }

.wa-new-chat-go {
    background: #25D366;
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.wa-new-chat-go:hover { background: #1da851; }

/* ===== RESPONSIVO - MOBILE ===== */
@media (max-width: 768px) {
    .wa-chat-container {
        height: calc(100vh - 60px);
        position: relative;
    }

    .wa-chat-sidebar {
        width: 100%;
        min-width: 100%;
    }

    .wa-chat-main {
        display: none;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 5;
        background: var(--background-color);
    }

    /* Quando chat aberto: cobre tudo incluindo o header da página */
    .wa-chat-container.chat-open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        z-index: 1000;
        border-radius: 0;
        border: none;
    }

    .wa-chat-container.chat-open .wa-chat-sidebar {
        display: none;
    }

    .wa-chat-container.chat-open .wa-quick-toolbar {
        display: flex !important;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 40px;
        flex-direction: column;
        justify-content: flex-end;
        border-left: none;
        border-right: 1px solid var(--table-border-color);
        padding: 6px 2px;
        z-index: 1001;
    }

    .wa-chat-container.chat-open .wa-quick-btn {
        width: 34px;
        height: 34px;
    }

    .wa-chat-container.chat-open .wa-chat-main {
        display: flex;
        left: 40px;
        right: 0;
        width: auto;
    }

    .wa-chat-back-btn {
        display: flex !important;
    }

    .wa-message {
        max-width: 85%;
    }

    .wa-messages-area {
        padding: 10px 12px;
    }

    .wa-msg-media-img,
    .wa-msg-media-video {
        max-width: 240px;
    }

    .wa-msg-audio {
        min-width: 200px;
    }

    .wa-media-placeholder {
        min-width: 160px;
        min-height: 80px;
    }

    .wa-msg-document-card {
        min-width: 160px;
        max-width: 260px;
    }

    .wa-msg-doc-thumb {
        max-height: 140px;
    }

    .wa-chat-input-area {
        padding: 6px 10px;
    }

    /* OCR button sempre visível em mobile (sem hover) */
    .wa-ocr-btn { opacity: 0.7; }

    /* Ações de mensagem sempre visíveis em mobile */
    .wa-msg-actions { opacity: 0.6; }
    .wa-message.sent .wa-msg-actions { left: -78px; }
    .wa-message.received .wa-msg-actions { right: -30px; }
}

@media (max-width: 500px) {
    /* Em mobile, header-info vira row pro ícone de copiar ficar AO LADO do nome,
     * não embaixo. Nome ocupa o espaço (flex:1 + min-width:0 mantém ellipsis funcional),
     * o ícone fica fixo na direita sem encolher. */
    .wa-chat-header-info {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    .wa-chat-header-name {
        flex: 1;
        min-width: 0;
    }
    /* Esconde só o número formatado (poupa espaço), mantém o ícone */
    .wa-chat-header-phone .wa-phone-number { display: none; }
    .wa-chat-header-phone { flex-shrink: 0; }
    /* Aumenta touch target do ícone em mobile (sem hover, precisa ser fácil de tocar) */
    .wa-copy-phone {
        font-size: 14px;
        padding: 6px;
        opacity: 0.7;
    }
    /* Swap: em telas muito estreitas, trinca de botões fora vira um único ⋮ inline no footer */
    .wa-msg-actions { display: none !important; }
    .wa-msg-menu-btn { display: inline-flex; }
}
/* Guard rígido pra desktop — se algum CSS herdado tentar mostrar, força hide */
@media (min-width: 501px) {
    .wa-msg-menu-btn { display: none !important; }
}

/* =========================================================================
   BANNER DE STATUS DE CONEXÃO WHATSAPP
   Mostrado entre o header e a área de chat quando o state retornado pela
   Evolution API é diferente de 'open'. Sticky abaixo do header pra não
   esconder a barra de chats. Mesma paleta do badge antigo em #wa-status-badge.
   ========================================================================= */
.wa-connection-banner {
    padding: 10px 16px;
    font-size: 13.5px;
    line-height: 1.4;
    border-bottom: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}
.wa-connection-banner i {
    flex-shrink: 0;
    font-size: 14px;
}
.wa-connection-banner--warning {
    background: #fff3cd;
    color: #856404;
    border-bottom-color: #ffeeba;
}
.wa-connection-banner--error {
    background: #f8d7da;
    color: #721c24;
    border-bottom-color: #f5c6cb;
    cursor: pointer;
    transition: background 0.15s;
}
.wa-connection-banner--error:hover {
    background: #f5c2c7;
}
.wa-connection-banner--error .wa-connection-action {
    text-decoration: underline;
    margin-left: 4px;
    font-weight: 500;
}
.wa-connection-banner--fatal {
    background: #e2e3e5;
    color: #383d41;
    border-bottom-color: #d6d8db;
}
@media (max-width: 500px) {
    .wa-connection-banner { font-size: 12.5px; padding: 8px 12px; }
}
