/* RAG PDF Chatbot - Frontend Styles */
.rag-chatbot-wrap {
    display: flex;
    flex-direction: column;
    background: #0f0f18;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(99,179,237,0.15);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    max-width: 480px;
    margin: 0 auto 24px;
    height: 520px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

/* Header */
.rag-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-bottom: 1px solid rgba(99,179,237,0.12);
    flex-shrink: 0;
}
.rag-header-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.rag-header-info { flex: 1; min-width: 0; }
.rag-header-title {
    display: block;
    font-weight: 700; font-size: 14px; color: #e8e8f0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rag-status {
    display: flex; align-items: center; gap: 5px;
    font-size: 10px; color: #63b3ed; margin-top: 2px;
}
.rag-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #48bb78; box-shadow: 0 0 5px #48bb78;
    display: inline-block;
}

.rag-doc-selector {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(99,179,237,0.2);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 11px; padding: 4px 8px;
    max-width: 140px;
}

/* Messages */
.rag-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: #2d2d3e transparent;
}
.rag-messages::-webkit-scrollbar { width: 4px; }
.rag-messages::-webkit-scrollbar-thumb { background: #2d2d3e; border-radius: 4px; }

.rag-msg { display: flex; }
.rag-msg-user { justify-content: flex-end; }
.rag-msg-bot  { justify-content: flex-start; }

.rag-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}
.rag-msg-user .rag-bubble {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.rag-msg-bot .rag-bubble {
    background: #1e1e2e;
    color: #e2e8f0;
    border: 1px solid rgba(99,179,237,0.1);
    border-bottom-left-radius: 4px;
}
.rag-source {
    display: block; margin-top: 8px;
    color: #63b3ed; font-size: 11px;
    border-top: 1px solid rgba(99,179,237,0.15);
    padding-top: 6px;
}

/* Thinking animation */
.rag-thinking { display: inline-flex; gap: 4px; align-items: center; }
.rag-thinking span {
    width: 6px; height: 6px; border-radius: 50%;
    background: #667eea; display: inline-block;
    animation: ragBounce 1.2s infinite ease-in-out;
}
.rag-thinking span:nth-child(2) { animation-delay: .2s; }
.rag-thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes ragBounce {
    0%,80%,100% { transform: translateY(0); opacity: .4; }
    40%         { transform: translateY(-5px); opacity: 1; }
}

/* Input */
.rag-input-area {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 8px 12px 10px;
    background: #13131f;
    border-top: 1px solid rgba(99,179,237,0.1);
    flex-shrink: 0;
}
.rag-input {
    flex: 1;
    background: #1e1e2e;
    border: 1px solid rgba(99,179,237,0.2);
    border-radius: 18px;
    color: #e2e8f0;
    font-size: 13px;
    padding: 9px 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    max-height: 90px;
    overflow-y: auto;
    transition: border-color .2s;
}
.rag-input:focus { border-color: rgba(102,126,234,.5); }
.rag-input::placeholder { color: #4a5568; }
.rag-input:disabled { opacity: .5; cursor: not-allowed; }

.rag-send-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none; color: #fff; font-size: 16px;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity .2s, transform .1s;
}
.rag-send-btn:hover  { transform: scale(1.05); }
.rag-send-btn:active { transform: scale(.95); }
.rag-send-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Upload area */
.rag-upload-area {
    padding: 6px 12px 8px;
    background: #13131f;
    border-top: 1px solid rgba(99,179,237,0.06);
    display: flex; align-items: center; gap: 10px;
}
.rag-upload-label {
    font-size: 12px; color: #63b3ed; cursor: pointer;
    padding: 4px 10px;
    border: 1px dashed rgba(99,179,237,0.3);
    border-radius: 8px;
    transition: background .2s;
}
.rag-upload-label:hover { background: rgba(99,179,237,0.08); }

/* Mobile */
@media (max-width: 520px) {
    .rag-chatbot-wrap { border-radius: 0; max-width: 100%; }
}
