/* Botón flotante de WhatsApp Mejorado */
.whatsapp-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: var(--font-body, system-ui, -apple-system, sans-serif);
}

/* El botón circular principal */
.whatsapp-btn-trigger {
    width: 60px;
    height: 60px;
    background: #25D366;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    outline: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.whatsapp-btn-trigger:hover {
    transform: scale(1.1);
}

.whatsapp-icon {
    width: 32px;
    height: 32px;
    fill: white;
}

.whatsapp-close-icon {
    width: 24px;
    height: 24px;
    fill: white;
    display: none;
}

/* Estado abierto: cambia icono */
.whatsapp-widget.open .whatsapp-btn-trigger {
    background: #128C7E;
    transform: rotate(90deg);
}

.whatsapp-widget.open .whatsapp-icon {
    display: none;
}

.whatsapp-widget.open .whatsapp-close-icon {
    display: block;
}

/* Badge de notificación */
.whatsapp-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #FF3B30;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }

    60% {
        transform: translateY(-3px);
    }
}

/* Ventana del chat (popup) */
.whatsapp-popup {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    pointer-events: none;
}

.whatsapp-widget.open .whatsapp-popup {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header del chat */
.whatsapp-popup-header {
    background: #128C7E;
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.whatsapp-avatar {
    background: white;
    border-radius: 50%;
    padding: 2px;
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.whatsapp-header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.whatsapp-header-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

/* Cuerpo del chat */
.whatsapp-popup-body {
    padding: 20px;
    background-color: #E5DDD5;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h100v100H0z' fill='%23E5DDD5' fill-opacity='1'/%3E%3Cpath d='M96.39 30.61l-3.23-2.15-2.15-3.23 2.15-3.23 3.23-2.15 2.15 3.23-2.15 3.23-3.23 2.15zM22.61 73.39l-3.23-2.15-2.15-3.23 2.15-3.23 3.23-2.15 2.15 3.23-2.15 3.23-3.23 2.15z' fill='%23d3cbc3' fill-opacity='0.4'/%3E%3C/svg%3E");
    max-height: 300px;
    overflow-y: auto;
}

.whatsapp-message-bubble {
    background: white;
    padding: 12px 14px;
    border-radius: 0 12px 12px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    max-width: 85%;
    position: relative;
    font-size: 14px;
    color: #111;
    line-height: 1.4;
}

.whatsapp-message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 10px solid white;
    border-left: 10px solid transparent;
}

.whatsapp-message-time {
    display: block;
    text-align: right;
    font-size: 10px;
    color: #999;
    margin-top: 4px;
}

/* Footer del chat (botón de acción) */
.whatsapp-popup-footer {
    padding: 12px;
    background: white;
    border-top: 1px solid #eee;
}

.whatsapp-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25D366;
    color: white;
    text-decoration: none;
    font-weight: 600;
    padding: 12px;
    border-radius: 24px;
    transition: background 0.2s;
}

.whatsapp-start-btn:hover {
    background: #1EBE57;
    color: white;
}

/* Ajustes móvil */
@media (max-width: 480px) {
    .whatsapp-popup {
        width: 280px;
        right: -24px;
        bottom: 70px;
    }
}