/*!
 * KLZ 실시간 상담 위젯 스타일
 * 사이트 현대화 톤(인디고~바이올렛)과 통일.
 */
.klz-chat, .klz-chat * { box-sizing: border-box; }
/* hidden 속성이 아래 display 선언(.klz-chat-panel, .klz-chat-lightbox 등)에 밀리지 않도록 고정 */
.klz-chat [hidden] { display: none !important; }
.klz-chat {
    --kc-primary: #4f46e5;
    --kc-primary-2: #7c3aed;
    --kc-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --kc-bg: #ffffff;
    --kc-panel-bg: #f4f5fb;
    --kc-text: #1e293b;
    --kc-muted: #64748b;
    --kc-line: rgba(15,23,42,.10);
    --kc-user: linear-gradient(135deg, #4f46e5 0%, #6d5ae0 100%);
    --kc-agent: #ffffff;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100000;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* 런처 버튼 */
.klz-chat-launcher {
    position: relative;
    width: 60px; height: 60px;
    border: 0; border-radius: 50%;
    background: var(--kc-grad);
    color: #fff; cursor: pointer;
    box-shadow: 0 10px 25px -6px rgba(79,70,229,.55), 0 4px 10px rgba(0,0,0,.12);
    display: flex; align-items: center; justify-content: center;
    transition: transform .18s ease, box-shadow .18s ease;
}
.klz-chat-launcher:hover { transform: translateY(-2px) scale(1.04); }
.klz-chat-launcher .ico-close { display: none; }
.klz-chat.is-open .klz-chat-launcher .ico-chat { display: none; }
.klz-chat.is-open .klz-chat-launcher .ico-close { display: block; }
.klz-chat-badge {
    position: absolute; top: -3px; right: -3px;
    min-width: 20px; height: 20px; padding: 0 5px;
    border-radius: 999px; background: #ef4444; color: #fff;
    border: 2px solid #fff;
    font-size: 11px; font-weight: 800; line-height: 16px; text-align: center;
}

/* 패널 */
.klz-chat-panel {
    position: absolute; right: 0; bottom: 74px;
    width: 370px; max-width: calc(100vw - 32px);
    height: 560px; max-height: calc(100vh - 120px);
    background: var(--kc-panel-bg);
    border: 1px solid var(--kc-line);
    border-radius: 18px;
    box-shadow: 0 24px 60px -12px rgba(16,24,40,.35);
    display: flex; flex-direction: column; overflow: hidden;
    transform-origin: bottom right;
    animation: klzChatIn .18s ease;
}
@keyframes klzChatIn {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 헤더 */
.klz-chat-head {
    background: var(--kc-grad);
    color: #fff; padding: 16px 16px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.klz-chat-title { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.klz-chat-status { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; opacity: .92; }
.klz-chat-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; box-shadow: 0 0 0 0 rgba(255,255,255,.5); }
.klz-chat-status .dot.online { background: #4ade80; animation: klzPulse 2s infinite; }
@keyframes klzPulse { 0%{box-shadow:0 0 0 0 rgba(74,222,128,.6)} 70%{box-shadow:0 0 0 7px rgba(74,222,128,0)} 100%{box-shadow:0 0 0 0 rgba(74,222,128,0)} }
.klz-chat-headbtn { border: 0; background: rgba(255,255,255,.16); color: #fff; width: 32px; height: 32px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s ease; }
.klz-chat-headbtn:hover { background: rgba(255,255,255,.28); }

/* 사전 입력 폼 */
.klz-chat-intro { padding: 26px 20px; flex: 1; overflow-y: auto; }
.klz-chat-intro-lead { margin: 4px 0 20px; font-size: 14px; line-height: 1.6; color: var(--kc-text); text-align: center; }
.klz-chat-field { margin-bottom: 10px; }
.klz-chat-field input {
    width: 100%; height: 46px; padding: 0 14px;
    border: 1px solid var(--kc-line); border-radius: 11px;
    background: #fff; font-size: 14px; color: var(--kc-text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.klz-chat-field input:focus { outline: 0; border-color: var(--kc-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.14); }
.klz-chat-startbtn {
    width: 100%; height: 48px; margin-top: 6px;
    border: 0; border-radius: 12px; cursor: pointer;
    background: var(--kc-grad); color: #fff; font-size: 15px; font-weight: 700;
    box-shadow: 0 8px 18px -6px rgba(79,70,229,.5);
    transition: filter .15s ease, transform .12s ease;
}
.klz-chat-startbtn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.klz-chat-intro-note { margin: 14px 0 0; font-size: 11px; color: var(--kc-muted); text-align: center; }

/* 메시지 영역 */
.klz-chat-body { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.klz-chat-body::-webkit-scrollbar { width: 8px; }
.klz-chat-body::-webkit-scrollbar-thumb { background: rgba(100,116,139,.35); border-radius: 8px; }
.kc-row { display: flex; flex-direction: column; max-width: 82%; }
.kc-row.user { align-self: flex-end; align-items: flex-end; }
.kc-row.agent { align-self: flex-start; align-items: flex-start; }
.kc-row.system { align-self: center; align-items: center; max-width: 92%; }
.kc-name { font-size: 11px; color: var(--kc-muted); margin: 0 4px 3px; font-weight: 600; }
.kc-bubble {
    padding: 10px 13px; font-size: 14px; line-height: 1.5; word-break: break-word;
    border-radius: 15px; box-shadow: 0 1px 2px rgba(16,24,40,.06);
}
.kc-row.user .kc-bubble { background: var(--kc-user); color: #fff; border-bottom-right-radius: 5px; }
.kc-row.agent .kc-bubble { background: var(--kc-agent); color: var(--kc-text); border: 1px solid var(--kc-line); border-bottom-left-radius: 5px; }
.kc-row.system .kc-bubble { background: rgba(100,116,139,.12); color: var(--kc-muted); font-size: 12.5px; text-align: center; border-radius: 999px; padding: 7px 15px; box-shadow: none; }
.kc-time { font-size: 10px; color: var(--kc-muted); margin: 3px 5px 0; }

/* 사진 말풍선 */
.kc-bubble.photo { padding: 4px; overflow: hidden; background: #fff; border: 1px solid var(--kc-line); }
.kc-row.user .kc-bubble.photo { background: var(--kc-user); border: 0; padding: 4px; }
.kc-bubble.photo img {
    display: block; max-width: 100%; width: 210px; height: auto;
    border-radius: 11px; cursor: zoom-in; background: rgba(100,116,139,.10);
}
.kc-bubble.photo .kc-photo-name {
    display: block; max-width: 210px; margin: 5px 4px 2px;
    font-size: 11px; color: var(--kc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kc-row.user .kc-bubble.photo .kc-photo-name { color: rgba(255,255,255,.85); }

/* 업로드 진행 말풍선 */
.kc-bubble.uploading { position: relative; }
.kc-bubble.uploading img { opacity: .45; cursor: default; }
.kc-upbar {
    position: absolute; left: 12px; right: 12px; bottom: 12px; height: 5px;
    border-radius: 99px; background: rgba(15,23,42,.22); overflow: hidden;
}
.kc-upbar > i { display: block; height: 100%; width: 0; background: #fff; border-radius: 99px; transition: width .18s ease; }
.kc-bubble.uploading.failed { background: #fee2e2; border-color: #fecaca; color: #b91c1c; font-size: 12.5px; padding: 10px 13px; }

/* 드래그&드롭 오버레이 */
.klz-chat-drop {
    position: absolute; inset: 0; z-index: 20;
    background: rgba(79,70,229,.10); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.klz-chat-drop-in {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    width: 100%; height: 100%; border: 2px dashed var(--kc-primary); border-radius: 16px;
    align-items: center; justify-content: center;
    color: var(--kc-primary); font-size: 13.5px; font-weight: 700; background: rgba(255,255,255,.72);
}

/* 입력 영역 */
.klz-chat-input {
    flex-shrink: 0; display: flex; align-items: flex-end; gap: 6px;
    padding: 10px 12px; background: #fff; border-top: 1px solid var(--kc-line);
}
.klz-chat-attachbtn {
    flex-shrink: 0; width: 40px; height: 42px; border: 0; border-radius: 11px; cursor: pointer;
    background: none; color: var(--kc-muted);
    display: flex; align-items: center; justify-content: center;
    transition: background .15s ease, color .15s ease;
}
.klz-chat-attachbtn:hover { background: rgba(79,70,229,.10); color: var(--kc-primary); }
.klz-chat-attachbtn:disabled { opacity: .45; cursor: default; background: none; }
.klz-chat-input textarea {
    flex: 1; resize: none; max-height: 110px; min-height: 42px;
    padding: 11px 14px; border: 1px solid var(--kc-line); border-radius: 12px;
    font-size: 14px; line-height: 1.4; font-family: inherit; color: var(--kc-text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.klz-chat-input textarea:focus { outline: 0; border-color: var(--kc-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.14); }
.klz-chat-sendbtn {
    flex-shrink: 0; width: 42px; height: 42px; border: 0; border-radius: 12px; cursor: pointer;
    background: var(--kc-grad); color: #fff; display: flex; align-items: center; justify-content: center;
    transition: filter .15s ease, transform .12s ease;
}
.klz-chat-sendbtn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.klz-chat-sendbtn:disabled { opacity: .5; cursor: default; transform: none; filter: none; }

/* 하단 종료 */
.klz-chat-foot { flex-shrink: 0; padding: 0 12px 10px; background: #fff; text-align: center; }
.klz-chat-closebtn { border: 0; background: none; color: var(--kc-muted); font-size: 12px; cursor: pointer; text-decoration: underline; padding: 4px; }
.klz-chat-closebtn:hover { color: #ef4444; }

/* 원본 보기(라이트박스) */
.klz-chat-lightbox {
    position: fixed; inset: 0; z-index: 100001;
    background: rgba(8,11,22,.92);
    display: flex; align-items: center; justify-content: center;
    padding: 56px 16px 24px;
    animation: klzLbIn .16s ease;
}
@keyframes klzLbIn { from { opacity: 0 } to { opacity: 1 } }
.klz-chat-lightbox img {
    max-width: 100%; max-height: 100%;
    object-fit: contain; border-radius: 6px;
    box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.klz-lb-bar { position: absolute; top: 12px; right: 14px; display: flex; gap: 8px; }
.klz-lb-btn {
    width: 40px; height: 40px; border: 0; border-radius: 11px; cursor: pointer;
    background: rgba(255,255,255,.14); color: #fff;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s ease;
}
.klz-lb-btn:hover { background: rgba(255,255,255,.28); color: #fff; }

@media (max-width: 480px) {
    .klz-chat { right: 14px; bottom: 14px; }
    .klz-chat-panel { bottom: 70px; height: calc(100vh - 100px); }
    .kc-bubble.photo img { width: 180px; }
    .kc-bubble.photo .kc-photo-name { max-width: 180px; }
}
