/**
 * 챗봇 위젯 스타일
 * Floating Chatbot Widget CSS
 */

/* 챗봇 컨테이너 */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* 토글 버튼 */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
}

.chatbot-toggle-icon {
    color: white;
    width: 28px;
    height: 28px;
    transition: all 0.3s ease;
}

.chatbot-toggle-icon.close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
}

#chatbot-widget.is-open .chatbot-toggle-icon.open {
    opacity: 0;
    transform: rotate(90deg);
}

#chatbot-widget.is-open .chatbot-toggle-icon.close {
    opacity: 1;
    transform: rotate(0);
}

/* 알림 배지 */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* 챗봇 창 */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

#chatbot-widget.is-open .chatbot-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

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

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-avatar svg {
    width: 24px;
    height: 24px;
}

.chatbot-name {
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

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

.chatbot-close svg {
    width: 18px;
    height: 18px;
}

/* 메시지 영역 */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

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

/* 로딩 */
.chatbot-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.loading-dots, .typing-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span, .typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1), .typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2), .typing-dots span:nth-child(2) { animation-delay: -0.16s; }

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

/* 메시지 */
.chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

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

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

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

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

/* 자동응답 봇 메시지 - 흰색 (왼쪽) */
.chatbot-message.bot .message-bubble {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* 상담사(관리자) 메시지 - 파란색 (왼쪽) */
.chatbot-message.admin {
    align-self: flex-start;
    align-items: flex-start;
}

.chatbot-message.admin .message-bubble {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

/* 링크 */
.chat-link {
    color: #667eea;
    text-decoration: underline;
}

.chatbot-message.user .chat-link {
    color: #c4b5fd;
}

/* 퀵 버튼 */
.chatbot-quick-buttons {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-btn {
    padding: 8px 14px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

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

.chatbot-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc;
    color: #1e293b;
}

.chatbot-input:focus {
    border-color: #667eea;
    background: white;
}

.chatbot-input::placeholder {
    color: #94a3b8;
}

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

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
}

/* 타이핑 인디케이터 */
.chatbot-message.typing .message-bubble {
    padding: 16px 20px;
}

/* 모바일 대응 */
@media (max-width: 480px) {
    #chatbot-widget {
        bottom: 10px;
        right: 10px;
    }

    .chatbot-toggle {
        width: 54px;
        height: 54px;
    }

    .chatbot-window {
        bottom: 70px;
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 0;
        border-radius: 12px;
    }

    .chatbot-header {
        padding: 14px 16px;
    }

    .chatbot-messages {
        padding: 16px;
    }

    .quick-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}
