/*!
 * 사전 영업 챗봇 위젯 — 스타일
 * 설계: docs/CHATBOT-PRESALES-DESIGN.md §12
 *
 * 🔑 사이트 팔레트를 그대로 쓴다 — #667eea → #764ba2, 본문 #1a1a1a, 보조 #4a5568.
 * 🔑 클래스 접두사 `cjchat-` 로 기존 스타일과 충돌하지 않게 한다.
 * 🛑 `prefers-reduced-motion` 을 존중한다(설계서 §12).
 */

.cjchat-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1200;
    padding: 0.85rem 1.4rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cjchat-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.45);
}

.cjchat-panel {
    position: fixed;
    right: 20px;
    bottom: 84px;
    z-index: 1201;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 40px));
    max-height: min(600px, calc(100vh - 120px));
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    animation: cjchat-in 0.22s ease;
}

.cjchat-panel[hidden] { display: none; }

@keyframes cjchat-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cjchat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.cjchat-title { font-weight: 600; font-size: 0.98rem; }

.cjchat-x {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0 0.25rem;
    cursor: pointer;
    border-radius: 4px;
}

.cjchat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    background: #f7f8fc;
}

.cjchat-msg { margin-bottom: 0.9rem; }

.cjchat-who {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #4a5568;
    margin-bottom: 0.25rem;
}

.cjchat-body {
    background: #fff;
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    color: #1a1a1a;
    font-size: 0.92rem;
    line-height: 1.55;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.cjchat-body p + p { margin-top: 0.6rem; }

/* ── 마크다운 (봇 말풍선만) ────────────────────────────────────────────
 * 🔑 `chat-widget.js` 의 `renderMarkdown` 이 만드는 것들이다. 허용 목록 밖의
 *    문법은 글자 그대로 떨어지므로 여기 없는 태그는 나오지 않는다.
 * 🛑 봇 말풍선은 폭 400px(모바일은 100vw)다 — **넓은 것은 전부 가둔다.**
 */
.cjchat-body > :first-child { margin-top: 0; }
.cjchat-body > :last-child { margin-bottom: 0; }

.cjchat-h {
    font-weight: 700;
    font-size: 0.95rem;
    margin: 0.7rem 0 0.3rem;
}

/* 🔴 두 사이트 모두 `* { margin:0; padding:0 }` 로 리셋한다 — 들여쓰기를 여기서
 *    되돌려 주지 않으면 글머리표가 말풍선 밖으로 잘린다.
 * 🛑 `list-style` 도 명시한다. 지금은 `.nav-links` 에만 `none` 이 걸려 있지만,
 *    누군가 전역으로 옮기는 날 **표식 없는 목록**이 조용히 생긴다. */
.cjchat-body ul,
.cjchat-body ol {
    margin: 0.45rem 0;
    padding-left: 1.25rem;
}

.cjchat-body ul { list-style: disc outside; }
.cjchat-body ol { list-style: decimal outside; }
.cjchat-body li > ul { list-style: circle outside; }

.cjchat-body li { margin: 0.2rem 0; }
.cjchat-body li > p { margin: 0; }
.cjchat-body li > p + p { margin-top: 0.35rem; }
.cjchat-body li > ul,
.cjchat-body li > ol { margin: 0.2rem 0; }

.cjchat-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86em;
    background: #eef0f8;
    border-radius: 4px;
    padding: 0.1em 0.32em;
    /* 🔑 `cj_chat_handler` 같은 긴 식별자가 말풍선을 밀어내지 않게 한다 */
    overflow-wrap: anywhere;
}

.cjchat-body pre {
    margin: 0.5rem 0;
    padding: 0.6rem 0.7rem;
    background: #f2f3f8;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.45;
}

.cjchat-body pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    overflow-wrap: normal;
    white-space: pre;
}

/* 🔴 표는 반드시 감싼 것 안에서 가로 스크롤한다 — 안 그러면 3열짜리 하나가
 *    좁은 패널의 레이아웃을 통째로 밀어낸다. */
.cjchat-tw {
    margin: 0.55rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cjchat-tw table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.84rem;
}

.cjchat-tw th,
.cjchat-tw td {
    border: 1px solid #e6e8f0;
    padding: 0.35rem 0.5rem;
    text-align: left;
    vertical-align: top;
}

.cjchat-tw th {
    background: #f2f3f8;
    font-weight: 600;
    white-space: nowrap;
}

.cjchat-body blockquote {
    margin: 0.5rem 0;
    padding: 0.1rem 0 0.1rem 0.7rem;
    border-left: 3px solid #d7dae6;
    color: #4a5568;
}

.cjchat-body hr {
    border: 0;
    border-top: 1px solid #e6e8f0;
    margin: 0.7rem 0;
}

.cjchat-body a { color: #667eea; }

.cjchat-user .cjchat-who { text-align: right; }
.cjchat-user .cjchat-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.cjchat-err .cjchat-body { background: #fff5f5; }

.cjchat-cta {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #667eea;
}

.cjchat-src {
    margin-top: 0.45rem;
    font-size: 0.78rem;
    color: #4a5568;
}

.cjchat-src a { color: #667eea; }

.cjchat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1rem 0.6rem;
    background: #f7f8fc;
}

.cjchat-chips:empty { display: none; }

.cjchat-chip {
    border: 1px solid rgba(102, 126, 234, 0.35);
    background: #fff;
    color: #4a5568;
    border-radius: 999px;
    padding: 0.4rem 0.75rem;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.cjchat-chip:hover { background: #667eea; color: #fff; }

.cjchat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e6e8f0;
    background: #fff;
}

.cjchat-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid #d7dae6;
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    font-family: inherit;
    font-size: 0.92rem;
    color: #1a1a1a;
}

.cjchat-input:disabled { background: #f2f3f8; }

.cjchat-send {
    flex: 0 0 auto;
    border: 0;
    border-radius: 10px;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.cjchat-send:disabled { opacity: 0.6; cursor: default; }

.cjchat-foot {
    padding: 0.6rem 1rem 0.85rem;
    background: #fff;
    font-size: 0.74rem;
    line-height: 1.5;
    color: #4a5568;
}

.cjchat-foot a { color: #667eea; }

/* 🔴 좁은 화면에서는 전체를 덮는다 — 우하단 카드는 모바일에서 쓰기 어렵다 */
@media (max-width: 480px) {
    .cjchat-panel {
        right: 0;
        bottom: 0;
        width: 100vw;
        max-height: 85vh;
        border-radius: 18px 18px 0 0;
    }
    .cjchat-fab { right: 12px; bottom: 12px; padding: 0.75rem 1.1rem; font-size: 0.88rem; }
}

/* 🛑 설계서 §12 — 존중한다 */
@media (prefers-reduced-motion: reduce) {
    .cjchat-panel { animation: none; }
    .cjchat-fab { transition: none; }
    .cjchat-fab:hover { transform: none; }
}
