/* ========================================
   WIDGET WHATSAPP CEPJK
   10 estrategias de conversión integradas
   ======================================== */

.wa-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    font-family: var(--font-primary);
}

/* Burbuja principal — pill con etiqueta de texto en desktop, círculo en móvil */
.wa-bubble {
    height: 56px;
    background: var(--color-whatsapp);
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(37, 211, 102, 0.32);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 22px 0 16px;
    position: relative;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: none; /* Bounce eliminado: era demasiado intrusivo */
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    border: none;
    font-family: inherit;
}

.wa-bubble::after {
    content: "Estamos en línea";
    white-space: nowrap;
}

.wa-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(37, 211, 102, 0.48);
}

.wa-bubble-icon,
.wa-bubble > svg {
    width: 26px;
    height: 26px;
    color: white;
    fill: white;
    z-index: 2;
    flex-shrink: 0;
}

/* En móvil ocultamos la etiqueta y volvemos a círculo compacto */
@media (max-width: 640px) {
    .wa-bubble {
        width: 56px;
        padding: 0;
        border-radius: 50%;
    }
    .wa-bubble::after {
        display: none;
    }
}

/* Indicador "online" (punto verde, sin pulse agresivo) */
.wa-online-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #00E676;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 3;
}

/* Badge de notificación — más discreto, sin pulse agresivo */
.wa-notification-badge {
    display: none;  /* Ocultado: el "1" rojo era demasiado intrusivo y no representa algo real. */
}

@keyframes waBadgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Pop-up de bienvenida temporizado (Estrategia 2) */
.wa-welcome-popup {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: white;
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: 280px;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wa-welcome-popup.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.wa-welcome-popup::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 16px;
    height: 16px;
    background: white;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05);
}

.wa-welcome-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-gray);
    border: none;
}

.wa-welcome-close:hover {
    background: var(--color-lighter-gray);
    color: var(--color-black);
}

.wa-welcome-title {
    font-weight: 700;
    color: var(--color-black);
    font-size: 0.95rem;
    margin-bottom: 4px;
    padding-right: 28px;
}

.wa-welcome-text {
    color: var(--color-gray);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 12px;
}

.wa-welcome-btn {
    background: var(--color-whatsapp);
    color: white;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.wa-welcome-btn:hover {
    background: var(--color-whatsapp-hover);
}

.wa-welcome-btn svg {
    width: 14px;
    height: 14px;
}

/* Panel principal del chat */
.wa-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 48px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 560px;
    display: flex;
    flex-direction: column;
}

.wa-panel.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header del panel */
.wa-panel-header {
    background: linear-gradient(135deg, #128C7E 0%, #075E54 100%);
    padding: 16px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.wa-panel-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath d='M30 30m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0' fill='%23ffffff' fill-opacity='0.05'/%3E%3C/svg%3E");
    opacity: 0.3;
}

.wa-panel-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #FF6B35 0%, #E85D2C 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.wa-panel-avatar-online {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #00E676;
    border: 2px solid #075E54;
    border-radius: 50%;
}

.wa-panel-info {
    flex: 1;
    position: relative;
    z-index: 2;
}

.wa-panel-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 2px;
}

.wa-panel-status {
    font-size: 0.78rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}

.wa-panel-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    transition: background 0.2s;
}

.wa-panel-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Body del panel */
.wa-panel-body {
    background: #ECE5DD;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    min-height: 280px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath d='M30 30m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0' fill='%23075E54' fill-opacity='0.03'/%3E%3C/svg%3E");
}

.wa-message {
    background: white;
    padding: 12px 14px;
    border-radius: 0 12px 12px 12px;
    margin-bottom: 12px;
    max-width: 85%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: waMessageIn 0.3s ease-out;
}

@keyframes waMessageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.wa-message-text {
    color: var(--color-black);
    font-size: 0.9rem;
    line-height: 1.5;
}

.wa-message-text strong {
    color: #128C7E;
}

.wa-message-time {
    font-size: 0.7rem;
    color: var(--color-light-gray);
    text-align: right;
    margin-top: 4px;
}

.wa-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border-radius: 0 12px 12px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wa-typing span {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: waTyping 1.4s infinite;
}

.wa-typing span:nth-child(2) { animation-delay: 0.2s; }
.wa-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes waTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Opciones de servicio (Estrategia 3: CTAs contextuales) */
.wa-options {
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wa-option {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-black);
    width: 100%;
}

.wa-option:hover {
    background: var(--color-whatsapp);
    color: white;
    border-color: var(--color-whatsapp);
    transform: translateX(4px);
}

.wa-option-icon {
    width: 32px;
    height: 32px;
    background: var(--color-orange-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.wa-option:hover .wa-option-icon {
    background: rgba(255, 255, 255, 0.2);
}

.wa-option-icon svg {
    width: 18px;
    height: 18px;
    color: var(--color-orange);
    transition: color 0.2s;
}

.wa-option:hover .wa-option-icon svg {
    color: white;
}

.wa-option-text {
    flex: 1;
}

.wa-option-title {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 0.9rem;
}

.wa-option-sub {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Footer del panel */
.wa-panel-footer {
    padding: 12px 16px;
    background: #F0F0F0;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.wa-panel-footer-stars {
    color: #FBBC05;
    font-size: 0.8rem;
}

/* Prueba social junto al CTA (Estrategia 4) */
.wa-social-proof {
    padding: 8px 14px;
    background: rgba(37, 211, 102, 0.08);
    border: 1px solid rgba(37, 211, 102, 0.2);
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: 0.78rem;
    color: #075E54;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wa-social-proof svg {
    width: 16px;
    height: 16px;
    color: #25D366;
    flex-shrink: 0;
}

/* Exit intent popup (Estrategia 8) */
.wa-exit-intent {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.wa-exit-intent.active {
    opacity: 1;
    pointer-events: all;
}

.wa-exit-intent-content {
    background: white;
    border-radius: 20px;
    padding: 40px 32px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.wa-exit-intent.active .wa-exit-intent-content {
    transform: scale(1);
}

.wa-exit-intent-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: var(--color-bg-light);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--color-gray);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-exit-intent-close:hover {
    background: var(--color-lighter-gray);
}

.wa-exit-intent-icon {
    width: 72px;
    height: 72px;
    background: var(--color-orange-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.wa-exit-intent-icon svg {
    width: 36px;
    height: 36px;
    color: var(--color-orange);
}

.wa-exit-intent-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-black);
    margin-bottom: 8px;
}

.wa-exit-intent-text {
    color: var(--color-gray);
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.wa-exit-intent-btn {
    background: var(--color-whatsapp);
    color: white;
    padding: 14px 28px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.3);
}

.wa-exit-intent-btn:hover {
    background: var(--color-whatsapp-hover);
    transform: translateY(-2px);
}

/* Sticky bar móvil (Estrategia 9) */
.wa-mobile-sticky {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--color-border);
    padding: 10px 12px;
    z-index: 90;
    gap: 8px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.wa-mobile-sticky a {
    flex: 1;
    padding: 12px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    color: white;
}

.wa-mobile-sticky .wa-mobile-whatsapp {
    background: var(--color-whatsapp);
}

.wa-mobile-sticky .wa-mobile-call {
    background: var(--color-orange);
}

.wa-mobile-sticky svg {
    width: 18px;
    height: 18px;
}

/* Mobile */
@media (max-width: 768px) {
    .wa-widget {
        bottom: 80px; /* Arriba del sticky bar */
    }

    .wa-mobile-sticky {
        display: flex;
    }

    .wa-panel {
        width: calc(100vw - 32px);
        right: -8px;
    }

    .wa-welcome-popup {
        width: 260px;
    }

    body {
        padding-bottom: 60px;
    }
}

/* Oculta el widget cuando el exit intent está activo */
.wa-widget.hidden {
    opacity: 0;
    pointer-events: none;
}
