/* =========================================
   Rekha's List - Premium AI Chat Widget UI
========================================= */

/* Floating Action Button (FAB) */
#ragChatButton {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border: 0;
    padding: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
    z-index: 9999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#ragChatButton:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.5);
}

#ragChatButton svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* Chat Window Container */
#ragChatWindow {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 380px;
    height: 560px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0,0,0,0.2);
    display: none; /* Flex when open */
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: inherit;
    border: 1px solid #f1f5f9;
}

#ragChatWindow.open {
    display: flex;
    animation: slideUpFade 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(20px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.rag-header {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #ffffff;
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 2;
}

.rag-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rag-header__icon {
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rag-header__icon svg {
    width: 14px;
    height: 14px;
    fill: #ffffff;
}

.rag-header__title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.rag-header__close {
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    width: 44px;
    height: 44px;
    margin: -10px -12px -10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rag-header__close:hover {
    opacity: 1;
}
.rag-header__close svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* Message Area */
#ragChatMessages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f8fafc;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar styling */
#ragChatMessages::-webkit-scrollbar {
    width: 6px;
}
#ragChatMessages::-webkit-scrollbar-track {
    background: transparent;
}
#ragChatMessages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
#ragChatMessages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Chat Rows & Bubbles */
.chat-row {
    display: flex;
    max-width: 100%;
}

.chat-user {
    justify-content: flex-end;
}

.chat-ai {
    justify-content: flex-start;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-user .chat-bubble {
    background: #2563eb;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    max-width: 80%;
}

/* AI Bubble becomes a transparent wrapper. The elements inside it will provide the styling! */
.chat-ai .chat-bubble {
    background: transparent;
    color: inherit;
    border: none;
    box-shadow: none;
    max-width: 95%;
    padding: 0;
    white-space: normal;
}

/* Typing Dots */
.typing-dots {
    display: inline-block;
    padding: 14px 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    color: #64748b;
    font-size: 24px;
    line-height: 0.5;
}
.typing-dots span { animation: blink 1.4s infinite both; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Input Area (Pill-Shaped) */
.rag-input-area {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.rag-input-wrapper {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 24px;
    padding: 4px 6px 4px 16px;
    border: 1px solid #e2e8f0;
    transition: border-color 0.2s, background 0.2s;
}

.rag-input-wrapper:focus-within {
    border-color: #93c5fd;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.rag-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    outline: none;
    font-size: 14px;
    color: #1e293b;
}

.rag-input-wrapper input::placeholder {
    color: #475569;
}

.rag-send-btn {
    width: 44px;
    height: 44px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.rag-send-btn:hover {
    background: #1d4ed8;
}

.rag-send-btn:active {
    transform: scale(0.95);
}

.rag-send-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    margin-left: -2px; /* optical alignment for paper plane */
}

/* =========================
   RAG Output Cards
========================= */
.rag-narrative {
    font-size: 14px;
    color: #1e293b;
    margin-bottom: 12px;
    line-height: 1.5;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: inline-block;
}

.rag-result-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.rag-result-card:last-child {
    margin-bottom: 0;
}
.rag-result-card__header {
    margin-bottom: 10px;
}
.rag-result-card__name {
    display: block;
    font-weight: 600;
    color: #1d4ed8;
    text-decoration: none;
    font-size: 15px;
    margin-bottom: 8px;
    line-height: 1.3;
}
.rag-result-card__name:hover {
    text-decoration: underline;
    color: #2563eb;
}
.rag-result-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.rag-badge {
    background: #f1f5f9;
    color: #334155;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid #e2e8f0;
}
.rag-badge--category { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.rag-badge--location { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.rag-badge--low-cost { background: #fef9c3; color: #854d0e; border-color: #fef08a; }
.rag-badge--sunday   { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }

.rag-result-card__description {
    font-size: 13px;
    color: #475569;
    margin: 10px 0;
    line-height: 1.5;
    white-space: normal;
}
.rag-result-card__match-hint {
    font-size: 12px;
    color: #475569;
    margin: 0;
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid #f1f5f9;
}
.rag-no-results {
    font-size: 14px;
    color: #475569;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: inline-block;
}
