/**
 * RAG 챗봇 UI 스타일
 * Author: Claude Code
 * Date: 2026-01-16
 */

/* 챗봇 컨테이너 - 오른쪽 하단 고정 */
.rag-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 최소화 버튼 (챗봇 아이콘) */
.rag-chatbot-minimized {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

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

.rag-chatbot-minimized i {
    color: white;
    font-size: 28px;
}

/* 펄스 애니메이션 */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }
}

/* 확장된 챗봇 */
.rag-chatbot-expanded {
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* 헤더 */
.rag-chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rag-chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.rag-chatbot-header-title i {
    font-size: 20px;
}

.rag-chatbot-minimize-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.rag-chatbot-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 메시지 영역 */
.rag-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f7f8fa;
}

/* 스크롤바 스타일 */
.rag-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* 메시지 아이템 */
.rag-chatbot-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-chatbot-message.user {
    align-items: flex-end;
}

.rag-chatbot-message.user .rag-chatbot-message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

/* AI 메시지 */
.rag-chatbot-message.ai {
    align-items: flex-start;
}

.rag-chatbot-message.ai .rag-chatbot-message-bubble {
    background: white;
    color: #2d3748;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 메시지 버블 */
.rag-chatbot-message-bubble {
    padding: 12px 16px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 14px;
    white-space: normal;
}

/* 메시지 버블 내부 포맷팅 */
.rag-chatbot-message-bubble strong {
    color: #667eea;
    font-weight: 600;
    display: inline-block;
    margin-top: 8px;
}

.rag-chatbot-message-bubble br {
    display: block;
    content: "";
    margin: 4px 0;
}

/* 번호 목록 스타일 개선 */
.rag-chatbot-message.ai .rag-chatbot-message-bubble {
    padding-right: 20px;
}

/* 메시지 메타 정보 */
.rag-chatbot-message-meta {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 4px;
    padding: 0 8px;
}

/* 출처 정보 */
.rag-chatbot-sources {
    margin-top: 8px;
    padding: 8px 12px;
    background: #edf2f7;
    border-radius: 8px;
    font-size: 12px;
}

.rag-chatbot-source-item {
    display: block;
    margin-top: 8px;
    padding: 8px;
    background: white;
    border-radius: 6px;
    border-left: 3px solid #667eea;
    color: #4a5568;
}

.rag-chatbot-source-item > span {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: #2d3748;
    margin-bottom: 6px;
}

.rag-chatbot-source-item i {
    color: #667eea;
    font-size: 12px;
}

/* 로딩 인디케이터 */
.rag-chatbot-loading {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

/* 스트리밍 답변 대기 중 로딩 스피너 (메시지 버블 내부) */
.rag-chatbot-streaming-loader {
    display: flex;
    gap: 6px;
    padding: 8px 0;
    justify-content: flex-start;
    align-items: center;
}

/* AI 메시지 버블 내부의 스피너는 더 진한 색상 */
.rag-chatbot-streaming-loader .rag-chatbot-loading-dot {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: loadingDot 1.4s infinite ease-in-out both;
}

.rag-chatbot-loading-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: loadingDot 1.4s infinite ease-in-out both;
}

.rag-chatbot-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.rag-chatbot-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* 입력 영역 */
.rag-chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
}

.rag-chatbot-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.rag-chatbot-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rag-chatbot-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.rag-chatbot-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

/* 환영 메시지 */
.rag-chatbot-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
}

.rag-chatbot-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: #667eea;
}

.rag-chatbot-welcome-title {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 8px;
}

.rag-chatbot-welcome-text {
    font-size: 14px;
    line-height: 1.6;
}

/* 반응형 */
@media (max-width: 480px) {
    .rag-chatbot-expanded {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
    }
}

/* 유틸리티 클래스 */
.hidden {
    display: none !important;
}

/* LLM 선택 버튼 영역 */
.rag-chatbot-llm-selector {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}

/* LLM 선택 버튼 */
.rag-llm-btn {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.rag-llm-btn i {
    font-size: 14px;
}

.rag-llm-btn:hover {
    border-color: #667eea;
    background: #f7fafc;
    transform: translateY(-1px);
}

.rag-llm-btn.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.rag-llm-btn.active:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
}
