@charset "UTF-8";

/* =====================================================================
   챗봇 위젯 (반응형)
   - 화면 크기에 맞춰 창 너비/높이가 줄어듭니다.
   - 아래 변수만 바꾸면 여백/버튼 크기를 한 번에 조절할 수 있습니다.
   ===================================================================== */

#chatbot-widget {
    --cb-edge: 50px;        /* 화면 가장자리와의 여백 */
    --cb-launcher: 58px;    /* 열기 버튼 크기 */
    --cb-gap: 14px;         /* 열기 버튼과 챗봇 창 사이 간격 */

    position: fixed;
    right: var(--cb-edge);
    bottom: var(--cb-edge);
    z-index: 99999;
    font-family: Arial, sans-serif;
}

/* ---------- 열기 버튼 ---------- */

.chatbot-launcher {
    position: fixed !important;
    right: var(--cb-edge) !important;
    bottom: var(--cb-edge) !important;

    width: var(--cb-launcher);
    height: var(--cb-launcher);

    padding: 0;
    border: none;
    border-radius: 50%;

    background: #ffffff;
    cursor: pointer;
    overflow: hidden;

    z-index: 9999;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
    transition: transform .15s ease;
}

.chatbot-launcher img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-launcher:hover {
    transform: scale(1.08);
}

/* ---------- 챗봇 창 ---------- */

#chatbot-window {
    position: fixed;
    right: var(--cb-edge);
    bottom: calc(var(--cb-edge) + var(--cb-launcher) + var(--cb-gap));

    /* 화면보다 커지지 않도록 제한 (기본 350 x 540) */
    width: min(450px, calc(100vw - (var(--cb-edge) * 2)));
    height: min(600px, calc(100vh - var(--cb-edge) - var(--cb-launcher) - var(--cb-gap) - 20px));
    height: min(600px, calc(100dvh - var(--cb-edge) - var(--cb-launcher) - var(--cb-gap) - 20px));

    background: #fff;
    border-radius: 18px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;

    /* 내용이 창보다 길어지면(문의 남기기 펼침 등) 창 전체가 스크롤됨 */
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;   /* 챗봇 안에서 스크롤해도 뒤의 페이지가 같이 움직이지 않게 */
    -webkit-overflow-scrolling: touch;
}

.chatbot-hidden {
    display: none !important;
}

.chatbot-header {
    flex: 0 0 auto;
    position: sticky;           /* 창이 스크롤되어도 헤더(닫기 버튼)는 항상 위에 고정 */
    top: 0;
    z-index: 5;
    background: #222;
    color: white;
    padding: 17px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header strong,
.chatbot-header small {
    display: block;
}

.chatbot-header small {
    margin-top: 5px;
    color: #ddd;
    font-size: 11px;
}

#chatbot-close {
    border: none;
    background: transparent;
    color: white;
    font-size: 27px;
    cursor: pointer;
}

/* ---------- 대화 영역 ---------- */

#chatbot-messages {
    flex: 1 1 auto;
    min-height: 160px;         /* 다른 영역이 커져도 대화창이 이 높이 밑으로는 줄지 않음 (넘치면 창이 스크롤) */
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f7;
}

.chatbot-message {
    max-width: 85%;
    padding: 11px 13px;
    margin-bottom: 10px;
    border-radius: 13px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chatbot-message.bot {
    background: white;
    color: #222;
    border: 1px solid #eee;
}

.chatbot-message.user {
    background: #0071e3;
    color: white;
    margin-left: auto;
}

/* ---------- 단계형 메뉴 (위 → 아래 한 줄씩) ---------- */

.chatbot-faq {
    flex: 0 0 auto;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eee;
    font-size: 12px;
}

#chatbot-menu-title {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    color: #333;
}

#chatbot-faq-list {
    display: flex;
    flex-direction: column;     /* 세로 배치 */
    flex-wrap: nowrap;          /* 옆 칸으로 넘어가지 않도록 (가로로 나열되던 원인 제거) */
    gap: 7px;

    /* 항목이 많으면 이 영역 안에서만 스크롤 */
    max-height: min(200px, 28vh);
    overflow-x: hidden;         /* 가로 스크롤바 제거 */
    overflow-y: auto;
}

.chatbot-faq-list-button {
    flex: 0 0 auto;             /* 세로로 눌려 찌그러지지 않게 */
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.chatbot-faq-list-button:hover {
    background: #f5f5f7;
    border-color: #0071e3;
}

/* 기타 질문 방식 선택(AI / 관리자) 버튼 */
.chatbot-faq-list-button small {
    display: block;
    margin-top: 3px;
    color: #777;
    font-size: 11px;
}

.chatbot-back-button {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    border: none;
    background: #f5f5f7;
    border-radius: 7px;
    color: #555;
    cursor: pointer;
}

/* ---------- 입력 영역 ---------- */

.chatbot-input-area {
    flex: 0 0 auto;
    display: flex;
    gap: 7px;
    padding: 10px;
    border-top: 1px solid #eee;
}

#chatbot-question {
    flex: 1;
    min-width: 0;
    border: 1px solid #ddd;
    border-radius: 18px;
    padding: 10px;
    outline: none;
}

#chatbot-send,
#chatbot-inquiry-send {
    border: none;
    border-radius: 18px;
    background: #0071e3;
    color: white;
    padding: 0 14px;
    cursor: pointer;
}

/* ---------- 문의 남기기 ---------- */

.chatbot-inquiry-form {
    flex: 0 0 auto;
    padding: 9px 12px;
    border-top: 1px solid #eee;
}

#chatbot-inquiry-toggle {
    border: none;
    background: none;
    color: #0071e3;
    cursor: pointer;
    font-size: 12px;
}

/* 문의 입력 영역은 자체 스크롤 없이 펼쳐지고, 넘치는 부분은 창 전체 스크롤로 처리 */
#chatbot-inquiry-fields {
    max-height: none;
    overflow: visible;
}

.chatbot-inquiry-form {
    padding-bottom: 14px;       /* 맨 아래 전송 버튼이 창 가장자리에 붙지 않게 */
}

#chatbot-inquiry-fields input,
#chatbot-inquiry-fields select,
#chatbot-inquiry-fields textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 9px;
    margin-top: 7px;
    border: 1px solid #ddd;
    border-radius: 7px;
    font-size: 12px;
}

#chatbot-inquiry-fields select {
    background: #fff;
    cursor: pointer;
}

#chatbot-inquiry-fields textarea {
    height: 65px;
    resize: vertical;
}

#chatbot-inquiry-send {
    width: 100%;
    padding: 10px;
    margin-top: 7px;
}

/* STORE 페이지의 기존 스페셜리스트 버튼 숨김 */
.rs-sticky-chat {
    display: none !important;
}

/* =====================================================================
   반응형
   ===================================================================== */

/* 태블릿 이하: 여백을 줄여 화면을 더 넓게 사용 */
@media (max-width: 768px) {
    #chatbot-widget {
        --cb-edge: 24px;
    }
}

/* 모바일: 창을 화면 좌우에 맞춰 꽉 차게 */
@media (max-width: 480px) {

    #chatbot-widget {
        --cb-edge: 14px;
        --cb-launcher: 52px;
        --cb-gap: 10px;
    }

    #chatbot-window {
        left: var(--cb-edge);
        right: var(--cb-edge);
        width: auto;
        border-radius: 14px;
    }

    .chatbot-header {
        padding: 13px 15px;
    }

    /* iOS 사파리는 16px 미만 입력창에 포커스하면 화면이 확대됨 */
    #chatbot-question,
    #chatbot-inquiry-fields input,
    #chatbot-inquiry-fields select,
    #chatbot-inquiry-fields textarea {
        font-size: 16px;
    }
}

/* 화면 높이가 낮을 때 (가로 모드 모바일, 작은 노트북 창 등) */
@media (max-height: 560px) {

    .chatbot-header {
        padding: 10px 15px;
    }

    #chatbot-messages {
        min-height: 110px;
    }

    #chatbot-faq-list {
        max-height: 24vh;
    }
}
