/* 톡상담·챗봇 아이콘 바 - 조회하기 버튼 바로 아래 가운데 정렬 (문서 흐름) */
.chatbot-widget-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 9998;
}

/* 다른 페이지(인트로, 예약 등): body 직계일 때 화면 하단 고정 */
body > .chatbot-widget-bar {
    position: fixed;
    bottom: max(24px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    padding-bottom: 0;
}

/* 모바일 메인페이지: 카톡·챗봇 플로팅 아이콘 숨김 (리스트 메뉴로 대체) */
.intro-mobile .chatbot-widget-bar > #chatbot-toggle,
.intro-mobile .chatbot-widget-bar > #kakao-chat-toggle {
    display: none !important;
}

/* 챗봇 상담 위젯 */
#chatbot-toggle {
    position: relative;
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0068ff;
    color: #fff;
    border: none;
    box-shadow: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.2s;
}
#chatbot-toggle:hover {
    transform: scale(1.05);
}
#chatbot-toggle:active { transform: scale(0.98); }

#chatbot-panel {
    display: none;
    position: fixed;
    bottom: max(90px, calc(56px + 24px + env(safe-area-inset-bottom)));
    right: max(24px, env(safe-area-inset-right));
    width: 340px;
    max-width: calc(100vw - 48px);
    height: 420px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    /* 상단 라운드에서 흰 끝선이 보이지 않도록 헤더와 반경 공유 */
    isolation: isolate;
    z-index: 9999;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Noto Sans KR', sans-serif;
}
#chatbot-panel.open { display: flex; }

#chatbot-header {
    padding: 14px 16px;
    background: #0068ff;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}
/* 헤더 내 로봇 아이콘: 본색 #0068ff (흰 배지로 대비) */
#chatbot-header .chatbot-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #fff;
    color: #0068ff;
    flex-shrink: 0;
}
#chatbot-header .chatbot-header-icon .fa-robot {
    font-size: 1.1rem;
    color: #0068ff;
}
#chatbot-header .chatbot-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.9;
}
#chatbot-header .chatbot-close:hover { opacity: 1; }

#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f6f8;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
/* 관리자 등록 시 줄바꿈(Enter) 그대로 표시 */
.chatbot-msg .text {
    white-space: pre-line;
}
.chatbot-msg.bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
}
.chatbot-msg.user {
    align-self: flex-end;
    background: #0068ff;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chatbot-msg .time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}
.chatbot-msg.user .time { color: rgba(255,255,255,0.8); }

#chatbot-quick {
    padding: 8px 12px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
#chatbot-quick button {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid #0068ff;
    color: #0068ff;
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
#chatbot-quick button:hover {
    background: #0068ff;
    color: #fff;
}

#chatbot-input-wrap {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: center;
}
#chatbot-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 22px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
#chatbot-input:focus { border-color: #0068ff; }
#chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #0068ff;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
#chatbot-send:hover { background: #0052cc; }
#chatbot-send:disabled { background: #ccc; cursor: not-allowed; }

/* PC 인트로(/): 우측 고정 · 패널 대형 · 본문/빠른답변 가독성 */
@media (min-width: 769px) {
    body.intro-pc > .chatbot-widget-bar {
        left: auto;
        right: max(28px, env(safe-area-inset-right));
        transform: none;
        justify-content: flex-end;
        gap: 16px;
        bottom: max(28px, env(safe-area-inset-bottom));
    }

    body.intro-pc #kakao-chat-toggle {
        width: 64px;
        height: 64px;
    }

    body.intro-pc #chatbot-toggle {
        width: 64px;
        height: 64px;
        font-size: 28px;
        box-shadow: none;
    }

    body.intro-pc #chatbot-panel {
        right: max(28px, env(safe-area-inset-right));
        bottom: max(108px, calc(64px + 36px + env(safe-area-inset-bottom)));
        /* 가로 이전 대비 20% 축소 (480→384px, 36vw→28.8vw) */
        width: min(384px, 28.8vw);
        min-width: 304px;
        height: min(680px, calc(100vh - 120px));
        max-height: calc(100dvh - 96px);
        border-radius: 20px;
        box-shadow: 0 16px 56px rgba(0, 0, 0, 0.22);
        border: none;
    }

    body.intro-pc #chatbot-header {
        padding: 18px 20px;
        font-size: 17px;
        letter-spacing: -0.02em;
        border-radius: 20px 20px 0 0;
    }

    body.intro-pc #chatbot-header .chatbot-header-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    body.intro-pc #chatbot-header .chatbot-header-icon .fa-robot {
        font-size: 1.25rem;
    }

    body.intro-pc #chatbot-messages {
        padding: 20px 22px;
        gap: 14px;
        background: #f0f2f5;
    }

    body.intro-pc .chatbot-msg {
        max-width: 90%;
        padding: 12px 16px;
        font-size: 15px;
        line-height: 1.55;
        border-radius: 16px;
    }

    body.intro-pc .chatbot-msg .time {
        font-size: 12px;
    }

    body.intro-pc #chatbot-quick {
        padding: 12px 16px;
        gap: 8px;
    }

    body.intro-pc #chatbot-quick button {
        padding: 9px 16px;
        font-size: 13px;
        border-radius: 22px;
    }

    body.intro-pc #chatbot-input-wrap {
        padding: 14px 16px;
    }

    body.intro-pc #chatbot-input {
        padding: 12px 18px;
        font-size: 15px;
    }

    body.intro-pc #chatbot-send {
        width: 48px;
        height: 48px;
        font-size: 19px;
    }
}

/* 모바일 반응형 */
@media (max-width: 480px) {
    #chatbot-panel {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        height: 70vh;
        max-height: calc(100dvh - 100px);
        border-radius: 16px 16px 0 0;
        margin-right: 0;
    }
}
