/* RAG AI Chatbot Stylesheet */

#rag-ai-chat-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

#rag-ai-chat-container * {
    box-sizing: border-box !important;
}

/* Floating Bubble Button */
#rag-ai-chat-bubble {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c92127 0%, #a8171c 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(201, 33, 39, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
    outline: none;
    padding: 0;
    overflow: hidden;
}

#rag-ai-chat-bubble.rag-ai-has-custom-icon {
    background: transparent !important;
    box-shadow: none !important;
}

#rag-ai-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(201, 33, 39, 0.45);
}

#rag-ai-chat-bubble:active {
    transform: scale(0.95);
}

/* Chat Window */
#rag-ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(238, 238, 238, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: height 0.3s ease, opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform-origin: bottom right;
    opacity: 1;
    transform: scale(1) translateY(0);
}

#rag-ai-chat-window.rag-ai-has-recommendations {
    height: 610px;
}

/* Hidden state for transition */
#rag-ai-chat-window.rag-ai-chat-hidden {
    opacity: 0;
    transform: scale(0.8) translateY(40px);
    pointer-events: none;
}

/* Header */
.rag-ai-chat-header {
    background: #23282d;
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.rag-ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rag-ai-chat-header-banner {
    position: absolute;
    top: -30px;
    left: 0;
    width: 100%;
    height: auto;
    z-index: 1;
    pointer-events: none;
    display: block;
}

.rag-ai-chat-header.rag-ai-has-header-image {
    height: 60px;
    padding: 0;
    position: relative;
    overflow: visible;
    background: transparent !important;
    border-bottom: none;
}

.rag-ai-has-header-image .rag-ai-chat-header-actions {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: transparent !important;
    border: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rag-ai-has-header-image .rag-ai-chat-header-actions button {
    color: #ffffff !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.rag-ai-has-header-image .rag-ai-chat-header-actions button:hover {
    color: #eeeeee !important;
}

.rag-ai-chat-header.rag-ai-has-header-image + #rag-ai-chat-messages {
    padding-top: 70px;
}

.rag-ai-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #c92127;
    color: #fff;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(201, 33, 39, 0.3);
}

.rag-ai-chat-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.rag-ai-chat-status {
    font-size: 11px;
    color: #46b450;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.rag-ai-chat-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #46b450;
}

.rag-ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#rag-ai-chat-reset, #rag-ai-chat-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.15s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#rag-ai-chat-reset {
    font-size: 16px;
}

#rag-ai-chat-close {
    font-size: 24px;
}

#rag-ai-chat-reset:hover {
    color: #fff;
    transform: rotate(-45deg);
}

#rag-ai-chat-close:hover {
    color: #fff;
    transform: scale(1.1);
}

/* Messages List */
#rag-ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafa;
}

/* Message Bubble */
.rag-ai-message {
    display: flex;
    max-width: 85%;
}

.rag-ai-message.rag-ai-user {
    align-self: flex-end;
}

.rag-ai-message.rag-ai-bot {
    align-self: flex-start;
}

.rag-ai-message-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    word-break: break-word;
    font-size: 13.5px;
    line-height: 1.45;
}

.rag-ai-user .rag-ai-message-bubble {
    background: #c92127;
    color: #fff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 6px rgba(201, 33, 39, 0.15);
}

.rag-ai-bot .rag-ai-message-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 2px;
    border: 1px solid #eef0f2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.rag-ai-message-bubble a {
    color: #c92127;
    text-decoration: underline;
    font-weight: 500;
}

.rag-ai-message-bubble a:hover {
    color: #a8171c;
}

/* Typing Indicator */
.rag-ai-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 6px;
    align-items: center;
    justify-content: center;
}

.rag-ai-typing-indicator span {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: ragAiTyping 1.4s infinite ease-in-out both;
}

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

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

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

/* Input Form */
#rag-ai-chat-input-form {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

#rag-ai-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 8px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s;
    background: #fdfdfd;
}

#rag-ai-chat-input:focus {
    border-color: #c92127;
    background: #fff;
}

#rag-ai-chat-send {
    background: #c92127;
    color: #fff;
    border: none;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    padding: 0 !important;
    box-shadow: 0 2px 8px rgba(201, 33, 39, 0.25);
    flex-shrink: 0;
}

#rag-ai-chat-send:hover {
    background: #a8171c;
}

#rag-ai-chat-send:active {
    transform: scale(0.9);
}

/* Mobile Responsiveness */
@media (max-width: 450px) {
    #rag-ai-chat-container {
        bottom: 20px;
        right: 20px;
    }
    #rag-ai-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        max-height: 480px;
    }
    #rag-ai-chat-window.rag-ai-has-recommendations {
        max-height: 560px;
        height: calc(100vh - 120px);
    }
    .rag-ai-chat-welcome-bubble {
        display: none !important; /* Hide welcome bubble on mobile to avoid screen clutter */
    }
}

/* Welcome Bubble */
.rag-ai-chat-welcome-bubble {
    position: absolute;
    bottom: 20px;
    right: 95px;
    width: 260px;
    background: #fff;
    color: #333;
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #eef0f2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.3s, transform 0.3s;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 500;
    z-index: 999998;
}
.rag-ai-chat-welcome-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}
.rag-ai-chat-welcome-bubble.rag-ai-chat-hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}
.rag-ai-chat-welcome-text {
    flex: 1;
    pointer-events: none; /* Make clicking the text open the chat */
}
.rag-ai-chat-welcome-close {
    background: transparent;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.15s;
    flex-shrink: 0;
}
.rag-ai-chat-welcome-close:hover {
    color: #333;
}
.rag-ai-chat-welcome-bubble::after {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 34px;
    width: 10px;
    height: 10px;
    background: #fff;
    border-right: 1px solid #eef0f2;
    border-top: 1px solid #eef0f2;
    transform: rotate(45deg);
}

/* Product Recommendations Bar (Horizontal) */
#rag-ai-chat-recommendations-bar {
    padding: 10px 16px;
    background: #ffffff;
    border-top: 1px solid #eee;
    display: flex;
    overflow-x: auto;
    gap: 10px;
    align-items: center;
    max-width: 100%;
    flex-shrink: 0;
}

#rag-ai-chat-recommendations-bar::-webkit-scrollbar {
    height: 4px;
}
#rag-ai-chat-recommendations-bar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.rag-ai-rec-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 110px;
    min-width: 110px;
    padding: 8px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fff;
    text-decoration: none !important;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.rag-ai-rec-box:hover {
    border-color: #c92127;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(201, 33, 39, 0.1);
}
.rag-ai-rec-box-thumb {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    margin-bottom: 6px;
    border: 1px solid #eee;
}
.rag-ai-rec-box-thumb-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background: #f0f0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}
.rag-ai-rec-box-title {
    font-size: 11px;
    font-weight: 600;
    color: #333 !important;
    margin: 0 0 2px 0;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.rag-ai-rec-box-price {
    font-size: 11px;
    font-weight: 700;
    color: #c92127 !important;
    margin: 0;
    text-align: center;
}

/* Image Upload Preview and styling */
#rag-ai-chat-image-preview-container {
    padding: 8px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}
#rag-ai-chat-image-preview {
    max-height: 50px;
    max-width: 80px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #ddd;
}
#rag-ai-chat-image-remove {
    position: absolute;
    top: 2px;
    left: 82px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    padding: 0;
}
#rag-ai-chat-image-remove:hover {
    background: rgba(0, 0, 0, 0.8);
}
#rag-ai-chat-image-label {
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
    flex-shrink: 0;
}
#rag-ai-chat-image-label:hover {
    color: #c92127;
}
.rag-ai-user-image-msg {
    margin-bottom: 6px;
}

/* Quick Replies Area */
#rag-ai-chat-quick-replies {
    padding: 10px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}
.rag-ai-quick-reply-btn {
    background: #f1f3f5;
    border: 1px solid #dcdfe3;
    color: #495057;
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 550;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    outline: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.rag-ai-quick-reply-btn:hover {
    background: #c92127;
    border-color: #c92127;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(201, 33, 39, 0.15);
}
.rag-ai-quick-reply-btn:active {
    transform: translateY(0);
}

