.ai-widget {
    position: fixed;
    bottom: 0;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    /* Allow clicking through empty widget areas */
}

.ai-trigger {
    width: 160px;
    height: 200px;
    cursor: pointer;
    transition: all 0.4s var(--ease-out-expo);
    background-image: url('engineer_avatar.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    z-index: 10001;
    mix-blend-mode: screen;
    pointer-events: auto;
    border: none !important;
    background-color: transparent !important;
    margin-bottom: -25px;
    /* Sink deeper for better floating effect */
    position: relative;
}

.engineer-invite {
    position: absolute;
    right: 150px;
    bottom: 90px;
    background: white;
    /* Solid background for visibility */
    color: var(--primary);
    /* Contrast text */
    padding: 10px 16px;
    border-radius: 18px;
    border-bottom-right-radius: 2px;
    font-size: 0.75rem;
    font-weight: 800;
    width: 150px;
    text-align: center;
    line-height: 1.3;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    animation: floatingInvite 4s ease-in-out infinite;
    border: 2px solid var(--primary);
}

@keyframes floatingInvite {

    0%,
    100% {
        transform: translateY(0) translateX(0);
    }

    50% {
        transform: translateY(-10px) translateX(-5px);
    }
}

.ai-trigger svg {
    display: none !important;
}

.ai-trigger:hover {
    transform: translateY(-5px) scale(1.02);
}

.ai-chat-window {
    width: 310px;
    height: 380px;
    /* Reduced height as requested */
    background: var(--surface-high);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    margin-bottom: -10px;
    /* Lower position */
    margin-right: -0.5rem;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(30px);
    pointer-events: auto;
}

.ai-chat-window.active {
    display: flex;
    animation: chatOpen 0.5s var(--ease-out-expo);
}

@keyframes chatOpen {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-header {
    background: var(--surface-high);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-glass);
}

.ai-avatar {
    width: 45px;
    height: 45px;
    background-color: var(--primary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid white;
    background-image: url('engineer_avatar.png');
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.ai-msg-container {
    display: flex;
    gap: 12px;
    margin-bottom: 1.5rem;
    animation: slideUp 0.4s var(--ease-out-expo);
    align-self: flex-start;
    max-width: 90%;
}

.msg-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-left: 42px;
    /* Align with text */
}

.quick-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-dim);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
}

@keyframes pulseOpacity {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 0.3;
    }
}

#aiTyping .message {
    font-style: italic;
    font-size: 0.9rem;
    color: var(--text-dim);
    animation: pulseOpacity 1.5s infinite ease-in-out;
    background: transparent;
    border: none;
    box-shadow: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-image: url('engineer_avatar.png');
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-glass);
    flex-shrink: 0;
    mix-blend-mode: screen;
    /* Transparency for avatar too */
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.msg-ai {
    background: var(--surface-high);
    color: var(--text-white);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.msg-user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    padding: 1rem;
    background: var(--surface-med);
    border-top: 1px solid var(--border-glass);
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    background: var(--surface-high);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    padding: 8px 12px;
    color: white;
    font-size: 0.85rem;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

.chat-send {
    background: var(--primary);
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    color: white;
    font-weight: 700;
}

/* Mobile Optimization for Chatbot */
@media (max-width: 768px) {
    .ai-widget {
        right: 0.8rem;
        bottom: -5px;
    }

    .ai-trigger {
        width: 65px;
        /* Tiny */
        height: 75px;
        margin-bottom: -5px;
    }

    .engineer-invite {
        right: 60px;
        bottom: 45px;
        width: 90px;
        font-size: 0.55rem;
        padding: 6px 10px;
        line-height: 1.2;
    }

    .ai-chat-window {
        width: 260px;
        height: 320px;
        right: 0;
        bottom: 80px;
    }
}