/* =============================================
   Zionex Chat — Frontend Styles
   ============================================= */

/* ── Widget container — SIEMPRE esquina inferior derecha ── */
#dfchat-widget {
    position: fixed !important;
    bottom: var(--dfchat-bottom, 24px) !important;
    right:  var(--dfchat-right,  24px) !important;
    top: auto !important;
    left: auto !important;
    z-index: 2147483647 !important; /* máximo z-index posible */
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 10px !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    pointer-events: none;        /* el widget no bloquea el scroll */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    box-sizing: border-box !important;
    transform: translateZ(0);    /* crea stacking context propio */
}

/* ── Main Button ── */
#dfchat-btn {
    position: relative !important;
    width:  var(--dfchat-btn-size, 62px) !important;
    height: var(--dfchat-btn-size, 62px) !important;
    border-radius: 50% !important;
    border: none !important;
    cursor: pointer !important;
    background: var(--dfchat-btn-color, #25D366) !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.30) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: auto !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1),
                box-shadow 0.25s ease !important;
    -webkit-tap-highlight-color: transparent;
    overflow: visible !important;
}

#dfchat-btn:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.38) !important;
}

#dfchat-btn:active {
    transform: scale(0.96) !important;
}

#dfchat-logo {
    width: calc(var(--dfchat-btn-size, 62px) * 0.6) !important;
    height: calc(var(--dfchat-btn-size, 62px) * 0.6) !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    pointer-events: none !important;
    user-select: none !important;
    display: block !important;
}

/* ── Ping ring animation ── */
.dfchat-ping {
    position: absolute !important;
    inset: 0 !important;
    border-radius: 50% !important;
    border: 3px solid var(--dfchat-btn-color, #25D366) !important;
    opacity: 0 !important;
    animation: dfchat-ping 2.6s ease-out infinite !important;
    pointer-events: none !important;
}

@keyframes dfchat-ping {
    0%   { transform: scale(1);   opacity: 0.75; }
    70%  { transform: scale(1.65); opacity: 0; }
    100% { transform: scale(1.65); opacity: 0; }
}

/* ── Bubble ── */
#dfchat-bubble {
    position: relative !important;
    max-width: 265px !important;
    background: var(--dfchat-bubble-color, #1a73e8) !important;
    color: #fff !important;
    padding: 12px 16px !important;
    border-radius: 18px 18px 4px 18px !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.24) !important;
    cursor: pointer !important;
    line-height: 1.45 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    pointer-events: none !important;  /* empieza oculto */
    opacity: 0 !important;
    transform: translateY(10px) scale(0.94) !important;
    transition: none !important;
    will-change: opacity, transform;
    box-sizing: border-box !important;
}

#dfchat-bubble.dfchat-visible {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
    transition: opacity 0.35s ease,
                transform 0.35s cubic-bezier(.34,1.56,.64,1) !important;
}

#dfchat-bubble.dfchat-hiding {
    opacity: 0 !important;
    transform: translateY(-8px) scale(0.94) !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease,
                transform 0.25s ease !important;
}

#dfchat-bubble.dfchat-visible:hover {
    filter: brightness(1.07) !important;
}

/* Arrow pointing toward the button */
.dfchat-bubble-arrow {
    position: absolute !important;
    bottom: -9px !important;
    right: 18px !important;
    width: 0 !important;
    height: 0 !important;
    border-left: 9px solid transparent !important;
    border-right: 0 solid transparent !important;
    border-top: 11px solid var(--dfchat-bubble-color, #1a73e8) !important;
    pointer-events: none !important;
}

/* ── Text entrance animation ── */
@keyframes dfchat-text-in {
    from { opacity: 0; transform: translateX(-5px); }
    to   { opacity: 1; transform: translateX(0); }
}

#dfchat-bubble-text {
    display: block !important;
    animation: dfchat-text-in 0.32s ease both !important;
}

/* ── Button bounce-in on load ── */
@keyframes dfchat-bounce-in {
    0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
    60%  { transform: scale(1.18) rotate(4deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

#dfchat-btn.dfchat-init {
    animation: dfchat-bounce-in 0.55s cubic-bezier(.34,1.56,.64,1) both !important;
}

/* ── Shake on new message ── */
@keyframes dfchat-shake {
    0%, 100% { transform: rotate(0deg) scale(1); }
    20%       { transform: rotate(-13deg) scale(1.05); }
    40%       { transform: rotate(13deg) scale(1.05); }
    60%       { transform: rotate(-8deg); }
    80%       { transform: rotate(6deg); }
}

#dfchat-btn.dfchat-shake {
    animation: dfchat-shake 0.48s ease !important;
}

/* ── Responsive — tablet ── */
@media screen and (max-width: 768px) {
    #dfchat-bubble {
        max-width: 220px !important;
        font-size: 13px !important;
        padding: 10px 14px !important;
    }
}

/* ── Responsive — móvil ── */
@media screen and (max-width: 480px) {
    #dfchat-bubble {
        max-width: 190px !important;
        font-size: 12px !important;
        padding: 9px 12px !important;
    }
}
