/* ==========================================================================
   POPUP FLUTUANTE ARRASTÁVEL DO WHATSAPP (EMULADO TAMANHO SMARTPHONE)
   Estilo Neo-Brutalista Integrado ao SAAS-WEB HUD
   Com Tela Primária Fixa: LISTA DE CONVERSAS (Estilo WhatsApp Mobile Oficial)
   ========================================================================== */

:root {
    --wa-ink: #181716;
    --wa-primary: #25d366;
    --wa-dark-green: #075e54;
    --wa-teal: #128c7e;
    --wa-bubble-out: #dcf8c6;
    --wa-bubble-in: #ffffff;
    --wa-badge-gold: #ffb703;
    --wa-accent-orange: #ff7417;
}

/* SMARTPHONE FLUTUANTE */
.wa-float-popup {
    position: fixed;
    z-index: 10001;
    width: 385px;
    height: 565px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border: 3.5px solid var(--wa-ink);
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.45);
    overflow: visible;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    user-select: none;
    transition: box-shadow 0.2s ease, opacity 0.2s ease;
}

.wa-float-popup.dragging {
    box-shadow: 16px 16px 0 rgba(0, 0, 0, 0.55);
    opacity: 0.95;
    cursor: grabbing !important;
}

/* TELAS INTERNAS DO SMARTPHONE (CONVERSAS VS CHAT) */
.wa-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 20px;
    background: #ffffff;
}

/* CABEÇALHOS DO SMARTPHONE */
.wa-pop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--wa-dark-green);
    color: #fff;
    border-bottom: 3px solid var(--wa-ink);
    border-radius: 20px 20px 0 0;
    cursor: grab;
    flex-shrink: 0;
}

.wa-float-popup.dragging .wa-pop-header {
    cursor: grabbing;
}

.wa-pop-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.wa-pop-back-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--wa-ink);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.wa-pop-back-btn:hover {
    background: #ffffff;
    color: var(--wa-ink);
    transform: scale(1.08);
}

.wa-pop-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--wa-primary);
    color: #fff;
    font: 900 0.85rem sans-serif;
    box-shadow: 1.5px 1.5px 0 var(--wa-ink);
    flex-shrink: 0;
}

.wa-pop-meta {
    min-width: 0;
}

.wa-pop-title-main {
    font: 900 1.05rem/1 'Outfit', sans-serif;
    color: #ffffff;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.wa-pop-name {
    font: 800 0.92rem/1.1 'Outfit', sans-serif;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.wa-pop-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.62rem;
    font-weight: 700;
    color: #dcf8c6;
    margin-top: 2px;
}

.wa-pop-status i {
    font-size: 0.45rem;
    color: var(--wa-primary);
}

.wa-pop-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.wa-pop-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--wa-ink);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.wa-pop-btn:hover {
    background: #ffffff;
    color: var(--wa-ink);
    transform: scale(1.08);
}

/* ==========================================================================
   TELA 1: LISTA DE CONVERSAS (INICIAL FIXO E PRIMÁRIO)
   ========================================================================== */
.wa-chats-search-bar {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    background: #f0f2f5;
    border-bottom: 2.5px solid var(--wa-ink);
    flex-shrink: 0;
}

.wa-chats-search-bar i {
    color: #78716c;
    font-size: 0.85rem;
}

.wa-chats-search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font: 700 0.82rem 'Outfit', sans-serif;
    color: #181716;
    outline: none;
}

.wa-chats-search-bar input::placeholder {
    color: #94a3b8;
    font-weight: 600;
}

.wa-chats-quick-filter {
    display: flex;
    gap: 6px;
    padding: 6px 12px;
    background: #f8fafc;
    border-bottom: 1.5px solid #e2e8f0;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

.wa-chats-quick-filter::-webkit-scrollbar {
    display: none;
}

.wa-filter-pill {
    padding: 3px 9px;
    border: 1px solid var(--wa-ink);
    border-radius: 999px;
    background: #ffffff;
    color: #181716;
    font: 800 0.62rem 'Outfit', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s;
}

.wa-filter-pill:hover,
.wa-filter-pill.active {
    background: #e7fce9;
    border-color: var(--wa-primary);
    color: #0b4d26;
}

.wa-chats-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 0 0 20px 20px;
    scrollbar-width: thin;
}

.wa-chats-list::-webkit-scrollbar {
    width: 5px;
}
.wa-chats-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.wa-chats-empty {
    padding: 36px 20px;
    text-align: center;
    font: 700 0.82rem 'Outfit', sans-serif;
    color: #64748b;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.wa-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1.5px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.08s ease;
}

.wa-chat-item:hover {
    background: #f8fafc;
}

.wa-chat-item:active {
    background: #e7fce9;
}

.wa-chat-item.active {
    background: #e7fce9;
    border-left: 4.5px solid var(--wa-primary);
}

.wa-chat-avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1.5px solid var(--wa-ink);
    border-radius: 50%;
    background: var(--wa-primary);
    color: #fff;
    font: 900 0.82rem sans-serif;
    flex-shrink: 0;
    box-shadow: 1px 1px 0 var(--wa-ink);
}

.wa-chat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.wa-chat-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.wa-chat-name {
    font: 800 0.86rem/1.2 'Outfit', sans-serif;
    color: #181716;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-time {
    font: 700 0.65rem 'Outfit', sans-serif;
    color: #94a3b8;
    flex-shrink: 0;
}

.wa-chat-row-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.wa-chat-sub {
    font: 600 0.72rem 'Outfit', sans-serif;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.wa-chat-badge {
    padding: 1.5px 7px;
    border: 1px solid var(--wa-ink);
    border-radius: 999px;
    background: var(--wa-badge-gold);
    color: var(--wa-ink);
    font: 900 0.55rem 'Outfit', sans-serif;
    flex-shrink: 0;
}

/* ==========================================================================
   TELA 2: CHAT INDIVIDUAL
   ========================================================================== */
.wa-pop-quick-bar {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    background: var(--wa-teal);
    overflow-x: auto;
    border-bottom: 2px solid var(--wa-ink);
    scrollbar-width: thin;
    flex-shrink: 0;
}

.wa-pop-quick-bar::-webkit-scrollbar {
    height: 4px;
}
.wa-pop-quick-bar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 4px;
}

.wa-pop-quick-chip {
    padding: 3px 9px;
    border: 1.5px solid var(--wa-ink);
    border-radius: 999px;
    background: #ffffff;
    color: var(--wa-ink);
    font: 800 0.62rem 'Outfit', sans-serif;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 1.5px 1.5px 0 var(--wa-ink);
    transition: background 0.15s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wa-pop-quick-chip:hover {
    background: #dcf8c6;
    transform: translateY(-1px);
}

/* CONTAINER DE MENSAGENS (DOODLE BACKGROUND) */
.wa-pop-messages {
    flex: 1 1 auto;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #0b141a;
    background-image: url('/img/wa-doodle-dark.svg');
    background-repeat: repeat;
    background-size: 280px 280px;
    scrollbar-width: thin;
}

.wa-pop-messages::-webkit-scrollbar {
    width: 6px;
}
.wa-pop-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
}

/* BALÕES DE MENSAGEM */
.wa-msg-bubble {
    position: relative;
    max-width: 82%;
    padding: 8px 12px;
    border: 2px solid var(--wa-ink);
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
    box-shadow: 2px 2px 0 var(--wa-ink);
    word-break: break-word;
    user-select: text;
}

.wa-msg-bubble.out {
    align-self: flex-end;
    background: var(--wa-bubble-out);
    color: #0b4d26;
    border-bottom-right-radius: 2px;
}

.wa-msg-bubble.in {
    align-self: flex-start;
    background: var(--wa-bubble-in);
    color: #181716;
    border-bottom-left-radius: 2px;
}

.wa-msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 0.55rem;
    font-weight: 800;
    opacity: 0.75;
}

/* RODAPÉ E INPUT DE ENVIO */
.wa-pop-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    background: #f0f2f5;
    border-top: 2.5px solid var(--wa-ink);
    border-radius: 0 0 20px 20px;
    flex-shrink: 0;
}

.wa-pop-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wa-pop-input {
    flex: 1;
    padding: 9px 14px;
    border: 2px solid var(--wa-ink);
    border-radius: 999px;
    font: 600 0.82rem 'Outfit', sans-serif;
    color: #181716;
    background: #ffffff;
    outline: none;
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.1);
}

.wa-pop-input:focus {
    border-color: var(--wa-teal);
}

.wa-pop-send-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 2px solid var(--wa-ink);
    border-radius: 50%;
    background: var(--wa-teal);
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    box-shadow: 2px 2px 0 var(--wa-ink);
    transition: transform 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.wa-pop-send-btn:hover {
    transform: scale(1.08);
    background: var(--wa-dark-green);
}

.wa-pop-send-btn:active {
    transform: scale(0.95);
}

/* ==========================================================================
   BOTÃO FLUTUANTE INFERIOR ESQUERDO
   ========================================================================== */
.wa-floating-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 18px;
    border: 3px solid var(--wa-ink);
    border-radius: 999px;
    background: var(--wa-primary);
    color: #ffffff;
    font: 900 0.82rem 'Outfit', sans-serif;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--wa-ink);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    user-select: none;
}

.wa-floating-fab:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 6px 6px 0 var(--wa-ink);
    background: #20ba59;
}

.wa-floating-fab:active {
    transform: translateY(1px);
    box-shadow: 2px 2px 0 var(--wa-ink);
}

.wa-floating-fab i.fab {
    font-size: 1.25rem;
}

.wa-floating-fab .wa-fab-pulse {
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
    animation: waFabPulse 1.8s infinite;
}

@keyframes waFabPulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.wa-floating-fab.active {
    background: var(--wa-dark-green);
    border-color: var(--wa-ink);
}

/* ==========================================================================
   PAINEL DE FERRAMENTAS ACOPLADO AO LADO DO WHATSAPP (.wa-tools-panel)
   ========================================================================== */
.wa-tools-panel {
    position: absolute;
    left: calc(100% + 12px);
    top: 0;
    width: 320px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 3.5px solid var(--wa-ink);
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.4);
    overflow: hidden;
    z-index: 10002;
    font-family: 'Outfit', sans-serif;
}

/* Auto-docking: se perto da borda direita, abre à esquerda */
.wa-float-popup.dock-left .wa-tools-panel {
    left: auto;
    right: calc(100% + 12px);
}

.wa-tools-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--wa-ink);
    color: #fff;
    border-bottom: 3px solid var(--wa-ink);
}

.wa-tools-header h4 {
    margin: 0;
    font: 900 0.85rem 'Outfit', sans-serif;
    color: var(--wa-badge-gold);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.wa-tools-body {
    flex: 1 1 auto;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fdfbf7;
}

.wa-tool-card {
    padding: 10px 12px;
    border: 2.5px solid var(--wa-ink);
    border-radius: 14px;
    background: #fff;
    box-shadow: 3px 3px 0 var(--wa-ink);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wa-tool-title {
    font: 900 0.72rem 'Outfit', sans-serif;
    color: var(--wa-ink);
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wa-tool-title i {
    color: #3b82f6;
}

.wa-tool-stepper {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.wa-tool-step-btn {
    flex: 1;
    min-width: 60px;
    padding: 5px 8px;
    border: 1.5px solid var(--wa-ink);
    border-radius: 999px;
    background: #fff8f0;
    color: var(--wa-ink);
    font: 900 0.6rem 'Outfit', sans-serif;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

.wa-tool-step-btn:hover {
    background: #e5e5e5;
}

.wa-tool-step-btn.active {
    background: #3b82f6;
    color: #fff;
}

.wa-tool-input {
    width: 100%;
    padding: 7px 10px;
    border: 2px solid var(--wa-ink);
    border-radius: 8px;
    font: 600 0.75rem 'Outfit', sans-serif;
    color: #181716;
    background: #fff;
    outline: none;
    resize: vertical;
}

/* CARD DE DADOS DO CLIENTE / LEAD */
.wa-lead-info-card {
    background: linear-gradient(160deg, #fff 0%, #fffaf2 100%);
    border-color: var(--wa-accent-orange);
    box-shadow: 3px 3px 0 var(--wa-accent-orange);
}

.wa-lead-info-card .wa-tool-title i {
    color: var(--wa-accent-orange);
}

.wa-info-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.wa-info-badge {
    padding: 2.5px 8px;
    border: 1.5px solid var(--wa-ink);
    border-radius: 999px;
    background: #fff8f0;
    color: var(--wa-ink);
    font: 800 0.58rem 'Outfit', sans-serif;
    letter-spacing: 0.3px;
}

.wa-info-grid {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-top: 4px;
    border-top: 1.5px dashed rgba(24, 23, 22, 0.18);
}

.wa-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.68rem;
}

.wa-info-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #78716c;
    font-weight: 700;
    flex-shrink: 0;
}

.wa-info-label i {
    width: 12px;
    text-align: center;
    color: var(--wa-accent-orange);
}

.wa-info-value {
    font-weight: 800;
    color: var(--wa-ink);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-info-value.copyable {
    cursor: pointer;
    border-bottom: 1.5px dashed var(--wa-accent-orange);
    transition: color 0.15s ease;
}

.wa-info-value.copyable:hover {
    color: var(--wa-accent-orange);
}

.wa-info-value.copyable.copied {
    color: var(--wa-primary);
    border-color: var(--wa-primary);
}

/* NOTAS DO LEAD */
.wa-notes-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    max-height: 160px;
    overflow-y: auto;
    padding-right: 2px;
}

.wa-note-card {
    padding: 7px 9px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #1e293b;
    font: 600 0.7rem 'Outfit', sans-serif;
    line-height: 1.35;
    word-break: break-word;
}

.wa-note-card-time {
    font-weight: 800;
    color: #0284c7;
    font-size: 0.6rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wa-notes-empty {
    font: 700 0.68rem 'Outfit', sans-serif;
    color: #94a3b8;
    text-align: center;
    padding: 10px 0;
    font-style: italic;
}

/* BOTÃO RETRO REUTILIZÁVEL */
.btn-retro-wa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border: 2px solid var(--wa-ink);
    border-radius: 8px;
    background: var(--wa-primary);
    color: #fff;
    font: 900 0.72rem 'Outfit', sans-serif;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--wa-ink);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-retro-wa:hover {
    transform: translateY(-1px);
    box-shadow: 3px 3px 0 var(--wa-ink);
}

.btn-retro-wa:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 var(--wa-ink);
}

/* MOBILE ADAPTATION */
@media (max-width: 768px) {
    .wa-float-popup {
        width: calc(100vw - 20px) !important;
        height: 75vh !important;
        left: 10px !important;
        top: 60px !important;
        right: auto !important;
    }
    .wa-tools-panel {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        top: 60px !important;
        width: calc(100vw - 20px) !important;
        height: 75vh !important;
        z-index: 10005 !important;
    }
    .wa-floating-fab {
        bottom: 16px;
        left: 16px;
        padding: 8px 14px;
        font-size: 0.75rem;
    }
}
