/* ══════════════════════════════════════
   Botão WhatsApp — site
   Posição, tamanho (--wlb-btn) e cores do balão (--wlb-tip-bg/fg) vêm do
   CSS gerado pelo plugin (wlb_enqueue_inline_css).
   ══════════════════════════════════════ */

.wlb-container {
    position: fixed;
    right: 16px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 99999;
    --wlb-btn: 70px;
    --wlb-tip-bg: #075E54;
    --wlb-tip-fg: #FFFFFF;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}

/* Botão: link wa.me de verdade (abre em nova aba, funciona com o botão do meio) */
.wlb-whatsapp-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--wlb-btn);
    height: var(--wlb-btn);
    border-radius: 50%;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.wlb-whatsapp-button img,
.wlb-whatsapp-button svg { width: 100%; height: 100%; object-fit: contain; }
.wlb-whatsapp-button img { padding: 8%; box-sizing: border-box; }
.wlb-whatsapp-button .wlb-btn-estatico { position: absolute; inset: 0; transition: opacity .2s; }
.wlb-whatsapp-button.is-animado .wlb-btn-estatico { opacity: 0; }
.wlb-whatsapp-button:focus-visible { outline: 3px solid #0B3D2E; outline-offset: 3px; }

/* Balão e aviso fora do horário: acima do botão, alinhados pelo lado dele,
   seta no centro do botão. */
.wlb-tooltip,
.wlb-offline-popup {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    box-sizing: border-box;
    width: max-content;
    max-width: min(270px, calc(100vw - 32px));
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
    animation: wlbFadeIn .3s ease;
    transition: opacity .3s;
}
.wlb-tooltip { background: var(--wlb-tip-bg); color: var(--wlb-tip-fg); }
.wlb-offline-popup { background: #1d2327; color: #fff; padding: 14px 44px 14px 16px; }
.wlb-tooltip::after,
.wlb-offline-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    right: calc(var(--wlb-btn) / 2 - 8px);
    border: 8px solid transparent;
    border-top-color: var(--wlb-tip-bg);
}
.wlb-offline-popup::after { border-top-color: #1d2327; }
.wlb-container-left .wlb-tooltip,
.wlb-container-left .wlb-offline-popup { right: auto; left: 0; }
.wlb-container-left .wlb-tooltip::after,
.wlb-container-left .wlb-offline-popup::after { right: auto; left: calc(var(--wlb-btn) / 2 - 8px); }

/* O balão inteiro é clicável */
.wlb-tooltip-text {
    display: block;
    width: 100%;
    padding: 12px 44px 12px 16px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 12px;
}
.wlb-tooltip-text:focus-visible { outline: 3px solid var(--wlb-tip-fg); outline-offset: -4px; }

/* Fechar com área de toque de 44px */
.wlb-tooltip-close,
.wlb-offline-close,
.wlb-popup-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-size: 20px;
    line-height: 44px;
    text-align: center;
    cursor: pointer;
    opacity: .8;
}
.wlb-tooltip-close:hover,
.wlb-offline-close:hover,
.wlb-popup-close:hover { opacity: 1; }
.wlb-tooltip-close:focus-visible,
.wlb-offline-close:focus-visible,
.wlb-popup-close:focus-visible { outline: 2px solid currentColor; outline-offset: -6px; opacity: 1; }

.wlb-offline-text { display: block; }
.wlb-offline-send {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    margin-top: 10px;
    padding: 0 14px;
    border-radius: 999px;
    background: #25D366;
    color: #0B3D2E;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
}
.wlb-offline-send:hover,
.wlb-offline-send:focus-visible { background: #1ebe5b; color: #0B3D2E; outline: none; box-shadow: 0 0 0 3px rgba(37, 211, 102, .4); }

/* ── Menu de atendentes ── */
.wlb-agents-popup {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    width: 320px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: wlbPopupIn .25s cubic-bezier(.175, .885, .32, 1.275);
    z-index: 100000;
}
.wlb-agents-popup.wlb-active { display: flex; }
.wlb-container-left .wlb-agents-popup { right: auto; left: 0; transform-origin: bottom left; }

.wlb-popup-header { position: relative; padding: 18px 48px 18px 20px; background: #075E54; color: #fff; }
.wlb-popup-title { margin: 0; font-size: 16px; font-weight: 600; color: inherit; }
.wlb-popup-subtitle { margin: 4px 0 0; font-size: 13px; opacity: .9; }

.wlb-popup-body { max-height: min(350px, 60vh); overflow-y: auto; padding: 10px; background: #f6f7f7; }

.wlb-agent-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fff;
    border-radius: 10px;
    text-decoration: none;
    color: #1d2327;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
    transition: box-shadow .2s ease;
}
.wlb-agent-row:last-child { margin-bottom: 0; }
.wlb-agent-row:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, .1); color: #1d2327; }
.wlb-agent-row:focus-visible { outline: 3px solid #075E54; outline-offset: 2px; }
.wlb-agent-avatar { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; object-fit: cover; border: 2px solid #25D366; padding: 2px; }
.wlb-agent-info { flex: 1; min-width: 0; }
.wlb-agent-name { font-weight: 600; font-size: 15px; }
.wlb-agent-role { font-size: 13px; color: #50575e; }
.wlb-agent-icon { color: #128C7E; font-size: 18px; }

@keyframes wlbFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes wlbPopupIn { from { opacity: 0; transform: scale(.9) translateY(12px); } to { opacity: 1; transform: none; } }

@media (hover: hover) {
    .wlb-agent-row:hover { transform: translateY(-1px); }
}
@media (prefers-reduced-motion: reduce) {
    .wlb-tooltip, .wlb-offline-popup, .wlb-agents-popup { animation: none; }
    .wlb-agent-row, .wlb-whatsapp-button .wlb-btn-estatico { transition: none; }
    .wlb-agent-row:hover { transform: none; }
}
