
/* =============================================
   Chatbot Widget v2 — Premium Dark Theme
   ============================================= */
.cn-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Toggle flotante oculto: acceso ahora vía botón IA del buscador */
.cn-chat__toggle {
    display: none !important;
}

/* Toggle Button */
.cn-chat__toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(102,126,234,0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
}
.cn-chat__toggle:hover {
    transform: scale(1.12);
    box-shadow: 0 8px 36px rgba(102,126,234,0.7);
}
.cn-chat__toggle-glow {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    opacity: 0.4;
    animation: cnGlow 2s ease-in-out infinite;
    z-index: -1;
}
@keyframes cnGlow {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.25); opacity: 0; }
}
.cn-chat__badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #f5576c, #ff6b6b);
    color: white;
    font-size: 10px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: cnBadgePulse 2s infinite;
}
@keyframes cnBadgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Window */
.cn-chat__window {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 400px;
    max-height: 600px;
    background: #0d1117;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(102,126,234,0.15);
    display: flex;
    flex-direction: column;
    animation: cnSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cnSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.cn-chat__header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}
.cn-chat__header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}
.cn-chat__header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cn-chat__avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.cn-chat__avatar-emoji {
    font-size: 22px;
}
.cn-chat__avatar-pulse {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #00e676;
    border-radius: 50%;
    border: 2px solid #667eea;
    animation: cnPulse 2s infinite;
}
@keyframes cnPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0,230,118,0.5); }
    50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(0,230,118,0); }
}
.cn-chat__name {
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}
.cn-chat__status {
    color: rgba(255,255,255,0.85);
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 5px;
}
.cn-chat__status-dot {
    width: 7px;
    height: 7px;
    background: #00e676;
    border-radius: 50%;
    display: inline-block;
}
.cn-chat__header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.cn-chat__header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}
.cn-chat__header-btn:hover {
    background: rgba(255,255,255,0.25);
}
.cn-chat__close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}
.cn-chat__close:hover {
    background: rgba(255,255,255,0.2);
}

/* Context Banner */
.cn-chat__context-banner {
    background: linear-gradient(90deg, rgba(102,126,234,0.12), rgba(118,75,162,0.08));
    border-bottom: 1px solid rgba(102,126,234,0.15);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: #94a3b8;
    animation: cnFadeIn 0.3s ease;
}
@keyframes cnFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.cn-chat__context-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Messages Area */
.cn-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    max-height: 350px;
    scrollbar-width: thin;
    scrollbar-color: #1e293b transparent;
    scroll-behavior: smooth;
}
.cn-chat__messages::-webkit-scrollbar { width: 4px; }
.cn-chat__messages::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }

/* Message Bubbles */
.cn-chat__msg {
    margin-bottom: 14px;
    display: flex;
    animation: cnMsgIn 0.3s ease;
}
@keyframes cnMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.cn-chat__msg--bot { justify-content: flex-start; }
.cn-chat__msg--user { justify-content: flex-end; }

.cn-chat__msg-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.6;
    word-break: break-word;
}
.cn-chat__msg--bot .cn-chat__msg-bubble {
    background: #161b22;
    color: #e6edf3;
    border-bottom-left-radius: 4px;
    border: 1px solid #21262d;
}
.cn-chat__msg--user .cn-chat__msg-bubble {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-bottom-right-radius: 4px;
}
.cn-chat__msg-bubble strong { font-weight: 600; }
.cn-chat__msg-bubble a {
    color: #79b8ff;
    text-decoration: none;
}
.cn-chat__msg-bubble a:hover { text-decoration: underline; }

/* Result Cards */
.cn-chat__results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.cn-chat__result-card {
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}
.cn-chat__result-card:hover {
    border-color: #667eea;
    background: #1c2333;
    transform: translateX(2px);
}
.cn-chat__result-img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    background: #21262d;
    flex-shrink: 0;
}
.cn-chat__result-info {
    flex: 1;
    min-width: 0;
}
.cn-chat__result-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: #e6edf3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.cn-chat__result-price {
    font-weight: 700;
    font-size: 0.9rem;
    color: #00e676;
}
.cn-chat__result-meta {
    font-size: 0.7rem;
    color: #8b949e;
    margin-top: 2px;
}
.cn-chat__result-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(102,126,234,0.15);
    color: #667eea;
    margin-top: 2px;
}

/* Typing Indicator */
.cn-chat__typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.cn-chat__typing span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: cnTyping 1.4s infinite;
}
.cn-chat__typing span:nth-child(2) { animation-delay: 0.2s; }
.cn-chat__typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cnTyping {
    0%, 100% { opacity: 0.3; transform: scale(0.7); }
    50% { opacity: 1; transform: scale(1); }
}

/* Quick Actions */
.cn-chat__quick {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
}
.cn-chat__quick::-webkit-scrollbar { display: none; }
.cn-chat__quick-btn {
    white-space: nowrap;
    padding: 7px 14px;
    border: 1px solid #21262d;
    border-radius: 20px;
    background: rgba(22,27,34,0.6);
    color: #8b949e;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.25s;
    flex-shrink: 0;
    backdrop-filter: blur(8px);
}
.cn-chat__quick-btn:hover {
    border-color: #667eea;
    color: #e6edf3;
    background: rgba(102,126,234,0.1);
    transform: translateY(-1px);
}

/* Registration Gate */
.cn-chat__gate {
    padding: 20px 16px;
    text-align: center;
    animation: cnFadeIn 0.4s ease;
}
.cn-chat__gate-content {
    background: linear-gradient(135deg, rgba(102,126,234,0.08), rgba(118,75,162,0.05));
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 16px;
    padding: 24px 16px;
}
.cn-chat__gate-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}
.cn-chat__gate h4 {
    color: #e6edf3;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 6px;
}
.cn-chat__gate p {
    color: #8b949e;
    font-size: 0.8rem;
    margin: 0 0 14px;
    line-height: 1.4;
}
.cn-chat__gate-benefits {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 16px;
    text-align: left;
    font-size: 0.75rem;
    color: #c9d1d9;
}
.cn-chat__gate-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cn-chat__gate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s;
    cursor: pointer;
}
.cn-chat__gate-btn--primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
}
.cn-chat__gate-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102,126,234,0.4);
}
.cn-chat__gate-btn--secondary {
    background: transparent;
    color: #8b949e;
    border: 1px solid #21262d;
}
.cn-chat__gate-btn--secondary:hover {
    border-color: #667eea;
    color: #e6edf3;
}
.cn-chat__gate-whatsapp {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #21262d;
    font-size: 0.75rem;
    color: #8b949e;
    line-height: 1.4;
}
.cn-chat__gate-whatsapp strong {
    color: #25d366;
}

/* WhatsApp Upsell */
.cn-chat__upsell {
    border-top: 1px solid #21262d;
    animation: cnFadeIn 0.5s ease;
}
.cn-chat__upsell-content {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.75rem;
    color: #8b949e;
    background: linear-gradient(90deg, rgba(37,211,102,0.05), transparent);
}
.cn-chat__upsell-btn {
    margin-left: auto;
    padding: 4px 12px;
    background: #25d366;
    color: white;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
}
.cn-chat__upsell-btn:hover {
    background: #20bd5a;
    transform: scale(1.05);
}

/* Input Area */
.cn-chat__input-area {
    display: flex;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid #21262d;
    background: #0d1117;
}
.cn-chat__input {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid #21262d;
    border-radius: 12px;
    background: #161b22;
    color: #e6edf3;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}
.cn-chat__input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}
.cn-chat__input::placeholder { color: #484f58; }
.cn-chat__send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    flex-shrink: 0;
}
.cn-chat__send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(102,126,234,0.4);
}
.cn-chat__send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Voice Button */
.cn-chat__voice {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: rgba(102,126,234,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    flex-shrink: 0;
}
.cn-chat__voice:hover {
    background: rgba(102,126,234,0.3);
    transform: scale(1.05);
}
.cn-chat__voice.listening {
    background: rgba(245,87,108,0.3);
    animation: cnVoicePulse 1s infinite;
}
.cn-chat__voice svg { fill: #8b949e; }
.cn-chat__voice:hover svg { fill: #e6edf3; }
.cn-chat__voice.listening svg { fill: #f5576c; }
@keyframes cnVoicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245,87,108,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(245,87,108,0); }
}

/* Confirmation Modal */
.cn-chat__confirm {
    position: absolute;
    inset: 0;
    background: rgba(13,17,23,0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: cnFadeIn 0.2s ease;
}
.cn-chat__confirm-box {
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    max-width: 300px;
}
.cn-chat__confirm-icon { font-size: 2rem; margin-bottom: 8px; }
.cn-chat__confirm-text {
    color: #e6edf3;
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.5;
}
.cn-chat__confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.cn-chat__confirm-btn {
    padding: 8px 20px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.cn-chat__confirm-btn--yes {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}
.cn-chat__confirm-btn--yes:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.4);
}
.cn-chat__confirm-btn--no {
    background: #21262d;
    color: #8b949e;
}
.cn-chat__confirm-btn--no:hover {
    background: #30363d;
    color: #e6edf3;
}

/* Action feedback */
.cn-chat__action-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(90deg, rgba(102,126,234,0.1), rgba(118,75,162,0.05));
    border-radius: 12px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: #94a3b8;
    animation: cnFadeIn 0.3s ease;
}
.cn-chat__action-feedback .spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(102,126,234,0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: cnSpin 0.8s linear infinite;
}
@keyframes cnSpin {
    to { transform: rotate(360deg); }
}

/* Powered by badge */
.cn-chat__powered {
    text-align: center;
    padding: 4px;
    font-size: 0.6rem;
    color: #484f58;
    background: #0d1117;
    border-top: 1px solid #161b22;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Hide floating toggle on mobile — assistant is in the tab bar */
    .cn-chat__toggle {
        display: none !important;
    }
    .cn-chat {
        bottom: 70px;
        right: 6px;
        z-index: 100000;
    }
    .cn-chat__window {
        position: fixed;
        bottom: 70px;
        right: 6px;
        width: calc(100vw - 12px);
        max-height: 70vh;
        border-radius: 16px;
    }
    .cn-chat__messages {
        max-height: 42vh;
    }
}
@media (max-width: 480px) {
    .cn-chat__window {
        width: calc(100vw - 12px);
        right: 6px;
        bottom: 70px;
        max-height: 68vh;
        border-radius: 16px;
    }
    .cn-chat__messages {
        max-height: 38vh;
    }
}

/* Assistant icon style in mobile footer tab bar */
.mobile-footer-assistant i {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}
