/* RAG Chatbot Widget Styles */

.rag-chatbot-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Position variants */
.rag-chatbot-widget[data-position="bottom-right"] {
    bottom: 20px;
    right: 20px;
}

.rag-chatbot-widget[data-position="bottom-left"] {
    bottom: 20px;
    left: 20px;
}

.rag-chatbot-widget[data-position="top-right"] {
    top: 20px;
    right: 20px;
}

.rag-chatbot-widget[data-position="top-left"] {
    top: 20px;
    left: 20px;
}

/* Chatbot Button */
.rag-chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--rag-primary-color, #1fac5e);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.rag-chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.rag-chatbot-button svg {
    width: 28px;
    height: 28px;
}

/* Hide button when chat is open */
.rag-chatbot-widget.chat-open .rag-chatbot-button {
    display: none;
}

/* Chatbot Container */
.rag-chatbot-container {
    display: none;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    position: absolute;
    bottom: 0;
    right: 0;
    overflow: hidden;
}

.rag-chatbot-widget[data-position="bottom-left"] .rag-chatbot-container {
    left: 0;
    right: auto;
}

.rag-chatbot-widget[data-position="top-right"] .rag-chatbot-container,
.rag-chatbot-widget[data-position="top-left"] .rag-chatbot-container {
    bottom: auto;
    top: 0;
}

.rag-chatbot-container.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.rag-chatbot-header {
    background: var(--rag-primary-color, #1fac5e);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.header-text p {
    margin: 4px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.rag-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.rag-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Reset Topic Button */
.btn-reset-topic {
    display: none;
    background: rgba(31, 172, 94, 0.1);
    color: #1fac5e;
    border: 1.5px solid rgba(31, 172, 94, 0.3);
    border-radius: 8px;
    padding: 8px 16px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin: 12px 16px 0;
}

.btn-reset-topic.visible {
    display: block;
}

.btn-reset-topic:hover {
    background: rgba(31, 172, 94, 0.15);
    border-color: rgba(31, 172, 94, 0.5);
}

/* Messages Area */
.rag-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.rag-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.rag-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.rag-chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.rag-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Message Bubbles */
.rag-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.message-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #aaa;
    margin-bottom: 4px;
    padding: 0 4px;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
}

.rag-message.bot .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-radius: 12px 12px 12px 4px;
}

.rag-message.user .message-bubble {
    background: var(--rag-primary-color, #1fac5e);
    color: white;
    border-radius: 12px 12px 4px 12px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

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

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-8px);
    }
}

/* Input Area */
.rag-chatbot-input-area {
    display: flex;
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 8px;
}

.rag-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.rag-chatbot-input:focus {
    border-color: var(--rag-primary-color, #1fac5e);
}

.rag-chatbot-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.rag-chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--rag-primary-color, #1fac5e);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.rag-chatbot-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.rag-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Error Message */
.error-message {
    background: #fee;
    color: #c33;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .rag-chatbot-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 10px;
        right: 10px;
    }
    
    .rag-chatbot-widget[data-position="bottom-left"] .rag-chatbot-container {
        left: 10px;
        right: auto;
    }
    
    .rag-chatbot-button {
        width: 56px;
        height: 56px;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 13px;
    }
}
