/*!
 * 포우홀샵 실시간 상담 위젯 스타일
 * 사이트 현대화 톤(인디고~바이올렛)과 통일.
 */
.powuh-chat, .powuh-chat * { box-sizing: border-box; }
.powuh-chat {
    --kc-primary: #10b981;
    --kc-primary-2: #1FD192;
    --kc-grad: linear-gradient(135deg, #10b981 0%, #1FD192 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, #10b981 0%, #14b884 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;
}

/* 런처 버튼 */
.powuh-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(16,185,129,.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;
}
.powuh-chat-launcher:hover { transform: translateY(-2px) scale(1.04); }
.powuh-chat-launcher .ico-close { display: none; }
.powuh-chat.is-open .powuh-chat-launcher .ico-chat { display: none; }
.powuh-chat.is-open .powuh-chat-launcher .ico-close { display: block; }
.powuh-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;
}

/* 패널. 부모(런처 60px) 밖 absolute 이면 모바일에서 입력칸 탭이 안 먹는다. */
.powuh-chat-panel {
    position: fixed; right: 20px; bottom: 94px;
    width: 370px; max-width: calc(100vw - 32px);
    height: 560px; max-height: calc(100vh - 120px);
    height: min(560px, calc(100dvh - 120px));
    max-height: calc(100dvh - 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;
    animation: powuhChatIn .18s ease;
}
.powuh-chat-panel[hidden],
.powuh-chat-intro[hidden],
.powuh-chat-body[hidden],
.powuh-chat-input[hidden],
.powuh-chat-foot[hidden] { display: none !important; }
@keyframes powuhChatIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* 헤더 */
.powuh-chat-head {
    background: var(--kc-grad);
    color: #fff; padding: 16px 16px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.powuh-chat-title { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.powuh-chat-status { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; opacity: .92; }
.powuh-chat-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; box-shadow: 0 0 0 0 rgba(255,255,255,.5); }
.powuh-chat-status .dot.online { background: #4ade80; animation: powuhPulse 2s infinite; }
@keyframes powuhPulse { 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)} }
.powuh-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; }
.powuh-chat-headbtn:hover { background: rgba(255,255,255,.28); }

/* 사전 입력 폼 */
.powuh-chat-intro { padding: 26px 20px; flex: 1; min-height: 0; overflow-y: auto; }
.powuh-chat-intro-lead { margin: 4px 0 20px; font-size: 14px; line-height: 1.6; color: var(--kc-text); text-align: center; }
.powuh-chat-field { margin-bottom: 10px; }
.powuh-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;
}
.powuh-chat-field input:focus { outline: 0; border-color: var(--kc-primary); box-shadow: 0 0 0 3px rgba(16,185,129,.14); }
.powuh-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(16,185,129,.5);
    transition: filter .15s ease, transform .12s ease;
}
.powuh-chat-startbtn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.powuh-chat-intro-note { margin: 14px 0 0; font-size: 11px; color: var(--kc-muted); text-align: center; }

/* 메시지 영역. min-height:0 이 없으면 대화가 길어질 때 입력칸이 패널 밖으로 밀려 잘린다. */
.powuh-chat-body { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.powuh-chat-body::-webkit-scrollbar { width: 8px; }
.powuh-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-row.photo .kc-bubble { padding: 0; overflow: hidden; background: transparent; border: 0; box-shadow: none; position: relative; line-height: 0; }
.kc-photo { display: block; }
.kc-photo img {
    display: block; max-width: 220px; max-height: 260px;
    width: auto; height: auto; border-radius: 14px;
    border: 1px solid var(--kc-line); background: #fff;
    cursor: zoom-in;
    box-shadow: 0 1px 3px rgba(16,24,40,.10);
    transition: filter .15s ease;
}
.kc-photo:hover img { filter: brightness(.94); }
.kc-row.user.photo .kc-photo img { border-bottom-right-radius: 5px; }
.kc-row.agent.photo .kc-photo img { border-bottom-left-radius: 5px; }

/* 전송 중 */
.kc-row.pending .kc-photo img { opacity: .55; cursor: default; }
.kc-uploading {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    padding: 7px 0; font-size: 11.5px; line-height: 1; font-weight: 600; color: #fff;
    background: rgba(15,23,42,.62); border-radius: 0 0 14px 14px;
}
.kc-spin {
    width: 12px; height: 12px; border-radius: 50%; display: inline-block;
    border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
    animation: powuhSpin .7s linear infinite;
}
@keyframes powuhSpin { to { transform: rotate(360deg); } }
.kc-progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(15,23,42,.18); border-radius: 14px 14px 0 0; overflow: hidden; }
.kc-progress i { display: block; width: 0; height: 100%; background: var(--kc-primary-2); transition: width .15s ease; }

/* 드래그 앤 드롭 안내 */
.powuh-chat-drop {
    position: absolute; top: 8px; right: 8px; bottom: 8px; left: 8px; inset: 8px; z-index: 3;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    border: 2px dashed var(--kc-primary); border-radius: 14px;
    background: rgba(16,185,129,.09); color: var(--kc-primary);
    font-size: 13px; font-weight: 700; pointer-events: none;
}
.powuh-chat-drop[hidden] { display: none; }

/* 사진 크게보기 */
.powuh-chat-lightbox {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 100010;
    display: flex; align-items: center; justify-content: center;
    padding: 40px 20px; background: rgba(9,13,26,.88);
    animation: powuhChatIn .15s ease; cursor: zoom-out;
}
.powuh-chat-lightbox[hidden] { display: none; }
.powuh-chat-lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); cursor: default; }
.powuh-lb-close {
    position: absolute; top: 16px; right: 16px; width: 42px; height: 42px;
    border: 0; border-radius: 50%; cursor: pointer;
    background: rgba(255,255,255,.14); color: #fff;
    display: flex; align-items: center; justify-content: center; transition: background .15s ease;
}
.powuh-lb-close:hover { background: rgba(255,255,255,.28); }

/* 입력 영역 */
.powuh-chat-input {
    position: relative; z-index: 2;
    flex-shrink: 0; display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px; background: #fff; border-top: 1px solid var(--kc-line);
}
.powuh-chat-attachbtn {
    flex-shrink: 0; width: 42px; height: 42px; border: 1px solid var(--kc-line);
    border-radius: 12px; cursor: pointer; background: #fff; color: var(--kc-muted);
    display: flex; align-items: center; justify-content: center;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.powuh-chat-attachbtn:hover { color: var(--kc-primary); border-color: var(--kc-primary); background: rgba(16,185,129,.07); }
.powuh-chat-attachbtn:disabled { opacity: .45; cursor: default; }
.powuh-chat-input textarea {
    flex: 1; min-width: 0; 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);
    -webkit-user-select: text; user-select: text; touch-action: manipulation;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.powuh-chat-input textarea:focus { outline: 0; border-color: var(--kc-primary); box-shadow: 0 0 0 3px rgba(16,185,129,.14); }
.powuh-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;
}
.powuh-chat-sendbtn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.powuh-chat-sendbtn:disabled { opacity: .5; cursor: default; transform: none; filter: none; }

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

@media (max-width: 480px) {
    .powuh-chat { right: 14px; bottom: 14px; }
    .powuh-chat-panel {
        right: 14px; left: 14px; width: auto; bottom: 84px;
        height: calc(100vh - 110px);
        height: calc(100dvh - 110px);
        max-height: calc(100vh - 110px);
        max-height: calc(100dvh - 110px);
    }
    /* 16px 미만이면 iOS가 입력 포커스 때 화면을 확대해 입력칸이 밀린다 */
    .powuh-chat-field input,
    .powuh-chat-input textarea { font-size: 16px; }
}
