#ai-chatbot-widget {
    position: fixed;
    bottom: 60px;
    right: 25px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

#ai-chatbot-btn {
    width: 60px;
    height: 60px;
    background-color: #16A34A; /* Fallback color */
    background-image: url('../page-medias/allplastix-ai-chatbot/ai-bot.jpg');
    background-size: 160%;
    background-position: center 15%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: head-shake 3s infinite ease-in-out, pulse-glow 2s infinite;
}

@keyframes head-shake {
    0%, 100% {
        transform: rotate(0deg);
    }
    10%, 30% {
        transform: rotate(-12deg);
    }
    20%, 40% {
        transform: rotate(12deg);
    }
    50%, 90% {
        transform: rotate(0deg);
    }
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(99, 102, 241, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

#ai-chatbot-btn:hover {
    transform: scale(1.1) rotate(0deg);
    animation: none; /* Stop pulsing on hover */
}

#ai-chatbot-btn i {
    pointer-events: none;
    display: none;
}
#ai-chatbot-btn.fallback-icon i {
    display: inline-block;
}

#ai-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    height: 500px;
    max-height: calc(100vh - 150px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border: 1px solid #e5e7eb;
}

#ai-chatbot-window.open {
    transform: scale(1);
    opacity: 1;
}

.chatbot-header {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    padding: 1rem 1.25rem;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header h3 {
    margin: 0;
    font-size: clamp(0.85rem, 1.8vh, 1rem);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chatbot-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: clamp(1rem, 2.5vh, 1.15rem);
    cursor: pointer;
    transition: color 0.2s;
}

.chatbot-close:hover {
    color: #fff;
}

.chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: clamp(0.75rem, 2vh, 1.25rem);
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-msg {
    max-width: 85%;
    padding: clamp(0.5rem, 1.5vh, 0.75rem) clamp(0.75rem, 2vh, 1rem);
    border-radius: 12px;
    font-size: clamp(0.75rem, 1.6vh, 0.85rem);
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg.model {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #374151;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    background: #4f46e5;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-footer {
    padding: clamp(0.6rem, 1.5vh, 1rem);
    background: #fff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.5rem;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 0.5rem 0.85rem;
    outline: none;
    font-size: clamp(0.75rem, 1.6vh, 0.85rem);
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: #6366f1;
}

.chatbot-send {
    background: #6366f1;
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.chatbot-send:hover {
    background: #4f46e5;
}

.chatbot-send:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@media (max-width: 480px) {
    #ai-chatbot-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        z-index: 10000;
        border: none;
    }
}
