﻿/* =========================================
   WPC - WhatsApp Premium Connect - ISOLADO
   ========================================= */

/* Reseta e isola o wrapper do plugin */
#wpc-wrapper {
    all: initial;
    /* Reseta heranças do tema */
    position: fixed !important;
    bottom: var(--wpc-bottom, 20px) !important;
    right: var(--wpc-right, 20px) !important;
    left: var(--wpc-left, auto) !important;
    z-index: 999999 !important;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
    display: block !important;
}

#wpc-wrapper * {
    box-sizing: border-box !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Variáveis aplicadas apenas ao wrapper */
#wpc-wrapper {
    --wpc-color: #25D366;
    --wpc-header-bg: #075E54;
    --wpc-chat-bg: #e5ddd5;
    --wpc-width: 450px;
    --wpc-pulse-rgb: 37, 211, 102;
    /* Default Green RGB */
    --wpc-msg-visitor-bg: #ffffff;
    --wpc-msg-visitor-text: #111b21;
    --wpc-msg-agent-bg: #005C4B;
    --wpc-msg-agent-text: #ffffff;

}

.wpc-position-left {
    left: 20px;
    right: auto;
}

/* Botão Flutuante */
.wpc-float-btn {
    width: var(--wpc-btn-size, 60px) !important;
    height: var(--wpc-btn-size, 60px) !important;
    border-radius: 50%;
    background-color: var(--wpc-btn-bg, #25D366) !important;
    color: white;
    border: 2px solid var(--wpc-border-color, rgba(255, 255, 255, 0.2));
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    /* Remove padding padrão do navegador */
    transition: all 0.3s ease !important;
    transition: all 0.3s ease !important;
    position: relative;
    animation: wpcPulse 2s infinite;
}

/* Estado Escondido (Scroll Trigger) */
#wpc-wrapper.wpc-scroll-hidden .wpc-float-btn {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
    animation: none;
}

.wpc-float-btn:hover {
    transform: scale(1.1);
    animation: none;
}

/* Container do ícone */
.wpc-btn-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: normal !important;
    width: 100% !important;
    height: 100% !important;
}

.wpc-btn-icon svg {
    /* Agora usa % relativo ao botão, não pixels fixos */
    width: var(--wpc-icon-percent, 50%) !important;
    height: var(--wpc-icon-percent, 50%) !important;
    fill: var(--wpc-icon-color, white) !important;
    max-width: none !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
}

/* Força cor no PATH também para garantir */
.wpc-btn-icon svg path {
    fill: var(--wpc-icon-color, white) !important;
}

/* Texto do Botão (Popup) - BLINDADO CONTRA TEMAS */
.wpc-btn-text {
    /* Reset total para evitar herança do tema */
    all: initial;
    box-sizing: border-box;
    font-family: inherit;

    /* Posicionamento */
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999998;

    /* Aparência da Caixa */
    background: white !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;

    /* Aparência do Texto */
    color: #111 !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    font-weight: 600 !important;
    text-transform: none !important;
    /* Impede caixa alta forçada */
    text-align: center !important;
    white-space: normal !important;
    /* Permite quebra de linha */

    /* Dimensões */
    width: max-content !important;
    max-width: 220px !important;
    min-width: 120px !important;
    display: block !important;

    /* Animação */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    /* Evita interferência no clique */
}

/* Estado Hover */
.wpc-float-btn:hover .wpc-btn-text {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(-50%) translateX(-10px) !important;
}

/* Notification Badge */
.wpc-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff3b30;
    color: white;
    font-size: 11px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: wpcPop 0.3s ease-out;
}

@keyframes wpcPop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

/* Chat Box */
.wpc-chat-box {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: var(--wpc-width);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    transform-origin: bottom right;
}

.wpc-chat-box.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header Premium (Fiel à Imagem) */
.wpc-chat-header {
    background: var(--wpc-header, #075E54);
    padding: 10px 15px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 65px;
}

/* FORÇA MÁXIMA - Override WordPress/Tema */
#wpc-wrapper .wpc-chat-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

/* OVERRIDES EXTRAÍDOS DO PHP (Para garantir prioridade sobre Elementor) */
#wpc-wrapper #wpc-chat-widget .wpc-chat-header .wpc-header-left {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    flex: 1 !important;
}

#wpc-wrapper #wpc-chat-widget .wpc-chat-header .wpc-header-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
    overflow: hidden !important;
}

#wpc-wrapper #wpc-chat-widget .wpc-chat-header .wpc-header-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

#wpc-wrapper #wpc-chat-widget .wpc-chat-header .wpc-header-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    justify-content: center !important;
    flex: 1 !important;
    min-width: 0 !important;
}

#wpc-wrapper #wpc-chat-widget .wpc-chat-header .wpc-title,
#wpc-wrapper #wpc-chat-widget .wpc-chat-header .wpc-subtitle {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
}

#wpc-wrapper .wpc-header-left {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
}

#wpc-wrapper .wpc-header-avatar {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    background: rgba(255, 255, 255, 0.2) !important;
}

#wpc-wrapper .wpc-header-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

#wpc-wrapper .wpc-header-info {
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    line-height: 1.2 !important;
}

#wpc-wrapper .wpc-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
    padding: 0 !important;
}

#wpc-wrapper .wpc-subtitle {
    font-size: 12px !important;
    opacity: 0.9 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.wpc-header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 15px !important;
    margin-left: 10px !important;
    flex-shrink: 0 !important;
}

.wpc-action-btn,
.wpc-menu-dots {
    background: transparent !important;
    border: none !important;
    cursor: default !important;
    /* Ícones estáticos */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 8px !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
}

.wpc-action-btn svg,
.wpc-menu-dots svg {
    width: 22px !important;
    height: 22px !important;
    fill: white !important;
    flex-shrink: 0 !important;
}

/* Chat Body */
.wpc-chat-body {
    padding: 15px;
    background-color: var(--wpc-bg, #e5ddd5);
    background-image: url('https://web.whatsapp.com/img/bg-chat-tile-dark_a4be512e7195b6b733d9110b408f075d.png');
    background-repeat: repeat;
    background-size: 400px;
    height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Esconder barra de rolagem mas manter funcionalidade */
.wpc-chat-body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.wpc-chat-body {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Balões de Mensagem */
.wpc-msg-bubble {
    background: var(--wpc-msg-visitor-bg, #ffffff);
    padding: 10px 14px;
    border-radius: 0 10px 10px 10px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    font-size: 14.5px;
    line-height: 1.45;
    color: var(--wpc-msg-visitor-text, #111b21);
    max-width: 85%;
    align-self: flex-start;
    position: relative;
    animation: wpcFadeIn 0.3s ease;
}

/* Pontinha do balão branco (esquerda) */
.wpc-msg-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 0 solid transparent;
    border-right: 12px solid var(--wpc-msg-visitor-bg, #ffffff);
    border-bottom: 12px solid transparent;
}

.wpc-msg-time {
    font-size: 11px;
    color: #667781;
    margin-left: 8px;
    float: right;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* Balões ENVIADOS (Verde) */
.wpc-msg-sent {
    background: var(--wpc-msg-agent-bg, #005C4B);
    padding: 10px 14px;
    border-radius: 10px 0 10px 10px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    font-size: 14.5px;
    line-height: 1.45;
    color: var(--wpc-msg-agent-text, #FFFFFF);
    max-width: 85%;
    align-self: flex-end;
    position: relative;
    animation: wpcFadeIn 0.3s ease;
}

/* Pontinha do balão verde */
.wpc-msg-sent::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    border-top: 0 solid transparent;
    border-left: 12px solid var(--wpc-msg-agent-bg, #005C4B);
    border-bottom: 12px solid transparent;
}

.wpc-msg-sent .wpc-msg-time {
    color: rgba(255, 255, 255, 0.6);
}

/* GROUP CARD */
.wpc-group-card {
    background-color: #054740 !important;
    border-radius: 10px 0 10px 10px !important;
    padding: 0 !important;
    width: 95% !important;
    max-width: 390px !important;
    align-self: flex-end;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    overflow: visible;
    animation: wpcFadeIn 0.3s ease;
    position: relative;
}

/* Pontinha do card de grupo */
.wpc-group-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-top: 0 solid transparent;
    border-left: 12px solid #054740;
    border-bottom: 12px solid transparent;
}

.wpc-group-header {
    display: flex;
    gap: 12px;
    background: rgba(0, 0, 0, 0.25);
    padding: 12px;
    align-items: center;
    border-radius: 10px 0 0 0;
    overflow: hidden;
}

.wpc-group-logo img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.wpc-group-info {
    flex: 1;
    overflow: hidden;
}

.wpc-group-title {
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wpc-group-subtitle {
    color: #b1b1b1;
    font-size: 12.5px;
}

.wpc-group-link-text {
    color: #8696a0;
    font-size: 11px;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wpc-group-body-link {
    padding: 10px 12px;
    font-size: 13.5px;
}

.wpc-group-body-link a {
    color: #20B960 !important;
    text-decoration: underline;
    word-break: break-all;
}

.wpc-group-body-link a:visited,
.wpc-group-body-link a:active,
.wpc-group-body-link a:link {
    color: #20B960 !important;
}

/* Link no corpo do texto (Link topo) */
.wpc-group-body-link a:hover {
    color: #20B960 !important;
    text-decoration: none !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    transform: none !important;
}

.wpc-group-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    color: #8696a0;
    font-size: 11px;
    margin-top: 5px;
}

.wpc-group-meta svg {
    width: 16px;
    height: 15px;
    fill: #4fc3f7 !important;
}

.wpc-group-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.wpc-group-btn {
    display: block;
    padding: 12px;
    text-align: center;
    color: #20B960 !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: none !important;
    /* Remove transição */
}

/* Link Acessar Grupo (Footer) */
.wpc-group-btn:visited,
.wpc-group-btn:active,
.wpc-group-btn:link,
.wpc-group-btn:hover {
    color: #20B960 !important;
    text-decoration: none !important;
    background: transparent !important;
    transform: none !important;
    box-shadow: none !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    letter-spacing: normal !important;
}

/* Agents */
.wpc-agents-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.wpc-agent-row {
    background: white;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease !important;
}

.wpc-agent-row:hover {
    background-color: #f9f9f9 !important;
    transform: none !important;
    /* Evita pulos */
    text-decoration: none !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
    /* Mantém sombra fixa */
}

.wpc-agent-row:hover .wpc-agent-name,
.wpc-agent-row:hover .wpc-agent-role {
    text-decoration: none !important;
    transform: none !important;
}

.wpc-agent-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.wpc-agent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wpc-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 11px;
    height: 11px;
    background: #00e676;
    border: 2px solid white;
    border-radius: 50%;
}

.wpc-agent-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.wpc-agent-name {
    font-size: 15.5px;
    font-weight: 600;
    color: #111b21;
}

.wpc-agent-role {
    font-size: 13px;
    color: #667781;
}

/* Typing */
.wpc-typing {
    background: white;
    padding: 10px 15px;
    border-radius: 10px 0 10px 10px;
    display: inline-flex;
    gap: 4px;
    align-self: flex-end;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* Typing à esquerda (para mensagem recebida) */
.wpc-typing-left {
    border-radius: 0 10px 10px 10px;
    align-self: flex-start;
}

.wpc-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: wpcBounce 1.4s infinite ease-in-out both;
}

.wpc-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.wpc-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes wpcBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes wpcFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes wpcPulse {
    0% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(var(--wpc-pulse-rgb), 0.7);
    }

    50% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 15px rgba(var(--wpc-pulse-rgb), 0);
    }

    100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(var(--wpc-pulse-rgb), 0);
    }
}


/* ========================================= */
/* RESPONSIVIDADE - MOBILE & TABLET */
/* ========================================= */

/* Tablet (768px ou menos) */
@media (max-width: 768px) {
    :root {
        --wpc-width: 90vw;
    }

    #wpc-wrapper {
        right: 10px !important;
        bottom: var(--wpc-bottom, 10px) !important;
    }

    .wpc-position-left {
        left: 10px !important;
    }

    .wpc-chat-body {
        height: 60vh;
        max-height: 500px;
    }

    .wpc-group-card,
    .wpc-agent-card {
        max-width: 100% !important;
    }

    /* CENTERING FIX for all mobile devices - ID SELECTOR FOR FORCE */
    #wpc-chat-widget {
        position: fixed !important;
        bottom: 80px !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, 20px) !important;
        width: 90vw !important;
        max-width: 400px !important;
        z-index: 2147483647 !important;
    }

    #wpc-chat-widget.open {
        transform: translate(-50%, 0) !important;
        bottom: 80px !important;
    }
}

/* Mobile (480px ou menos) */
@media (max-width: 480px) {

    /* Fix: Scope variable to ID to override desktop default */
    #wpc-wrapper {
        --wpc-width: 88vw !important;
        /* Slightly less than 95 to allow margins */
    }

    #wpc-wrapper {
        right: var(--wpc-mob-right) !important;
        left: var(--wpc-mob-left) !important;
        bottom: var(--wpc-bottom, 5px) !important;
    }

    .wpc-position-left {
        left: 5px !important;
    }

    .wpc-float-btn {
        width: 56px !important;
        height: 56px !important;
        /* Force identical box model */
        box-sizing: border-box !important;
        margin: 0 !important;
    }

    .wpc-btn-icon svg {
        width: 28px;
        height: 28px;
    }

    .wpc-btn-text {
        display: none !important;
    }



    .wpc-chat-body {
        height: 50vh;
        max-height: 400px;
        padding: 10px;
    }

    .wpc-chat-header {
        padding: 8px 5px !important;
        /* Menos padding lateral para jogar arrow pra esquerda */
        height: 56px;
        gap: 5px !important;
        justify-content: space-between !important;
    }

    /* Reduzir Gap dos Ícones Direita (Camera/Phone) */
    .wpc-header-actions {
        gap: 2px !important;
        margin-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Mover 3 pontos mais pra direita. */
    .wpc-menu-dots {
        margin-right: -5px !important;
        /* Puxa pra direita */
    }

    /* Espaço Arrow - Avatar - Nome */
    .wpc-header-left {
        gap: 4px !important;
        flex: 1 !important;
        overflow: hidden !important;
        /* Garante que nome não quebre */
    }

    .wpc-header-avatar {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
    }

    .wpc-title {
        font-size: 14px !important;
        /* Menor */
    }

    .wpc-subtitle {
        font-size: 10px !important;
        /* Menor */
    }

    /* Botões menores no header mobile */
    .wpc-action-btn,
    .wpc-menu-dots {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        padding: 4px !important;
    }

    .wpc-msg-bubble,
    .wpc-msg-sent {
        max-width: 90%;
        font-size: 14px;
    }

    .wpc-group-card,
    .wpc-agent-card {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Fix: Reduce group link font size on mobile to prevent line break */
    .wpc-group-body-link {
        font-size: 11.5px !important;
        padding: 8px 10px !important;
    }
}

/* Mobile Landscape */
@media (max-width: 768px) and (orientation: landscape) {
    .wpc-chat-body {
        height: 40vh;
    }
}


/* Posição do texto quando botão está à esquerda */
.wpc-position-left .wpc-btn-text {
    right: auto;
    left: 75px;
}


/* Mensagem de Sistema (Segurança) */
.wpc-system-msg {
    display: flex;
    justify-content: center;
    padding: 8px 0;
    animation: wpcFadeIn 0.3s ease;
}

.wpc-system-msg-content {
    background: #FFF4E5;
    color: #8B7355;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    text-align: center;
    max-width: 80%;
    line-height: 1.4;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

/* =========================================
   FIX FINAL DE POSICIONAMENTO ESQUERDA (DESKTOP)
   ========================================= */
@media (min-width: 769px) {

    /* 1. O Chat abre ancorado à ESQUERDA (Left: 0) */
    .wpc-position-left .wpc-chat-box {
        right: auto !important;
        left: 0 !important;
        transform-origin: bottom left !important;
    }

    /* 2. O Tooltip aparece à DIREITA do botão */
    .wpc-position-left .wpc-btn-text {
        right: auto !important;
        left: calc(var(--wpc-btn-size, 60px) + 15px) !important;
        transform-origin: center left !important;
        text-align: left !important;
    }

    /* 3. Animação do Tooltip também inverte para a direita */
    .wpc-position-left .wpc-float-btn:hover .wpc-btn-text {
        transform: translateY(-50%) translateX(10px) !important;
    }
}