/* 상담 채팅 모양 (2026-10-24 지시서 004). 손님 화면 + 관리자 상담 화면이 같이 쓴다 */

/* ---------- 손님: 동그란 버튼 ---------- */
.chat-fab { position: fixed; z-index: 40; right: max(16px, calc(50vw - 240px + 16px)); bottom: calc(20px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--honey, #FFD666); color: var(--text, #33200D); display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(51, 32, 13, .28); }
.chat-fab .ico { width: 28px; height: 28px; }
.chat-dot { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #E5432B; color: #fff; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center; box-sizing: border-box; }
.chat-dot[hidden] { display: none; }
body:has(.tabbar) .chat-fab { bottom: calc(78px + env(safe-area-inset-bottom)); }
body:has(.buybar) .chat-fab { bottom: calc(90px + env(safe-area-inset-bottom)); }
body:has(.chat-win:not([hidden])) .chat-fab { display: none; }

/* ---------- 손님: 상담 창 ---------- */
.chat-win { position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; top: 8px; display: flex; flex-direction: column; background: var(--bg, #FFF8E8); border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); overflow: hidden; animation: chat-up .22s ease-out; }
.chat-win[hidden] { display: none; }
@keyframes chat-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) {
  body .chat-fab, body:has(.tabbar) .chat-fab, body:has(.buybar) .chat-fab { right: 24px; bottom: 24px; }
  .chat-win { left: auto; right: 24px; bottom: 24px; top: auto; width: 380px; height: min(600px, calc(100vh - 48px)); border-radius: 18px; }
}
.chat-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; background: var(--text, #33200D); color: #FFF3D1; }
.chat-head b { display: block; font-size: 16px; }
.chat-head small { display: block; font-size: 12px; opacity: .8; margin-top: 2px; }
.chat-x { border: 0; background: transparent; color: inherit; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 50%; }
.chat-x .ico { width: 22px; height: 22px; }
.chat-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.chat-composer { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--surface, #fff); border-top: 1px solid var(--line, #eadfca); }
.chat-composer[hidden] { display: none; }
.chat-composer textarea { flex: 1; min-height: 40px; max-height: 120px; resize: none; padding: 9px 12px; border-radius: 12px; border: 1.5px solid var(--line, #eadfca); font: inherit; font-size: 15px; background: var(--bg, #fff); color: var(--text, #33200D); box-sizing: border-box; }
.chat-attach, .chat-send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.chat-attach { background: var(--surface2, #F6EBD2); color: var(--text, #33200D); }
.chat-send { background: var(--honey, #FFD666); color: var(--text, #33200D); }
.chat-attach .ico, .chat-send .ico { width: 20px; height: 20px; }

/* 처음 화면(인사 + 자주 묻는 버튼) · 시작 칸 */
.chat-hello { background: var(--surface, #fff); border-radius: 14px; padding: 14px; font-size: 14.5px; line-height: 1.6; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.chat-faq { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chat-faq button, .chat-go { min-height: 44px; padding: 8px 10px; border-radius: 12px; border: 1.5px solid var(--line, #eadfca); background: var(--surface, #fff); color: var(--text, #33200D); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; }
.chat-go { background: var(--honey, #FFD666); border-color: transparent; }
.chat-form { display: flex; flex-direction: column; gap: 8px; background: var(--surface, #fff); border-radius: 14px; padding: 14px; }
.chat-form label { font-size: 13px; font-weight: 700; display: flex; flex-direction: column; gap: 4px; }
.chat-form input[type=text], .chat-form input[type=email] { height: 42px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--line, #eadfca); font: inherit; font-size: 15px; box-sizing: border-box; background: var(--bg, #fff); color: var(--text, #33200D); }
.chat-form .chat-check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 500; font-size: 13px; line-height: 1.5; }
.chat-form .chat-check input { margin-top: 3px; }
.chat-err { color: #C23A22; font-size: 13px; font-weight: 700; min-height: 18px; }
.chat-note { font-size: 12px; color: var(--sub, #8B7258); }

/* ---------- 말풍선 (손님·관리자 같이) ---------- */
.cm { position: relative; display: flex; flex-direction: column; max-width: 82%; gap: 3px; }
.cm-customer { align-self: flex-end; align-items: flex-end; }
.cm-admin { align-self: flex-start; align-items: flex-start; }
.cm-system { align-self: center; align-items: center; max-width: 92%; }
.cm-bubble { padding: 9px 12px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.cm-customer .cm-bubble { background: #FFD666; color: #33200D; border-bottom-right-radius: 4px; }
.cm-admin .cm-bubble { background: #fff; color: #33200D; border: 1px solid var(--line, #eadfca); border-bottom-left-radius: 4px; }
.cm-system .cm-bubble { background: #ECE7DE; color: #6B5B45; font-size: 13px; text-align: center; border-radius: 12px; }
.cm-bubble.recalled { background: transparent !important; border: 1px dashed var(--line, #cdbf9f) !important; color: var(--sub, #8B7258); font-style: italic; }
.cm-meta { font-size: 11px; color: var(--sub, #8B7258); display: flex; gap: 6px; align-items: center; }
.cm-img { display: block; max-width: 220px; max-height: 220px; border-radius: 12px; cursor: zoom-in; background: #eee; object-fit: cover; }
.cm-tools { display: none; position: absolute; top: -30px; z-index: 5; gap: 4px; padding: 3px; border-radius: 10px; background: #33200D; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.cm-customer .cm-tools { right: 0; }
.cm-admin .cm-tools, .cm-system .cm-tools { left: 0; }
.cm:hover .cm-tools, .cm.show-menu .cm-tools { display: flex; }
.cm-tools button, .cm-tools a { border: 0; background: transparent; color: #FFF3D1; font: inherit; font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.cm-tools button:hover, .cm-tools a:hover { background: rgba(255, 255, 255, .15); }
.chat-lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .85); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.chat-lightbox[hidden] { display: none; }
.chat-lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 8px; }

/* ---------- 관리자 상담 화면 ---------- */
.chat-rooms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chat-rooms a { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface, #fff); color: inherit; text-decoration: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.chat-rooms a.unread { border-left: 4px solid #E5432B; }
.chat-rooms b { font-size: 15px; }
.chat-rooms small { color: var(--sub, #8B7258); }
.chat-rooms .pv { grid-column: 1 / -1; font-size: 14px; color: var(--text, #33200D); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #E5432B; color: #fff; font-size: 12px; font-weight: 800; text-align: center; margin-left: 6px; }
.chat-admin { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.chat-admin .conv { display: flex; flex-direction: column; background: var(--bg, #FFF8E8); border: 1px solid var(--line, #eadfca); border-radius: 16px; overflow: hidden; height: min(72vh, 720px); }
.chat-admin .conv .chat-body { background: var(--bg, #FFF8E8); }
.chat-admin .quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 10px 0; background: var(--surface, #fff); border-top: 1px solid var(--line, #eadfca); }
.chat-admin .quick button { border: 1.5px solid var(--line, #eadfca); background: var(--surface2, #F6EBD2); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-admin .info-toggle { display: none; }
.chat-admin .guest-orders { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chat-admin .guest-orders li { border: 1px solid var(--line, #eadfca); border-radius: 12px; padding: 10px; font-size: 13.5px; background: var(--surface, #fff); }
.chat-admin .guest-orders li.mine { border-color: #3FA56B; }
.chat-admin .guest-orders .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chat-admin .guest-orders .btns form { margin: 0; }
@media (max-width: 900px) {
  .chat-admin { grid-template-columns: 1fr; }
  .chat-admin .info { display: none; }
  .chat-admin .info.open { display: block; }
  .chat-admin .info-toggle { display: inline-flex; margin-bottom: 8px; }
  .chat-admin .conv { height: 70vh; }
}

/* 2026-10-25 대표님 요청: 상담 창 머리에 글자 대신 로고 */
.chat-head .chat-logo { display: block; height: 26px; width: auto; }
.chat-head small { display: block; margin-top: 3px; }
