/* ============================================
   챗봇 UI - Mobile 버전
   ============================================ */

/* 플로팅 버튼 */
.chatbot-toggle {
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: #4a64f5;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 100, 245, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.chatbot-toggle.is-active svg.icon-chat {
    display: none;
}

.chatbot-toggle.is-active svg.icon-close {
    display: block;
}

.chatbot-toggle svg.icon-close {
    display: none;
}

/* 채팅창 - 모바일은 풀스크린 */
.chatbot-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-window.is-open {
    display: flex;
}

/* 헤더 */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #4a64f5;
    color: #fff;
    flex-shrink: 0;
}

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

.chatbot-header-title svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

.chatbot-header-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-header-close svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

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

/* 메시지 공통 */
.chatbot-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
}

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

/* AI 메시지 (왼쪽) */
.chatbot-msg.bot {
    align-self: flex-start;
}

.chatbot-msg.bot .chatbot-msg-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e8eaf0;
    border-bottom-left-radius: 4px;
}

.chatbot-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #4a64f5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-msg-avatar svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* 사용자 메시지 (오른쪽) */
.chatbot-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-msg.user .chatbot-msg-bubble {
    background: #4a64f5;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* 타이핑 인디케이터 */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    background: #aaa;
    border-radius: 50%;
    animation: chatbot-typing-bounce 1.4s infinite ease-in-out;
}

.chatbot-typing span:nth-child(1) {
    animation-delay: 0s;
}

.chatbot-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatbot-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

/* 입력 영역 */
.chatbot-input {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid #e8eaf0;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}

.chatbot-input-field {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 16px;
    outline: none;
    resize: none;
    height: 40px;
    line-height: 20px;
    background: #f7f8fc;
    -webkit-appearance: none;
}

.chatbot-input-field:focus {
    border-color: #4a64f5;
    background: #fff;
}

.chatbot-input-field::placeholder {
    color: #aaa;
}

.chatbot-input-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4a64f5;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-input-send:disabled {
    background: #ccc;
}

.chatbot-input-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* 마크다운 서식 */
.chatbot-formatted p {
    margin: 0 0 6px 0;
}

.chatbot-formatted p:last-child {
    margin-bottom: 0;
}

.chatbot-formatted strong {
    font-weight: 600;
    color: #222;
}

.chatbot-formatted .chatbot-heading {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #4a64f5;
    margin: 8px 0 4px 0;
}

.chatbot-formatted .chatbot-heading:first-child {
    margin-top: 0;
}

.chatbot-formatted em {
    font-style: italic;
}

.chatbot-formatted code {
    background: #f0f1f5;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

.chatbot-formatted ul,
.chatbot-formatted ol {
    margin: 4px 0 8px 0;
    padding-left: 18px;
}

.chatbot-formatted ul:last-child,
.chatbot-formatted ol:last-child {
    margin-bottom: 0;
}

.chatbot-formatted li {
    margin-bottom: 3px;
    line-height: 1.5;
}

.chatbot-formatted li:last-child {
    margin-bottom: 0;
}
