/* ============================================
   CONECTIVIDAD — Asistente Comercial Chatbot
   Premium Glassmorphism Chat Widget
   ============================================ */

/* --- Botón "Abrir WhatsApp" dentro del chat --- */
.cb-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    padding: 11px 18px;
    border-radius: 12px;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.35);
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.cb-wa-btn:hover {
    background: #1ebe57;
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(37, 211, 102, 0.45);
}
.cb-wa-btn svg { flex-shrink: 0; }

/* --- CSS Variables --- */
:root {
    --cb-primary: #0066FF;
    --cb-primary-dark: #0050CC;
    --cb-primary-glow: rgba(0, 102, 255, 0.4);
    --cb-accent: #00D4AA;
    --cb-accent-glow: rgba(0, 212, 170, 0.3);
    --cb-dark: #0A0E1A;
    --cb-dark-secondary: #111827;
    --cb-dark-card: #1A1F2E;
    --cb-dark-input: #232839;
    --cb-gray: #6B7280;
    --cb-gray-light: #9CA3AF;
    --cb-white: #F9FAFB;
    --cb-border: rgba(255, 255, 255, 0.08);
    --cb-glass: rgba(17, 24, 39, 0.85);
    --cb-glass-border: rgba(255, 255, 255, 0.12);
    --cb-radius: 16px;
    --cb-radius-sm: 10px;
    --cb-radius-msg: 18px;
    --cb-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 102, 255, 0.1);
    --cb-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --cb-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Floating Action Button --- */
.cb-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent));
    border: none;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px var(--cb-primary-glow), 0 4px 16px rgba(0,0,0,0.3);
    transition: var(--cb-transition);
    overflow: hidden;
}

.cb-fab::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent), var(--cb-primary));
    z-index: -1;
    animation: cb-rotate-gradient 3s linear infinite;
}

@keyframes cb-rotate-gradient {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cb-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px var(--cb-primary-glow), 0 6px 20px rgba(0,0,0,0.4);
}

.cb-fab:active {
    transform: scale(0.95);
}

.cb-fab svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: var(--cb-transition);
}

.cb-fab .cb-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.cb-fab.cb-open .cb-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.cb-fab.cb-open .cb-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Pulse ring */
.cb-fab-pulse {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    z-index: 9999;
    pointer-events: none;
}

.cb-fab-pulse::before,
.cb-fab-pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--cb-primary);
    animation: cb-pulse 2.5s ease-out infinite;
}

.cb-fab-pulse::after {
    animation-delay: 1.25s;
}

@keyframes cb-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.2); opacity: 0; }
}

.cb-fab.cb-open ~ .cb-fab-pulse {
    display: none;
}

/* --- Notification Badge --- */
.cb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #EF4444;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--cb-dark);
    animation: cb-badge-bounce 1s ease infinite;
}

@keyframes cb-badge-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.cb-fab.cb-open .cb-badge {
    display: none;
}

/* --- Chat Window --- */
.cb-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: 400px;
    height: 580px;
    max-height: calc(100vh - 140px);
    background: var(--cb-glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--cb-glass-border);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--cb-font);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease,
                visibility 0s 0.35s;
}

.cb-window.cb-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease,
                visibility 0s 0s;
}

/* --- Chat Header --- */
.cb-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.15), rgba(0, 212, 170, 0.08));
    border-bottom: 1px solid var(--cb-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.cb-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.cb-avatar svg {
    width: 22px;
    height: 22px;
    fill: white;
}

.cb-avatar::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #22C55E;
    border-radius: 50%;
    border: 2px solid var(--cb-dark-secondary);
}

.cb-header-info {
    flex: 1;
    min-width: 0;
}

.cb-header-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--cb-white);
    margin: 0;
    line-height: 1.3;
}

.cb-header-subtitle {
    font-size: 12px;
    color: var(--cb-accent);
    margin: 0;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cb-header-subtitle::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--cb-accent);
    border-radius: 50%;
    animation: cb-blink 1.5s ease infinite;
}

@keyframes cb-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.cb-header-close {
    background: none;
    border: none;
    color: var(--cb-gray-light);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: var(--cb-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cb-header-close:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.cb-header-close svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* --- Messages Container --- */
.cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar {
    width: 4px;
}

.cb-messages::-webkit-scrollbar-track {
    background: transparent;
}

.cb-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 4px;
}

/* --- Message Bubbles --- */
.cb-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: cb-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cb-msg-in {
    0% { opacity: 0; transform: translateY(12px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.cb-msg.cb-bot {
    align-self: flex-start;
}

.cb-msg.cb-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cb-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.cb-msg-avatar svg {
    width: 14px;
    height: 14px;
    fill: white;
}

.cb-msg.cb-user .cb-msg-avatar {
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
}

.cb-msg-bubble {
    padding: 12px 16px;
    border-radius: var(--cb-radius-msg);
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--cb-white);
    position: relative;
}

.cb-bot .cb-msg-bubble {
    background: var(--cb-dark-card);
    border: 1px solid var(--cb-border);
    border-bottom-left-radius: 6px;
}

.cb-user .cb-msg-bubble {
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-dark));
    border-bottom-right-radius: 6px;
}

.cb-msg-time {
    font-size: 10px;
    color: var(--cb-gray);
    margin-top: 4px;
    padding: 0 4px;
}

.cb-bot .cb-msg-time {
    text-align: left;
}

.cb-user .cb-msg-time {
    text-align: right;
}

/* --- Typing Indicator --- */
.cb-typing {
    display: flex;
    gap: 8px;
    align-self: flex-start;
    max-width: 88%;
    animation: cb-msg-in 0.3s ease;
}

.cb-typing-dots {
    padding: 14px 18px;
    background: var(--cb-dark-card);
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius-msg);
    border-bottom-left-radius: 6px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.cb-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cb-gray);
    animation: cb-typing-bounce 1.4s ease infinite;
}

.cb-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.cb-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cb-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); background: var(--cb-gray); }
    30% { transform: translateY(-6px); background: var(--cb-primary); }
}

/* --- Quick Replies --- */
.cb-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    animation: cb-msg-in 0.4s ease;
}

.cb-quick-btn {
    padding: 8px 16px;
    background: rgba(0, 102, 255, 0.1);
    border: 1px solid rgba(0, 102, 255, 0.3);
    border-radius: 20px;
    color: var(--cb-primary);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--cb-transition);
    font-family: var(--cb-font);
    white-space: nowrap;
}

.cb-quick-btn:hover {
    background: var(--cb-primary);
    color: white;
    border-color: var(--cb-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--cb-primary-glow);
}

.cb-quick-btn:active {
    transform: scale(0.95);
}

/* --- Input Area --- */
.cb-input-area {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--cb-border);
    background: rgba(10, 14, 26, 0.6);
    flex-shrink: 0;
}

.cb-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--cb-dark-input);
    border: 1px solid var(--cb-border);
    border-radius: 14px;
    padding: 4px 6px 4px 16px;
    transition: var(--cb-transition);
}

.cb-input-wrap:focus-within {
    border-color: var(--cb-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.15);
}

.cb-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--cb-white);
    font-size: 13.5px;
    font-family: var(--cb-font);
    padding: 8px 0;
    min-width: 0;
}

.cb-input::placeholder {
    color: var(--cb-gray);
}

.cb-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--cb-transition);
    flex-shrink: 0;
}

.cb-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px var(--cb-primary-glow);
}

.cb-send-btn:active {
    transform: scale(0.92);
}

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

.cb-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* --- Lead Capture Form (inside chat) --- */
.cb-form {
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cb-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cb-form-group label {
    font-size: 11px;
    color: var(--cb-gray-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cb-form-group input {
    background: var(--cb-dark-input);
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius-sm);
    padding: 10px 14px;
    color: var(--cb-white);
    font-size: 13px;
    font-family: var(--cb-font);
    outline: none;
    transition: var(--cb-transition);
}

.cb-form-group input:focus {
    border-color: var(--cb-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}

.cb-form-group input::placeholder {
    color: var(--cb-gray);
}

.cb-form-group input.cb-invalid {
    border-color: #EF4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.cb-form-submit {
    padding: 11px 20px;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-accent));
    border: none;
    border-radius: var(--cb-radius-sm);
    color: white;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--cb-transition);
    font-family: var(--cb-font);
    margin-top: 4px;
}

.cb-form-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--cb-primary-glow);
}

.cb-form-submit:active {
    transform: scale(0.97);
}

/* --- Product Card (inside chat) --- */
.cb-product-card {
    background: var(--cb-dark-input);
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius-sm);
    padding: 14px;
    margin-top: 8px;
}

.cb-product-card h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--cb-white);
    margin: 0 0 4px;
}

.cb-product-card p {
    font-size: 12px;
    color: var(--cb-gray-light);
    margin: 0;
    line-height: 1.4;
}

.cb-product-card .cb-product-tag {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(0, 102, 255, 0.12);
    color: var(--cb-primary);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
}

/* --- Summary Card --- */
.cb-summary {
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.08), rgba(0, 212, 170, 0.06));
    border: 1px solid rgba(0, 102, 255, 0.2);
    border-radius: var(--cb-radius-sm);
    padding: 16px;
    margin-top: 8px;
}

.cb-summary h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--cb-accent);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cb-summary ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cb-summary li {
    font-size: 13px;
    color: var(--cb-white);
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.4;
}

.cb-summary li::before {
    content: '✓';
    color: var(--cb-accent);
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

/* --- Powered By --- */
.cb-powered {
    text-align: center;
    padding: 8px 0 4px;
    font-size: 10px;
    color: var(--cb-gray);
    font-family: var(--cb-font);
}

.cb-powered a {
    color: var(--cb-primary);
    text-decoration: none;
    font-weight: 600;
}

/* --- Welcome Tooltip --- */
.cb-tooltip {
    position: fixed;
    bottom: 100px;
    right: 28px;
    background: var(--cb-dark-card);
    border: 1px solid var(--cb-glass-border);
    border-radius: 12px;
    padding: 12px 18px;
    color: var(--cb-white);
    font-family: var(--cb-font);
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    animation: cb-tooltip-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 260px;
    line-height: 1.45;
}

.cb-tooltip::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 24px;
    width: 14px;
    height: 14px;
    background: var(--cb-dark-card);
    border-right: 1px solid var(--cb-glass-border);
    border-bottom: 1px solid var(--cb-glass-border);
    transform: rotate(45deg);
}

.cb-tooltip-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: var(--cb-gray);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    line-height: 1;
}

@keyframes cb-tooltip-in {
    0% { opacity: 0; transform: translateY(10px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .cb-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .cb-fab {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .cb-fab-pulse {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .cb-tooltip {
        right: 16px;
        bottom: 86px;
        left: 16px;
        max-width: none;
    }

    .cb-tooltip::after {
        right: 30px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .cb-window {
        width: 370px;
        height: 520px;
    }
}
