/**
 * IMOVZ — WhatsApp (botão flutuante + botão no CTA do imóvel)
 *
 * @package Imovz_Tools
 */

/* ==========================================================================
   Botão flutuante
   ========================================================================== */

.imovz-whats-float {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 9999;
    display: flex;
    align-items: center;
    height: 56px;
    min-width: 56px;
    padding: 0;
    border-radius: 28px;
    background: #25D366;
    color: #fff;
    box-shadow: 0 6px 20px rgba(11, 31, 30, 0.25), 0 2px 6px rgba(37, 211, 102, 0.35);
    text-decoration: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 15px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    animation: imovz-whats-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    -webkit-tap-highlight-color: transparent;
}

.imovz-whats-float--direita {
    right: calc(20px + env(safe-area-inset-right, 0px));
    flex-direction: row-reverse; /* label expande para o centro da tela */
}

.imovz-whats-float--esquerda {
    left: calc(20px + env(safe-area-inset-left, 0px));
    flex-direction: row;
}

.imovz-whats-float::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
}

.imovz-whats-float:hover,
.imovz-whats-float:focus-visible {
    background: #1EBE5B;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(11, 31, 30, 0.3), 0 3px 8px rgba(37, 211, 102, 0.4);
}

.imovz-whats-float:focus-visible {
    outline: 3px solid #00C9B1;
    outline-offset: 3px;
}

.imovz-whats-float__icon {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    margin: 13px;
    fill: currentColor;
    display: block;
}

.imovz-whats-float__label {
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
}

/* Label "Fale conosco" só no hover em dispositivos com ponteiro fino (desktop) */
@media (hover: hover) and (pointer: fine) {
    .imovz-whats-float:hover .imovz-whats-float__label,
    .imovz-whats-float:focus-visible .imovz-whats-float__label {
        max-width: 180px;
        opacity: 1;
    }

    .imovz-whats-float--direita:hover .imovz-whats-float__label,
    .imovz-whats-float--direita:focus-visible .imovz-whats-float__label {
        padding-left: 20px;
    }

    .imovz-whats-float--esquerda:hover .imovz-whats-float__label,
    .imovz-whats-float--esquerda:focus-visible .imovz-whats-float__label {
        padding-right: 20px;
    }
}

/* Pulso de atenção (adicionado via JS uma vez após o carregamento) */
.imovz-whats-float.is-pulse::before {
    animation: imovz-whats-pulse 1.4s ease-out 2;
}

/* Some quando o banner de instalação do PWA está aberto */
body.imovz-pwa-banner-open .imovz-whats-float {
    display: none;
}

@keyframes imovz-whats-in {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes imovz-whats-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55);
    }
    100% {
        box-shadow: 0 0 0 18px rgba(37, 211, 102, 0);
    }
}

/* ==========================================================================
   Botão "Falar no WhatsApp" no CTA do imóvel (shortcode single)
   ========================================================================== */

.imovz-single .imovz-single-btn-whatsapp,
.imovz-single-btn-whatsapp {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    background: #25D366;
    color: #fff;
    border: none;
    border-radius: var(--imovz-radius-lg, 1rem);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
    transition: var(--imovz-transition, all 0.2s ease);
}

.imovz-single .imovz-single-btn-whatsapp:hover,
.imovz-single .imovz-single-btn-whatsapp:focus-visible,
.imovz-single-btn-whatsapp:hover,
.imovz-single-btn-whatsapp:focus-visible {
    background: #1EBE5B;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}

.imovz-single-btn-whatsapp:focus-visible {
    outline: 3px solid #00C9B1;
    outline-offset: 2px;
}

.imovz-single-btn-whatsapp__icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    fill: currentColor;
}

/* ==========================================================================
   Acessibilidade: movimento reduzido
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .imovz-whats-float,
    .imovz-whats-float__label,
    .imovz-single-btn-whatsapp {
        animation: none;
        transition: none;
    }

    .imovz-whats-float.is-pulse::before {
        animation: none;
    }

    .imovz-whats-float:hover,
    .imovz-single-btn-whatsapp:hover {
        transform: none;
    }
}
