/* File: /theme/responsive/chat/chat.css */

/* === 서로 다른 느낌의 한글 폰트 5종(전역 선로딩) === */
@import url('https://fonts.googleapis.com/css2?family=Gowun+Dodum&display=swap');           /* 고운돋움(담백 산세리프) */
@import url('https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&display=swap'); /* 고운바탕(세리프) */
@import url('https://fonts.googleapis.com/css2?family=Black+Han+Sans&display=swap');       /* 블랙한산스(헤비 디스플레이) */
@import url('https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap');             /* 도현(두툼) */
@import url('https://fonts.googleapis.com/css2?family=Jua&display=swap');                  /* 주아(부드러운 디스플레이) */


/* 상단 고정 영역 높이 변수: 탭바 높이만 반영(35px) */
:root { --chat-top: 100px; }

/* 접힌 상태 기본 글꼴/크기 유지 */
.chat-wrap:not(.active) { font-family: inherit !important; font-size: inherit !important; }
.chat-wrap:not(.active) #chat_log_preview,
.chat-wrap:not(.active) #chat_log_preview .preview-msg { font-family: inherit !important; font-size: inherit !important; }

/* ───── 탭 네비(상단) — 고정 높이/정렬 ───── */
.chat-room-nav { display: flex; align-items: center; width: 100%; margin: 0; text-align: left; height: 35px; }
.chat-wrap.active .chat-room-nav {
  justify-content: flex-start !important;
  background: linear-gradient(to bottom, #9a9a9a, #6f6f6f);
  box-shadow: inset 0 1px #bdbdbd, inset 0 -1px #444;
}
.room-nav-btn { display: none; }

/* 접힘: dot 인디케이터 */
.chat-wrap:not(.active) .chat-tabs { display: none; }
.chat-wrap:not(.active) .chat-room-nav { margin: 8px 0 0 0; }
.chat-wrap:not(.active) .chat-room-nav { height: auto; }
.chat-wrap:not(.active) .chat-room-nav { justify-content: center !important; }
.chat-wrap:not(.active) .room-indicator,
.chat-wrap:not(.active) #collapsed_room_indicator {
  display: flex !important; justify-content: center !important; margin: 0 auto !important; gap: 5px;
  touch-action: pan-y; user-select: none; pointer-events: auto; z-index: 2;
}
.room-dot {
  width: 20px; height: 6px; border: none; background-color: #00ffd9; cursor: pointer; padding: 0;
  transition: background-color 0.25s, width 0.25s;
}
.room-dot.active { background-color: #e04bfd; width: 20px; }

/* ───── 탭 목록 ───── */
.chat-tabs {
  display: flex;
  padding: 0 !important;
  margin: 0 !important;
  list-style: none;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  background: linear-gradient(to bottom, #9a9a9a, #6f6f6f);
  border-bottom: 1px solid #444;
  box-shadow: inset 0 1px #bdbdbd, inset 0 -1px #444;
  height: 35px;
}
.chat-tabs::-webkit-scrollbar { height: 6px; }
.chat-tabs::-webkit-scrollbar-thumb { background: #cfcfcf; border-radius: 3px; }
.chat-tabs::-webkit-scrollbar-track { background: transparent; }
.chat-tabs li {
  position: relative;
  cursor: pointer;
  padding: 5px 10px !important;
  margin: 0 !important;
  flex: 0 0 auto;
  background: transparent;
  color: #e2e2e2;
  text-shadow: 1px 1px 2px rgba(46,46,46,.8), -1px -1px 2px rgba(0,0,0,.8);
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
  user-select: none;
  border-right: 1px solid #555;
  letter-spacing: 2px;
  line-height: 25px; /* 35px 높이 내에서 수직정렬 */
}

/* 호버/활성 */
.chat-tabs li:hover::after { animation: chatSheen .85s ease forwards; }
.chat-tabs li:hover {
  background: linear-gradient(145deg, #a0a0a0, #666);
  color: #ffffff;
  box-shadow:
    inset 1px 1px 3px rgba(0,0,0,.45),
    inset -1px -1px 3px rgba(255,255,255,.45);
}
.chat-tabs li.active {
  background: linear-gradient(145deg, #707070, #4d4d4d);
  color: #252525;
  font-weight: 700;
  text-shadow:
    -0.7px -0.7px 0 #d1d1d1,
     0.7px -0.7px 0 #d1d1d1,
    -0.7px  0.7px 0 #d1d1d1,
     0.7px  0.7px 0 #d1d1d1;
  letter-spacing: 2px;
}

/* 탭 배지 */
.room-tab-convlist .conv-badge,
.room-tab.room-tab-convlist .conv-badge {
  display:inline-block; margin-left:6px; padding:0 6px;
  min-width:18px; height:18px; line-height:18px;
  border-radius:9px; background:#ff4d4f; color:#fff; font-size:11px; font-weight:700;
  vertical-align:middle;
}

/* ───── 상단 탑메뉴(탭 바로 밑에 sticky) ───── */
.chat-menu, #chat_menu {
  position: sticky;
  top: 35px; /* 탭바 높이와 동일 */
  height: 35px;
  background: linear-gradient(to bottom, #9a9a9a, #6f6f6f);
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 8px;
  gap: 8px;
  box-shadow: inset 0 1px #bdbdbd, inset 0 -1px #444, 0 2px 6px rgba(0,0,0,.4);
}
#chat_menu { display: none; }
.chat-wrap.active > #chat_menu { display: flex; }

/* 상단 버튼 */
#chat_menu button {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #8d8d8d, #5c5c5c);
  border: none; outline: none;
  cursor: pointer;
  padding: 6px 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease, background .18s ease;
  box-shadow: inset 2px 2px 4px #4a4a4a, inset -2px -2px 4px #a5a5a5;
}
#chat_menu button i {
  font-size: 14px;
  color: #e2e2e2;
  text-shadow: 1px 1px 2px rgba(46,46,46,.8), -1px -1px 2px rgba(0,0,0,.8);
}
#chat_menu button::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,.18) 45%, rgba(255,255,255,.32) 50%, rgba(255,255,255,.18) 55%, transparent 100%);
  transform: translateX(-120%); pointer-events: none;
}
#chat_menu button:hover::after { animation: chatSheen .85s ease forwards; }
#chat_menu button:hover {
  background: linear-gradient(145deg, #a0a0a0, #666);
  box-shadow:
    inset 1px 1px 3px #3a3a3a,
    inset -1px -1px 3px #cfcfcf,
    0 0 0 1px rgba(255,255,255,.06),
    0 6px 14px rgba(0,0,0,.35);
  transform: translateY(-1px);
  filter: contrast(1.03) saturate(1.02);
}
#chat_menu button:hover i { color: #f5f5f5; }
#chat_menu button:active {
  background: linear-gradient(145deg, #707070, #4d4d4d);
  box-shadow:
    inset 3px 3px 6px #2a2a2a,
    inset -3px -3px 6px #b0b0b0,
    0 0 0 1px rgba(255,255,255,.04),
    0 2px 6px rgba(0,0,0,.32);
  transform: scale(0.96);
}
#chat_menu button:active i { color: #cfcfcf; }

/* 접근성 텍스트 */
#chat_menu .sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* 셰인 애니메이션 */
@keyframes chatSheen {
  0%   { transform: translateX(-120%) rotate(0.001deg); }
  100% { transform: translateX(120%)  rotate(0.001deg); }
}
@media (prefers-reduced-motion: reduce) {
  #chat_menu button:hover::after { animation: none; opacity: .12; transform: translateX(0); }
}

/* ───── 전체 채팅 박스 ───── */
/* 기본(모바일): 화면 하단 고정 */
.chat-wrap {
  position: fixed; bottom: 0; left: 0; width: 100%;
  background: #f9f9f9; z-index: 1000; display: flex; flex-direction: column;
  transition: height 0.2s ease-in-out;
  --chat-msg-font: "Noto Sans KR","Apple SD Gothic Neo","Malgun Gothic","Segoe UI",Arial,sans-serif;
  --chat-msg-font-size: 14px;
}

/* 높이 대응 */
@supports (height: 100svh) { .chat-wrap.active { height: calc(100svh - var(--chat-top)); } }
@supports (height: 100dvh) and (not (height: 100svh)) { .chat-wrap.active { height: calc(100dvh - var(--chat-top)); } }
@supports not (height: 100svh) { .chat-wrap.active { height: calc(var(--vh, 1vh) * 100 - var(--chat-top)); } }
.chat-wrap.active { padding-bottom: env(safe-area-inset-bottom); }

/* ───── 접힌 채팅 미리보기 ───── */
#chat_log_preview.chat-log-preview {
  display: flex !important; flex-direction: column !important; justify-content: center !important; align-items: flex-start !important;
  height: 80px; background: #f9f9f9; cursor: pointer; overflow: hidden !important; box-sizing: border-box; padding: 0 4px !important;
  touch-action: pan-y; user-select: none;
}
.chat-wrap.active #chat_log_preview { display: none !important; }
#chat_log_preview.login-required .chat-login-required { width: 100%; text-align: center; font-size: 16px; color: #444; }
#chat_log_preview .preview-msg {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 4px 8px; box-sizing: border-box; width: 100%;
  font-family: var(--chat-msg-font, "Noto Sans KR","Apple SD Gothic Neo","Malgun Gothic","Segoe UI",Arial,sans-serif) !important;
}

/* ───── 채팅 로그 영역 ───── */
.chat-wrap.active #chat_log { display: block; flex: 1; overflow-y: auto; padding: 10px; background: #fff; position: relative; }
.chat-log, .chat-input-row { display: none; }

/* 날짜 라벨 */
.chat-date-label { text-align: center; margin: 10px 0; font-weight: bold; }

/* 메시지 */
.msg { display: flex; margin: 4px 0; }
.bubble { max-width: 70%; padding: 8px 12px; border-radius: 16px; word-break: break-word; line-height: 1.4; position: relative; }
.text {
  font-family: var(--chat-msg-font, "Noto Sans KR","Apple SD Gothic Neo","Malgun Gothic","Segoe UI",Arial,sans-serif) !important;
  font-size: var(--chat-msg-font-size, 14px) !important;
  color: #333; white-space: pre-line;
}
.meta { font-size: 0.75em; color: #666; margin-top: 4px; position: relative; text-align: right; }

/* 삭제 버튼 */
.chat-del-btn { background: none; border: none; color: #999; font-size: 13px; margin-left: 8px; cursor: pointer; padding: 0; vertical-align: middle; }
.chat-del-btn i { pointer-events: none; }
.chat-del-btn:hover { color: #e74c3c; }

/* 본인/상대 */
.msg.self { justify-content: flex-end; }
.msg.self .bubble { background: #dcf8c6; }
.msg.other { justify-content: flex-start; }
.msg.other .bubble { background: #fff; border: 1px solid #ddd; margin-left: 8px; border-radius: 16px 16px 16px 4px; }

/* ───── 입력 영역 ───── */
.chat-wrap.active .chat-input-row {
  display: flex;
  align-items: center;
  padding: 10px 6px;
  border-top: 1px solid #555; 
  background: linear-gradient(to bottom, #6f6f6f, #3b3b3b);
  box-shadow: inset 0 1px #bdbdbd, inset 0 -1px #444, 0 2px 6px rgba(0,0,0,.4);
  gap: 8px;
}
.chat-input-row { position: relative; }
.input-wrapper { position: relative; flex: 1; }

/* contenteditable 입력창 */
.input-wrapper .chat-input {
  width: 100%; height: 56px; overflow-y: hidden; padding: 10px 50px 10px 10px; border: 1px solid #838383; border-radius: 4px; outline: none; font-size: 14px; caret-color: #9e9e9e;
  box-sizing: border-box; line-height: 1.4; white-space: pre-wrap; word-break: break-word; cursor: text;
}
.input-wrapper .chat-input.empty:before { content: attr(data-placeholder); color: #cfcfcf; pointer-events: none; }

/* 전송 버튼 */
.chat-send-btn { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; background: none; border: none; color: #87CEEB; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: background 0.15s; }

/* 글자수 */
#chat_char_count { position: absolute; bottom: 8px; right: 10px; font-size: 0.75em; color: #b3b3b3; pointer-events: none; background: transparent; line-height: 1; }
#chat_char_count.warning { color: #e74c3c; }

/* 옵션 버튼(+) / 접힘 버튼(∨) 공통 */
.chat-option-btn,
.chat-preview-btn {
  width: 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  outline: none;
  cursor: pointer;
  border-radius: 6px;
  background: linear-gradient(145deg, #8d8d8d, #5c5c5c); /* 실버톤 */
  color: #e2e2e2;  /* 아이콘 은색 */
  text-shadow: 1px 1px 2px rgba(46,46,46,.8), -1px -1px 2px rgba(0,0,0,.8); /* 음각 효과 */
  box-shadow: inset 2px 2px 4px #4a4a4a, inset -2px -2px 4px #a5a5a5; /* 안쪽 입체감 */
  transition: background .2s ease, box-shadow .2s ease, color .2s ease;
}

/* hover: 더 밝은 실버 + 하이라이트 */
.chat-option-btn:hover,
.chat-preview-btn:hover {
  background: linear-gradient(145deg, #a0a0a0, #6a6a6a);
  color: #ffffff;
  box-shadow:
    inset 1px 1px 3px #3a3a3a,
    inset -1px -1px 3px #cfcfcf,
    0 0 6px rgba(0,0,0,.25);
}

/* active: 더 눌린 효과 */
.chat-option-btn:active,
.chat-preview-btn:active {
  background: linear-gradient(145deg, #707070, #4d4d4d);
  color: #dcdcdc;
  box-shadow:
    inset 3px 3px 6px #2a2a2a,
    inset -3px -3px 6px #b0b0b0;
  transform: scale(0.95);
}

/* 개별 크기만 유지 */
.chat-option-btn { font-size: 18px; }
.chat-preview-btn { font-size: 16px; }

/* 스크롤 아래 버튼 */
.chat-scroll-btn { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%); background: #3498db; color: #fff; border: none; border-radius: 4px; padding: 6px 10px; cursor: pointer; font-size: 12px; z-index: 10; display: none; }

/* ───── 링크/파일/이미지 (중복 정리: 본문/입력창 이모지 규칙 병합) ───── */
.chat-link { color: #1e90ff; text-decoration: underline; word-break: break-word; }
.image-wrapper { margin: 4px 0; }
.chat-image { max-width: 70%; height: auto; border-radius: 4px; }
/* ⬇ 이모지 크기: 본문(.text) + 입력창(contenteditable) 한 번에 */
.text img.chat-emoji,
.input-wrapper .chat-input img.chat-emoji {
  width: 30px;
  height: 30px;
  vertical-align: middle;
  margin: 0 2px;
}
/* 스티커(본문) */
.text img.chat-sticker {
  width: 60px;
  height: 60px;
  vertical-align: middle;
  margin: 0 2px;
}
.file-wrapper { margin: 4px 0; }
.chat-file { display: inline-flex; align-items: center; font-size: 0.9em; color: #1e90ff; text-decoration: none; }
.chat-file i { margin-right: 4px; }

/* ───── 이모지/스티커 선택창 ───── */
#chat_options_panel.hidden,
#emoji_picker.hidden,
#sticker_picker.hidden { display: none !important; }

#chat_options_panel {
  background: linear-gradient(to bottom, #5e5e5e, #363636);
  padding: 10px 10px 0px 10px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  border-top: 1px solid #444;
  border-left: 1px solid #444;
  border-right: 1px solid #444;
  border-bottom: 1px solid #444;
}

/* ───── 옵션 버튼(이모지/스티커/첨부) ───── */
.opt-btn[data-opt="emoji"],
.opt-btn[data-opt="sticker"],
.opt-btn[data-opt="attach"] {
  width: 32px;
  height: 32px;
  border: none;
  outline: none;
  border-radius: 6px;
  background: linear-gradient(145deg, #8d8d8d, #5c5c5c);
  color: #e2e2e2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  text-shadow: 1px 1px 2px rgba(46,46,46,.8), -1px -1px 2px rgba(0,0,0,.8);
  box-shadow: inset 2px 2px 4px #4a4a4a, inset -2px -2px 4px #a5a5a5;
  transition: background .2s ease, box-shadow .2s ease, transform .15s ease, color .2s ease;
}
/* opt-btn hover/active — 어두운 톤(덮어쓰기 보장) */
.opt-btn[data-opt="emoji"]:hover,
.opt-btn[data-opt="sticker"]:hover,
.opt-btn[data-opt="attach"]:hover {
  background: linear-gradient(145deg, #7a7a7a, #4a4a4a) !important;
  color: #f0f0f0;
  box-shadow:
    inset 1px 1px 3px #2a2a2a,
    inset -1px -1px 3px #b0b0b0,
    0 0 4px rgba(0,0,0,.3);
  transform: translateY(-1px);
}
.opt-btn[data-opt="emoji"]:active,
.opt-btn[data-opt="sticker"]:active,
.opt-btn[data-opt="attach"]:active {
  background: linear-gradient(145deg, #707070, #4d4d4d) !important;
  color: #dcdcdc;
  box-shadow:
    inset 3px 3px 6px #2a2a2a,
    inset -3px -3px 6px #b0b0b0;
  transform: scale(0.95);
}

/* 피커 */
#emoji_picker { display: grid; grid-template-columns: repeat(8, minmax(16px, 1fr)); gap: 6px; max-height: 220px; overflow-y: auto; padding: 6px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#emoji_picker img.chat-emoji { width: 25px; height: 25px; cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  outline: none;
  border-radius: 4px;
  transition: transform .06s ease, box-shadow .06s ease, background-color .06s ease;
}
#emoji_picker img.chat-emoji:active,
#emoji_picker img.chat-emoji.pressed {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #87ceeb inset;
  background-color: rgba(135,206,235,.15);
}

#sticker_picker { display: grid; grid-template-columns: repeat(4, minmax(56px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; padding: 6px; }
#sticker_picker img.chat-sticker { width: 72px; height: 72px; object-fit: contain; cursor: pointer; }

/* 인라인 메뉴(1:1) */
.chat-inline-menu { position: relative; display: inline-block; margin-right: 6px; vertical-align: middle; }
.chat-inline-menu .menu-toggle { background: none; border: none; cursor: pointer; color: #666; padding: 0 2px; }
.chat-inline-menu .menu-toggle:hover { color: #333; }
.chat-inline-menu .menu-dropdown {
  display: none; position: absolute; top: 18px; left: 0; min-width: 100px; background: #fff; border: 1px solid #ddd; border-radius: 4px; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.chat-inline-menu.open .menu-dropdown { display: block; }
.chat-inline-menu .menu-dropdown button { display: block; width: 100%; padding: 6px 10px; background: none; border: none; text-align: left; font-size: 13px; cursor: pointer; }
.chat-inline-menu .menu-dropdown button:hover { background: #f5f5f5; }

/* DM 대화목록 */
.conv-list { background:#fff; border-bottom:1px solid #eee; }
.conv-list.hidden { display:none; }
.conv-list-ul { list-style:none; margin:0; padding:0; }
.conv-li { position: relative; border-bottom: 1px solid #f2f2f2; }
.conv-li .conv-item {
  display:flex; align-items:center; width:100%;
  padding:10px 40px 10px 12px; gap:10px;
  background:#fff; border:0; text-align:left; cursor:pointer;
}
.conv-li .conv-label { flex:1 1 auto; font-weight:600; color:#222; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conv-li .conv-time { flex:0 0 auto; color:#777; font-size:12px; }
.conv-li .conv-close {
  position:absolute; right:8px; top:50%; transform:translateY(-50%);
  width:28px; height:28px; border:0; background:#fff; color:#999; font-size:18px; line-height:1; cursor:pointer; border-radius:4px;
}
.conv-li .conv-close:hover { background:#f5f5f5; color:#e74c3c; }

/* 미읽음 배지 */
.conv-li .conv-unread {
  position:absolute; right:44px; top:50%; transform:translateY(-50%);
  min-width:18px; height:18px; padding:0 6px;
  border-radius:9px; background:#ff4d4f; color:#fff;
  font-size:11px; font-weight:700; line-height:18px; text-align:center;
}

/* 시스템 메시지 */
.msg.system .system-line { text-align:center; color:#888; font-size:12px; padding:4px 8px; }

/* DM 헤더 */
.dm-sticky-header, .chat-dm-header {
  margin: 0 !important;
  padding: 5px;
  border-top: 1px solid #6c63ff;
  background: linear-gradient(135deg, #6cb4cf, #928DAB);
  border-bottom: 1px solid #6c63ff;
  font-size: 14px; color: #fff; letter-spacing: .5px; text-align: center;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.chat-wrap.active .chat-room-nav + .dm-sticky-header,
.chat-wrap.active .chat-room-nav + .chat-dm-header { margin-top: 0 !important; }
.chat-wrap.active .chat-room-nav { margin-bottom: 0 !important; }
.chat-wrap.active .chat-tabs { margin-bottom: 0 !important; }

/* 탭/내비 UI 글꼴 고정 */
.chat-wrap .chat-room-nav,
.chat-wrap .chat-tabs,
.chat-wrap .chat-tabs li,
.chat-wrap .dm-sticky-header,
.chat-wrap .chat-dm-header {
  font-family: "Noto Sans KR","Malgun Gothic",Arial,sans-serif !important;
}

/* ─────────────────────────────
   접힌 전용 커스텀(투명 배경 + 민트 포인트)
   ───────────────────────────── */
.chat-wrap:not(.active) #chat_log_preview.chat-log-preview { background: transparent !important; box-shadow: none !important; }
.chat-wrap:not(.active) #collapsed_room_indicator,
.chat-wrap:not(.active) .room-indicator { background: transparent !important; }
.chat-wrap:not(.active) { background: rgba(0,0,0,0.8) !important; }
.chat-wrap:not(.active) #chat_log_preview .preview-msg { color: #06dfb7 !important; }
.chat-wrap:not(.active) #chat_log_preview .preview-msg b { color: #97eee1 !important; font-weight: 700 !important; }

/* ─────────────────────────────────────────────
   PC 강제 펼침 모드 (min-width:1024px)
   - 미리보기(#chat_log_preview) 숨김
   - 로그/입력영역 강제 노출
   - 상단 메뉴(#chat_menu) 항상 표시
   - 접기 버튼 비노출(원하면 주석 해제)
   ───────────────────────────────────────────── */
@media (min-width: 1024px) {
    .chat-wrap {
        position: sticky;
        top: var(--chat-top, 100px);
        bottom: auto;
        left: auto;
        width: 100%;
        z-index: 1;
        height: calc(100vh - var(--chat-top, 100px));
    }
}
