/* ==============================================
   AI CHATBOT — Premium Widget Styles
   ============================================== */

/* Trigger Button */
.chatbot-trigger {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9998;
}

.chatbot-trigger-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, .35);
    transition: all .3s cubic-bezier(.4,0,.2,1);
    position: relative;
}

.chatbot-trigger-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(99, 102, 241, .45);
}

.chatbot-trigger-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    opacity: 0;
    animation: chatPulse 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes chatPulse {
    0%, 100% { transform: scale(1); opacity: 0; }
    50% { transform: scale(1.3); opacity: .2; }
}

.chatbot-icon-close { display: none; }
.chatbot-trigger.active .chatbot-icon-open { display: none; }
.chatbot-trigger.active .chatbot-icon-close { display: block; }

.chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: badgeBounce 2s ease-in-out infinite;
}

.chatbot-trigger.active .chatbot-badge { display: none; }

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

/* Chat Window */
.chatbot-window {
    position: fixed;
    bottom: 170px;
    right: 28px;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .15), 0 0 0 1px rgba(0,0,0,.04);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(.95);
    transition: all .35s cubic-bezier(.4,0,.2,1);
}

.chatbot-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.chatbot-header h4 {
    font-family: 'Outfit', sans-serif;
    font-size: .95rem;
    font-weight: 600;
    margin: 0;
}

.chatbot-status {
    font-size: .72rem;
    opacity: .85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, .2);
}

/* Body */
.chatbot-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}

.chatbot-body::-webkit-scrollbar { width: 4px; }
.chatbot-body::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 999px; }

/* Messages */
.chat-msg {
    display: flex;
    gap: 8px;
    animation: msgSlide .3s ease-out;
}

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

.chat-msg.bot { align-items: flex-start; }
.chat-msg.user { flex-direction: row-reverse; }

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
}

.chat-msg.bot .chat-msg-avatar {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
}

.chat-msg.user .chat-msg-avatar {
    background: #f3f4f6;
    color: #64748b;
}

.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: .88rem;
    line-height: 1.55;
}

.chat-msg.bot .chat-bubble {
    background: #f3f4f6;
    color: #334155;
    border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-bubble {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: .4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* Quick Replies */
.chatbot-quick-replies {
    padding: 0 16px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quick-reply-btn {
    padding: 6px 14px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 500;
    color: #6366f1;
    cursor: pointer;
    transition: all .2s;
    font-family: 'Inter', sans-serif;
}

.quick-reply-btn:hover {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
    transform: translateY(-1px);
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
}

.chatbot-input-area input {
    flex: 1;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-size: .88rem;
    color: #0f172a;
    outline: none;
    transition: border-color .2s;
}

.chatbot-input-area input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
}

.chatbot-input-area input::placeholder {
    color: #94a3b8;
}

#chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .2s;
    flex-shrink: 0;
}

#chatbot-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(99, 102, 241, .3);
}

/* Lead form inside chatbot */
.chatbot-lead-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.chatbot-lead-form input,
.chatbot-lead-form select {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: .82rem;
    color: #0f172a;
    outline: none;
    transition: border-color .2s;
}

.chatbot-lead-form input:focus,
.chatbot-lead-form select:focus {
    border-color: #6366f1;
}

.chatbot-lead-form button {
    padding: 8px 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.chatbot-lead-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, .3);
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-window {
        right: 12px;
        bottom: 140px;
        width: calc(100vw - 24px);
        max-height: 70vh;
    }

    .chatbot-trigger {
        bottom: 80px;
        right: 16px;
    }
}
