:root {
    --wp-ai-primary: #0073aa;
}

#ai-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 4px;
    font-family: Arial, sans-serif;
    z-index: 999999;
}

#ai-chatbot-header {
    background: var(--wp-ai-primary);
    color: #fff;
    padding: 15px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#ai-chatbot-clear {
    font-size: 16px;
    transition: transform 0.3s ease;
}

#ai-chatbot-clear:hover {
    transform: rotate(180deg);
}

#ai-chatbot-body {
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    border-radius: 0 0 4px 4px;
    animation: slideUpChat 0.3s ease-out forwards;
}

#ai-chatbot-messages {
    height: 300px;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bot-message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    align-self: flex-start;
    max-width: 92%;
}

.bot-avatar {
    width: 28px;
    height: 28px;
    background-color: var(--wp-ai-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.bot-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.bot-message-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0; /* Khắc phục lỗi Flexbox bị phình to */
    max-width: 100%;
}

.bot-name {
    font-size: 11px;
    color: #888;
    margin-left: 2px;
}

.bot-product-img {
    max-width: 100%;
    border-radius: 8px;
    margin: 5px 0;
    display: block;
}

.bot-product-link {
    color: var(--wp-ai-primary);
    text-decoration: underline;
}

/* Giao diện Carousel Sản phẩm trượt ngang */
.bot-carousel-container {
    width: 100%;
    min-width: 120px; 
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
    margin-top: 10px;
    -webkit-overflow-scrolling: touch; /* Cho phép vuốt mượt trên điện thoại */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #b0bec5 transparent;
}
/* Hiển thị lại thanh cuộn ngang mỏng, tinh tế cho Chrome/Safari */
.bot-carousel-container::-webkit-scrollbar {
    height: 6px;
    display: block;
}
.bot-carousel-container::-webkit-scrollbar-track {
    background: transparent;
}
.bot-carousel-container::-webkit-scrollbar-thumb {
    background-color: #b0bec5;
    border-radius: 10px;
}
.bot-carousel-container::-webkit-scrollbar-thumb:hover {
    background-color: #90a4ae;
}
.bot-carousel {
    display: flex;
    gap: 10px;
    width: max-content; /* Đảm bảo các sản phẩm không bị ép co lại */
    padding-right: 5px; /* Tránh sản phẩm cuối bị dính sát lề */
}
.bot-carousel-item {
    flex: 0 0 130px; /* Độ rộng cố định cho thẻ sản phẩm */
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none !important;
    color: #333 !important;
}
.bot-carousel-item img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    margin: 0 !important;
}
.bot-carousel-title {
    font-size: 11px;
    padding: 6px;
    text-align: center;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
}

.bot-message, .user-message {
    padding: 10px;
    border-radius: 12px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    min-width: 0; 
    max-width: 100%;
}

.bot-message {
    background: #e1f5fe;
    color: #0277bd;
    border-bottom-left-radius: 2px; 
}

.user-message {
    background: var(--wp-ai-primary);
    color: #fff;
    align-self: flex-end;
    max-width: 92%;
    border-bottom-right-radius: 2px;
}

#ai-chatbot-input-area {
    display: flex;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #ddd;
    border-radius: 0;
}

#ai-chatbot-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    outline: none;
    font-size: 16px !important; 
}

#ai-chatbot-send {
    background: var(--wp-ai-primary);
    color: #fff;
    border: none;
    padding: 8px 12px;
    margin-left: 5px;
    border-radius: 4px;
    cursor: pointer;
}

#ai-chatbot-send:hover {
    filter: brightness(0.85);
}

.wp-ai-bot-footer-text {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    text-align: center;
    font-size: 11px;
    color: #999;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    border-radius: 0 0 4px 4px;
}
.wp-ai-bot-footer-text a {
    color: #FF7A18;
    text-decoration: none;
    font-weight: 600;
}
.bot-branding a:hover {
    text-decoration: underline;
}

/* Hiệu ứng dấu ba chấm đang gõ */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 5px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--wp-ai-primary);
    border-radius: 50%;
    animation: typing-blink 1.4s infinite both;
}

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

@keyframes typing-blink {
    0%, 80%, 100% {
        opacity: 0.2;
    }
    40% {
        opacity: 1;
    }
}

/* Hiệu ứng trượt lên cho khung chat */
@keyframes slideUpChat {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Gợi ý câu hỏi nhanh (Quick Replies) */
.quick-replies-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}

.quick-reply-btn {
    background: #fff;
    border: 1px solid var(--wp-ai-primary);
    color: var(--wp-ai-primary);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.quick-reply-btn:hover {
    background: var(--wp-ai-primary);
    color: #fff;
}

/* Nút Zalo tiết kiệm API */
.zalo-btn {
    border-color: #0068ff !important;
    color: #0068ff !important;
}

.zalo-btn:hover {
    background-color: #0068ff !important;
    color: #fff !important;
}

/* Chấm đỏ thông báo (Notification Badge) */
.chat-badge {
    background-color: #ff3b30;
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -6px;
    left: 12px;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(255, 59, 48, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

/* Giao diện dành riêng cho điện thoại (Mobile) */
@media screen and (max-width: 768px) {
    #ai-chatbot-container {
        width: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0; /* Xóa bo góc để sát viền màn hình */
    }
    #ai-chatbot-header {
        border-radius: 0;
    }
    #ai-chatbot-body {
        border-radius: 0;
        border: none;
        padding-bottom: env(safe-area-inset-bottom);
    }
    #ai-chatbot-messages {
        /* Tính toán tự động: Chiều cao màn hình trừ đi phần Header và Khung nhập liệu */
        height: calc(100vh - 125px);
        height: calc(100dvh - 125px); 
        max-height: none;
    }
    #ai-chatbot-input-area {
        border-radius: 0;
    }
    .wp-ai-bot-footer-text {
        border-radius: 0;
    }
}



