/* ═══════════════════════════════════════════════════
   Nexia Chat Widget — Premium Glassmorphism
   Burbuja flotante + ventana de chat con captura de leads
   ═══════════════════════════════════════════════════ */

/* ── Burbuja Flotante ── */
.chat-widget-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(108,92,231,0.4), 0 0 0 0 rgba(108,92,231,0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: bubblePulse 3s ease-in-out infinite;
}

.chat-widget-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(108,92,231,0.5);
}

.chat-widget-bubble svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform 0.3s;
}

.chat-widget-bubble.open svg {
    transform: rotate(90deg);
}

.chat-widget-bubble .bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ff5252;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    border: 2px solid #0a0a0f;
    animation: badgeBounce 2s ease-in-out infinite;
}

@keyframes bubblePulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(108,92,231,0.4), 0 0 0 0 rgba(108,92,231,0.4); }
    50% { box-shadow: 0 8px 32px rgba(108,92,231,0.4), 0 0 0 14px rgba(108,92,231,0); }
}

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

/* ── Ventana de Chat ── */
.chat-widget-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    z-index: 9999;
    width: 400px;
    max-height: 600px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: rgba(15,15,26,0.95);
    backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 60px rgba(108,92,231,0.1);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header del Chat ── */
.cw-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(108,92,231,0.2), rgba(0,206,201,0.1));
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 14px;
}

.cw-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    position: relative;
}

.cw-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: #00b894;
    border-radius: 50%;
    border: 2px solid rgba(15,15,26,0.95);
}

.cw-header-info { flex: 1; }

.cw-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #f0f0f5;
}

.cw-header-status {
    font-size: 12px;
    color: rgba(240,240,245,0.5);
    display: flex;
    align-items: center;
    gap: 5px;
}

.cw-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cw-close:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}

/* ── Formulario de Captura ── */
.cw-capture {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cw-capture-title {
    font-size: 16px;
    font-weight: 700;
    color: #f0f0f5;
    text-align: center;
    margin-bottom: 4px;
}

.cw-capture-sub {
    font-size: 13px;
    color: rgba(240,240,245,0.5);
    text-align: center;
    margin-bottom: 8px;
    line-height: 1.5;
}

.cw-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    color: #f0f0f5;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.cw-input::placeholder { color: rgba(240,240,245,0.3); }
.cw-input:focus { border-color: rgba(108,92,231,0.5); background: rgba(255,255,255,0.07); }

.cw-capture-btn {
    padding: 14px;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.cw-capture-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(108,92,231,0.35);
}

/* ── Cuerpo del Chat ── */
.cw-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    min-height: 300px;
}

.cw-body::-webkit-scrollbar { width: 4px; }
.cw-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.cw-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    animation: msgSlide 0.3s ease;
    position: relative;
}

.cw-msg.bot {
    align-self: flex-start;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.06);
    border-bottom-left-radius: 4px;
    color: #f0f0f5;
}

.cw-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6c5ce7, #5b4cdb);
    border-bottom-right-radius: 4px;
    color: white;
}

.cw-msg-time {
    font-size: 10px;
    opacity: 0.4;
    margin-top: 4px;
}

.cw-typing {
    align-self: flex-start;
    padding: 12px 20px;
    background: rgba(255,255,255,0.06);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.cw-typing-dot {
    width: 7px;
    height: 7px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

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

/* ── Footer / Input ── */
.cw-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.cw-footer input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    color: #f0f0f5;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.cw-footer input::placeholder { color: rgba(240,240,245,0.3); }
.cw-footer input:focus { border-color: rgba(108,92,231,0.4); }

.cw-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.cw-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(108,92,231,0.4);
}

.cw-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.cw-powered {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: rgba(255,255,255,0.2);
    border-top: 1px solid rgba(255,255,255,0.04);
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 480px) {
    .chat-widget-bubble {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
    
    .chat-widget-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
    }
    
    .chat-widget-window.open {
        bottom: 0;
    }
}
