/* ==============================================================================
   Kolive Chat & Bot Widget Dedicated Stylesheet
   플랫폼 챗봇 & 실시간 상담 위젯 전용 스타일 (Zero Inline Style)
============================================================================== */

.kol-chat-widget-wrap {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Pretendard", sans-serif;
}

/* 플로팅 FAB 버튼 */
.kol-chat-fab {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    padding: 12px 20px;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px -4px rgba(37, 99, 235, 0.45);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.kol-chat-fab:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 28px -4px rgba(37, 99, 235, 0.55);
}
.kol-chat-fab .fab-icon-close { display: none; }
.kol-chat-widget-wrap.open .kol-chat-fab .fab-icon-chat { display: none; }
.kol-chat-widget-wrap.open .kol-chat-fab .fab-icon-close { display: block; }
.kol-chat-widget-wrap.open .kol-chat-fab {
    background: #0f172a;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.3);
}

/* 펄스 애니메이션 */
.kol-chat-pulse {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #ffffff;
    animation: kolPulse 2s infinite;
}
@keyframes kolPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* 챗봇 팝업 윈도우 */
.kol-chat-window {
    display: none;
    position: absolute;
    right: 0;
    bottom: 66px;
    width: 380px;
    height: 560px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.08);
    flex-direction: column;
    overflow: hidden;
    animation: kolSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.kol-chat-widget-wrap.open .kol-chat-window {
    display: flex;
}
@keyframes kolSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 헤더 */
.kol-chat-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-avatar-bot {
    width: 38px;
    height: 38px;
    background: #2563eb;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #ffffff;
}
.chat-header-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 3px 0;
}
.chat-header-status {
    font-size: 11.5px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
}
.status-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
}
.chat-btn-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}
.chat-btn-close:hover { color: #ffffff; }

/* 탭 네비게이션 */
.kol-chat-nav-tabs {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-bottom: 1px solid #e2e8f0;
}
.chat-nav-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.chat-nav-tab.active {
    background: #ffffff;
    color: #2563eb;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
}

/* 패널 */
.kol-chat-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}
.kol-chat-panel.active {
    display: flex;
}

/* 메시지 박스 */
.kol-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}
.kol-chat-messages::-webkit-scrollbar { width: 5px; }
.kol-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* 메시지 말풍선 */
.chat-msg-row {
    display: flex;
    gap: 8px;
    max-width: 88%;
}
.chat-msg-row.bot { align-self: flex-start; }
.chat-msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-row.system { align-self: center; max-width: 100%; }

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}
.msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-msg-row.bot .msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}
.chat-msg-row.user .msg-bubble {
    background: #2563eb;
    color: #ffffff;
}
.system-bubble {
    font-size: 12px;
    color: #64748b;
    background: #e2e8f0;
    padding: 6px 12px;
    border-radius: 20px;
    text-align: center;
}

/* 추천 칩 */
.chat-quick-chips {
    margin-top: 4px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}
.quick-chips-title {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 8px;
}
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chip-btn {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    padding: 5px 10px;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.chip-btn:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* FAQ 결과 카드 */
.bot-faq-card {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 8px;
}
.bot-faq-q {
    font-weight: 700;
    color: #0369a1;
    font-size: 13px;
    margin-bottom: 4px;
}
.bot-faq-a {
    font-size: 12.5px;
    color: #334155;
    line-height: 1.5;
}
.bot-faq-a p { margin: 4px 0; }
.bot-faq-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 11.5px;
    color: #2563eb;
    text-decoration: underline;
}

/* 입력 바 */
.kol-chat-input-box {
    display: flex;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    gap: 8px;
}
.chat-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13.5px;
}
.chat-input:focus {
    border-color: #2563eb;
    outline: none;
}
.chat-btn-send {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.chat-btn-send:hover { background: #1d4ed8; }

/* 윈도우 하단 바 */
.kol-chat-window-footer {
    padding: 8px 14px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    font-size: 11.5px;
    color: #64748b;
    text-align: center;
}
.kol-chat-window-footer a {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
}

@media (max-width: 640px) {
    .kol-chat-widget-wrap {
        bottom: 4.38rem !important;
        right: 0.75rem !important;
    }
    .kol-chat-fab {
        padding: 0.5rem 0.88rem !important;
        font-size: 0.81rem !important;
    }
    .kol-chat-window {
        width: calc(100vw - 1.5rem) !important;
        height: 70vh !important;
        right: -0.25rem !important;
        bottom: 3.5rem !important;
    }
}

@media (max-width: 480px) {
    .kol-chat-window {
        width: calc(100vw - 32px);
        height: 75vh;
        right: -8px;
    }
}

/* JS 동적 렌더링 전용 클래스 (Zero Inline Style) */
.bot-ai-answer {
    margin-bottom: 8px;
    line-height: 1.6;
}
.bot-faq-card.theme-purple {
    background: #fdf4ff;
    border-color: #f5d0fe;
}
.bot-faq-card.theme-emerald {
    background: #ecfdf5;
    border-color: #a7f3d0;
}
.bot-faq-card.theme-amber {
    background: #fffbeb;
    border-color: #fde68a;
}
