/**
 * AI Chat Widget - Gradient Glassmorphism
 * Premium corporate design with proactive suggestions
 */

#ai-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#ai-bubble img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

#ai-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 20px 50px rgba(30, 58, 138, 0.4);
}

#ai-bubble.attention {
    animation: aiBubbleAttention 2s ease-in-out 3;
}

@keyframes aiBubbleAttention {
    0%, 100% { transform: scale(1); box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 20px 50px rgba(37, 99, 235, 0.5); }
}

.pulse-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.35);
    animation: aiPulse 2.5s ease-out infinite;
    pointer-events: none;
}

@keyframes aiPulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.6); opacity: 0; }
}

#ai-chat {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 380px;
    height: 560px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    border: 1px solid rgba(255, 255, 255, 0.25);
    animation: aiChatSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#ai-chat.open {
    display: flex;
}

@keyframes aiChatSlideUp {
    from {
        transform: translateY(24px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.ai-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    flex-shrink: 0;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-avatar img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.ai-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.ai-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s;
    border-radius: 8px;
}

.ai-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.ai-suggestions {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.ai-suggestions span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 8px;
}

.suggestion {
    margin: 4px 4px 4px 0;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    background: rgba(15, 23, 42, 0.7);
    color: #fff;
    font-size: 12px;
    transition: all 0.2s ease;
}

.suggestion:hover {
    background: rgba(30, 58, 138, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

#ai-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(248, 250, 252, 0.5);
}

.message {
    margin-bottom: 0;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 88%;
    word-wrap: break-word;
}

.message.user {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    align-self: flex-end;
    margin-left: auto;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.message.bot {
    background: rgba(255, 255, 255, 0.75);
    color: #0f172a;
    align-self: flex-start;
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(4px);
}

.message.typing {
    font-style: italic;
    color: #64748b;
}

.ai-input {
    display: flex;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    gap: 10px;
    flex-shrink: 0;
}

#ai-input-field {
    flex: 1;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    outline: none;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#ai-input-field::placeholder {
    color: #94a3b8;
}

#ai-input-field:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

#ai-send {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

#ai-send:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.4);
}

#ai-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Conversion CTA block */
.cta-box {
    margin-top: 8px;
    padding: 14px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 88%;
    align-self: flex-start;
}

.cta-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(37, 99, 235, 0.9);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, transform 0.2s;
}

.cta-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.lead-form-box {
    margin-top: 8px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(15, 23, 42, 0.2);
    border-radius: 14px;
    max-width: 88%;
    align-self: flex-start;
}

.lead-form-title {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lead-input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}

.lead-input:focus {
    outline: none;
    border-color: #2563eb;
}

.lead-form-box .cta-btn {
    margin-top: 4px;
}

@media (max-width: 480px) {
    #ai-bubble {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    #ai-bubble img {
        width: 28px;
        height: 28px;
    }

    #ai-chat {
        bottom: 90px;
        right: 16px;
        left: 16px;
        width: auto;
        height: 75vh;
        max-height: 520px;
    }

    .message {
        max-width: 92%;
    }
}
