/* Chatbot Container */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000001;
    /* Higher than any theme element or preloader */
    font-family: 'Inter', sans-serif;
    pointer-events: auto !important;
}

#chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F57D1C, #FFD700);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.3s;
}

#chatbot-button:hover {
    transform: scale(1.1);
}

#chatbot-window {
    width: 350px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: none;
    /* Initially hidden */
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
    transition: all 0.3s ease;
    z-index: 1000001;
}

#chatbot-window.show {
    display: flex !important;
}

#chatbot-header {
    background: #F57D1C;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

#chatbot-messages {
    flex: 1 1 0%;
    /* Ensure it shrinks and grows correctly within fixed parent */
    height: 0;
    /* Force flex to determine height */
    padding: 15px;
    overflow-y: auto !important;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;
    /* Prevent scroll bubbling to underlying page */
    overscroll-behavior: contain;
    /* Custom Scrollbar for modern browsers */
    scrollbar-width: thin;
    scrollbar-color: #F57D1C #f1f1f1;
    -webkit-overflow-scrolling: touch;
}

#chatbot-messages::-webkit-scrollbar {
    width: 8px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background-color: #F57D1C;
    border-radius: 10px;
    border: 2px solid #f1f1f1;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background-color: #d96a15;
}

.chat-message {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.chat-message.bot {
    background: #ffffff;
    align-self: flex-start;
    border: 1px solid #eee;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chat-message.user {
    background: #F57D1C;
    color: white;
    align-self: flex-end;
}


#chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    font-size: 14px;
}

#chatbot-send {
    background: #F57D1C;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

#chatbot-send:hover {
    background: #d96a15;
}

/* Typing Indicator */
.typing-indicator {
    background-color: #f1f1f1;
    padding: 10px 15px;
    border-radius: 15px;
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
    margin-left: 15px;
    /* Align with messages since it's now outside the padded messages box */
}

#chatbot-input-container {
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    background: white;
    margin-top: auto;
    /* Push to bottom of flex container */
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: #888;
    border-radius: 50%;
    animation: typing 1s infinite alternate;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    from {
        opacity: 0.3;
        transform: translateY(0);
    }

    to {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #chatbot-window {
        width: 90vw;
        height: 70vh;
        right: -10px;
        bottom: 75px;
    }
}

/* Product Card in Chat */
.chatbot-product {
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 12px;
    margin-top: 10px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.chatbot-product img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 8px;
}

.chatbot-product h4 {
    margin: 10px 0 5px;
    font-size: 14px;
    color: #333;
}

.chatbot-product .price {
    font-weight: bold;
    color: #F57D1C;
    margin-bottom: 12px;
    display: block;
    font-size: 16px;
}

.chatbot-product button {
    background: #F57D1C;
    color: white;
    border: none;
    padding: 7px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    width: 100%;
    margin-top: 5px;
    transition: background 0.2s;
}

.chatbot-product button:hover {
    background: #d96a15;
}

.chatbot-product button.view-details {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
    margin-top: 8px;
}

.chatbot-product button.view-details:hover {
    background: #e2e6ea;
}