/* チャットボットウィジェット - RAG対応版 */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* トグルボタン */
#chatbot-toggle {
    width: 60px;
    height: 60px;
    background: var(--theme-color, #4CAF50);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    color: white;
}

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

#chatbot-toggle svg {
    width: 28px;
    height: 28px;
}

/* チャットウィンドウ */
#chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px 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);
    }
}

/* ヘッダー */
#chatbot-header {
    background: var(--theme-color, #4CAF50);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
}

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

#chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* メッセージエリア */
#chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

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

#chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

/* メッセージ */
.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);
    }
}

.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
}

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

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

.user-message .message-content {
    background: var(--theme-color, #4CAF50);
    color: white;
    border-radius: 12px 12px 2px 12px;
}

/* 参考記事リンク */
.message-references {
    margin-top: 12px;
    padding: 12px;
    background: #f0f7ff;
    border: 1px solid #b3d9ff;
    border-radius: 8px;
    max-width: 85%;
}

.message-references-title {
    font-size: 12px;
    font-weight: 600;
    color: #0066cc;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-references-title svg {
    width: 14px;
    height: 14px;
}

.reference-link {
    display: block;
    padding: 8px 10px;
    margin: 6px 0;
    background: white;
    border: 1px solid #d0e3ff;
    border-radius: 6px;
    text-decoration: none;
    color: #0066cc;
    font-size: 13px;
    transition: all 0.2s;
}

.reference-link:hover {
    background: #e6f2ff;
    border-color: #0066cc;
    transform: translateX(4px);
}

.reference-link-title {
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
}

.reference-link-excerpt {
    font-size: 11px;
    color: #666;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ローディング */
.loading-message .message-content {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 12px 20px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    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% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 入力エリア */
#chatbot-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

#chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chatbot-input:focus {
    border-color: var(--theme-color, #4CAF50);
}

#chatbot-send {
    width: 44px;
    height: 44px;
    background: var(--theme-color, #4CAF50);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
}

#chatbot-send:hover {
    background: color-mix(in srgb, var(--theme-color, #4CAF50) 85%, black);
    transform: scale(1.05);
}

#chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    #chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }
    
    #chatbot-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .message-content,
    .message-references {
        max-width: 95%;
    }
}

/* エラーメッセージ */
.error-message .message-content {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}
