/* chat.css */

/* ───── 상단 고정 메뉴 ───── */
.chat-menu {
  position: sticky;
  top: 0;
  height: 50px;
  background: #fff;
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid #ddd;
}

/* 기본: 접힌 상태에서는 메뉴 숨김 */
#chat_menu {
  display: none;
}

/* 펼침 상태에서만 메뉴 표시 */
.chat-wrap.active > #chat_menu {
  display: flex;
}

/* ───── 전체 채팅 박스 ───── */
.chat-wrap {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  font-size: 14px;
  background: #f9f9f9;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: height 0.2s ease-in-out;
}

.chat-wrap.active {
  height: calc(100dvh - 100px);
}

/* ───── 접힌 채팅 미리보기 ───── */
#chat_log_preview.chat-log-preview {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: flex-start !important;
  height: 90px;
  background: #f9f9f9;
  cursor: pointer;
  overflow: hidden !important;
  box-sizing: border-box;
  padding: 0 4px !important;
}

.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%;
}

#chat_log_preview .preview-msg img.chat-emoji {
  height: 1em;
  max-width: 1.2em;
  display: inline-block;
  vertical-align: middle;
}

/* ───── 채팅 로그 영역 ───── */
.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-size: 0.9em;
  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.self .meta {
  text-align: right;
}

/* 상대방 메시지 */
.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 #ddd;
  background: #f1f1f1;
  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 #ccc;
  border-radius: 4px;
  outline: none;
  font-size: 14px;
  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: #aaa;
  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-send-btn:hover {
  background: #E0F7FF;
}

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

/* 옵션 버튼 */
.chat-option-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: #ff9100;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.chat-option-btn:hover {
  background: #ffe0b2;
}

/* 접힘 버튼 */
.chat-preview-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: #ff9100;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  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 .chat-emoji {
  width: 32px;
  height: 32px;
  vertical-align: middle;
  margin: 0 2px;
}

/* 채팅 본문 내 스티커 */
.text .chat-sticker {
  width: 64px;
  height: 64px;
  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;
}

/* ───── 참여자 목록 모달 ───── */
.participants-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  display: none;
  align-items: center; justify-content: center;
  z-index: 2000;
}
.participants-modal.visible {
  display: flex;
}
.participants-modal-overlay {
  position: absolute; top:0; left:0; width:100%; height:100%;
  background: rgba(0,0,0,0.5);
}
.participants-modal-content {
  position: relative;
  background: #fff;
  border-radius: 6px;
  width: 300px;
  max-height: 80%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.participants-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #ddd;
}
.modal-title {
  font-size: 16px;
  font-weight: bold;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}
.participants-modal-body {
  padding: 8px 12px;
  overflow-y: auto;
}
#participants_list {
  list-style: none;
  margin: 0;
  padding: 0;
}
#participants_list li {
  padding: 6px 0;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
#participants_list li:hover {
  background: #f5f5f5;
}
