.thrivonx-widget {
    --brand-primary: #0ea5e9;
    --brand-secondary: #d946ef;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.2);
    
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

.thrivonx-widget * { box-sizing: border-box; }

.chat-window {
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: linear-gradient(180deg, var(--bg-dark) 0%, #0a0f1d 100%);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.chat-window.closed {
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.chat-header {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(217, 70, 239, 0.1));
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.1) 0%, transparent 70%);
    animation: pulse-glow 4s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.6;
    animation: message-in 0.3s ease-out;
    position: relative;
}

@keyframes message-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.bot {
    background: var(--bg-card);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
    align-self: flex-start;
    border: 1px solid var(--border-color);
}

.message.user {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    color: white;
    border-bottom-right-radius: 6px;
    align-self: flex-end;
}

.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 18px;
    background: var(--bg-card);
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    width: fit-content;
    border: 1px solid var(--border-color);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--brand-primary);
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.quick-reply-btn {
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.quick-reply-btn:hover {
    background: rgba(14, 165, 233, 0.1);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.input-area {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 4px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within { border-color: var(--brand-primary); }

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 120px;
    font-family: 'Inter', sans-serif;
}

.chat-input::placeholder { color: var(--text-secondary); }

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin: 4px;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.lead-form {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    margin-top: 12px;
}

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.form-group input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.form-group input.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.error-message {
    font-size: 12px;
    color: #ef4444;
    margin-top: 4px;
    display: none;
}

.error-message.show { display: block; }

.submit-lead-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    position: relative;
    overflow: hidden;
}

.submit-lead-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.3);
}

.submit-lead-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: rotate(30deg);
    transition: all 0.6s;
}

.submit-lead-btn:hover::after { left: 100%; }

.whatsapp-handoff {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(217, 70, 239, 0.05));
    border-radius: 20px;
    border: 1px solid var(--border-color);
    margin-top: 12px;
}

.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: #25D366;
    color: white;
    border-radius: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    margin-top: 16px;
    font-size: 14px;
}

.whatsapp-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
}

.widget-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(14, 165, 233, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.widget-toggle:hover { transform: scale(1.1) rotate(5deg); }
.widget-toggle:active { transform: scale(0.95); }

.widget-toggle .close-icon { display: none; }
.widget-toggle.open .chat-icon { display: none; }
.widget-toggle.open .close-icon { display: block; }

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-dark);
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid #22c55e;
    animation: status-ring 2s ease-out infinite;
}

@keyframes status-ring {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
    opacity: 0.7;
}

.bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-content { word-wrap: break-word; }

@media (max-width: 480px) {
    .thrivonx-widget {
        bottom: 16px;
        right: 16px;
    }
    .chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        border-radius: 20px;
    }
    .widget-toggle {
        width: 56px;
        height: 56px;
    }
}