/* Toggle Button PC */
#ai-chatbot-toggle {
    position: fixed;
    bottom: 500px;
    right: 10px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#ai-chatbot-toggle.hidden {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

#ai-chatbot-toggle.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#ai-chatbot-toggle img {
    width: 80%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

#ai-chatbot-toggle:hover img {
    transform: scale(1.1) rotate(5deg);
}

/* Chatbox Container */
#ai-chatbot-box {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    max-height: 80%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    overflow: hidden;
    flex-direction: column;
    font-family: Arial, sans-serif;
    z-index: 9998;
    flex-direction: column;
}

#ai-chatbot-box.active {
    display: flex;
}

/* Chatbox Header */
#ai-chatbot-box .chatbot-header {
    background: #007aff;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: 15px;
    font-weight: 600;
}

#ai-chatbot-box .chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

#ai-chatbot-box .chatbot-header-left img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: contain;
    background: #fff;
    padding: 2px;
}

.chatbox-actions {
    display: flex;
    gap: 6px;
}

.chatbox-actions > div {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chatbox-actions .chat-icon-btn {
    width: 20px;
    height: 20px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.chatbox-actions > div:hover .chat-icon-btn {
    transform: scale(1.2);
}

/* Chat Content */
#ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f9f9f9;
    min-height: 400px;
    scroll-behavior: smooth;
}

/* User Message */
#ai-chatbot-messages .user {
    text-align: right;
    background: #d9f0ff;
    padding: 8px 12px;
    margin: 6px 0;
    border-radius: 8px;
    display: inline-block;
    max-width: 80%;
    float: right;
    clear: both;
}

/* Bot Message Container */
#ai-chatbot-messages .bot {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    clear: both;
    margin: 6px 0;
}

#ai-chatbot-messages .bot .bot-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.bot-content {
    background: #fff;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

/* Typing dots layout (Bot side) */
.bot.typing .bot-content .typing-dots {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.typing-dots .dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #333;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}

.typing-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}

/* Typing Text Effect */
.typing-effect {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 14px;
}

.cursor {
    display: inline-block;
    width: 2px;
    background: #007aff;
    animation: blinkCursor 0.8s infinite;
}

@keyframes blinkCursor {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

/* Input box */
#ai-chatbot-input-area {
    padding: 10px;
    display: flex;
    gap: 6px;
    border-top: 1px solid #ddd;
}

#ai-chatbot-input {
    flex: 1;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

#ai-chatbot-send {
    padding: 6px 12px;
    background: #007aff;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Product Grid */
.bot-content:has(.product-list) {
    max-width: 100%;
    width: 100%;
    padding: 0;
    background: transparent;
    border: none;
}

.bot-content .product-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.bot-content .product-item img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    margin-bottom: 5px;
}

.product-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 13px;
}

.product-item .title {
    font-weight: bold;
    font-size: 13px;
    min-height: 36px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin-bottom: 4px;
}

.product-item .price {
    color: #d10000;
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 14px;
}

.product-item .btn {
    display: inline-block;
    margin: 2px 0;
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 4px;
    text-decoration: none;
    color: #fff;
    background: #007aff;
    cursor: pointer;
    transition: 0.2s;
}

.product-item .btn.add { background: #28a745; }
.product-item .btn:hover { opacity: 0.85; }

/* Mobile button in footer */
@media screen and (max-width: 767px) {
    #ai-chatbot-toggle {
        display: none;
    }
    .chatbot-mobile-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        font-weight: bold;
        color: #007aff;
    }
    .chatbot-mobile-btn .icon.main-icon-chat {
        background-image: url('../assets/chatbot-icon.png');
        width: 35px;
        height: 35px;
        background-size: contain;
        background-repeat: no-repeat;
        display: inline-block;
    }
}
