/* =======================
   플로팅 채팅 DM 리스트 ONLY
======================= */

/* (추가) 검색창/내부 요소 오버플로우 방지 공통 규칙 */
.chat-popup-dm-list,
.chat-popup-dm-list *
.new-chat-modal,
.new-chat-modal * {  
  box-sizing: border-box;
  min-width: 0; /* flex 내부 줄바꿈/넘침 방지 */
}

#chat-float {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  background-color: #7289da; border: none; border-radius: 50%;
  width: 56px; height: 56px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  color: white; font-size: 24px;
  display: flex; justify-content: center; align-items: center;
  cursor: pointer;
}

/* DM 리스트 컨테이너 */
.chat-popup-dm-list {
  position: fixed; bottom: 60px; right: 26px;
  width: 405px; height: 560px;
  background: #fff; box-shadow: 0 2px 15px rgba(0,0,0,0.13);
  border-radius: 17px; overflow: hidden; z-index: 9999;
  display: flex; flex-direction: column;
}
@media (max-width: 700px) {
  .chat-popup-dm-list {
    width: 100vw; height: 100vh; right: 0; bottom: 0; border-radius: 0;
  }
}

.chat-header {
  background: #f8faff;
  padding: 12px 18px 9px 15px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1.3px solid #edefff; min-height: 52px;
}
.chat-title { font-weight: bold; font-size: 18px; color: #2e345a;}
.chat-actions button { background: none; border: none; font-size: 19px; color: #8f99bb; cursor: pointer; border-radius: 8px; padding: 2px 6px;}
.chat-actions button:hover { background: #f3f6fa; color: #4263eb; }

.dm-list-search {
  padding: 13px 18px 10px 17px;
  border-bottom: 1.1px solid #eee;
}
#user-search-input {
  width: 100%; border: 1.2px solid #d9e2f6; border-radius: 8px;
  padding: 7px 12px; font-size: 14px; background: #f9fafe; outline: none;

  /* (추가) 검색창이 박스 밖으로 나가지 않도록 */
  display: block;
  max-width: 100%;
}
#user-search-input:focus { border: 1.4px solid #4263eb; background: #fff; }

.dm-user-list {
  list-style: none; margin: 0; padding: 0 0 10px 0;
  flex: 1 1 auto; overflow-y: auto; background: none; width: 100%;
}
.dm-user-item {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 19px; border-radius: 13px; margin: 1px 1px;
  cursor: pointer; transition: background .14s;
  position: relative; /* X 버튼 위치를 위해 */
}
.dm-user-item:hover { background: #e6eafc; }
.avatar {
  width: 39px; height: 39px; font-size: 21px; background: #e6eafc; /* 기존 유지 */
  border-radius: 50%; /* 추가: 동그랗게 */
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; /* 이미지 원형 자르기 */
}
.avatar img { /* 추가: 이미지 원형/사이즈 일률적 */
  width: 100%; height: 100%; object-fit: cover; border-radius: inherit;
}
.user-info {
  flex: 1; min-width: 0; /* 텍스트 줄바꿈 방지 */
}
.user-nick-time { /* 추가: 두 줄 구조 상단 */
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 2px;
}
.user-nick { font-weight: 500; color: #2e345a; font-size: 14px; }
.last-time { font-size: 12px; color: #8f99bb; }
.last-msg { /* 추가: 두 줄 구조 하단 */
  display: block; font-size: 13px; color: #6b75a1; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-meta {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
}
.unread-dot {
  background: #ff3b30; color: white; border-radius: 10px; padding: 2px 6px;
  font-size: 11px; min-width: 16px; text-align: center;
}

/*새 대화 스타일 추가*/
.new-chat-modal {
  position: fixed; top:0; left:0; width:100vw; height:100vh;
  z-index:12000; display:flex; justify-content:center; align-items:center;
}
.modal-bg {
  position:absolute;top:0;left:0;width:100vw;height:100vh;
  background:rgba(22,24,31,0.24);
}
.modal-content {
  position:relative; z-index:1; background:#fff;
  border-radius:13px; box-shadow:0 2px 19px rgba(0,0,0,0.13);
  width:350px; max-width:94vw; padding:0 0 18px 0;
  display:flex; flex-direction:column;
}
.modal-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:18px 22px 7px 22px; border-bottom:1px solid #eee;
  font-size:17px; font-weight:700; color:#23232e;
}
.close-btn { background:none;border:none;font-size:20px;cursor:pointer;color:#888;}
#new-chat-search {
  width: calc(100% - 36px); margin:18px 18px 0 18px; border:1.1px solid #ccd7f7; border-radius:7px; font-size:15px; padding:8px 13px;

  /* (추가) 모달 내에서도 절대 넘치지 않도록 */
  display: block;
  max-width: calc(100% - 36px);
  box-sizing: border-box; /* ← 이 한 줄 추가 (안전망) */
}
.new-chat-list { list-style:none; margin:11px 0 0 0; padding:0; max-height:210px; overflow-y:auto;}
.new-chat-list .dm-user-item { padding:13px 17px; }
/*새 대화 스타일 끝*/


/* DM 항목 삭제(X) 버튼 */
.dm-user-item {
  position: relative;
}
.dm-delete {
  position: absolute;
  right: 14px; /* 미세 조정: 우측 끝 예쁘게 */
  top: 50%;
  transform: translateY(-50%);
  display: none;
  border: none;
  background: #f2f4ff;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 13px;
  color: #6b75a1;
  cursor: pointer;
  z-index: 1; /* 추가: 오버랩 방지 */
}
.dm-delete:hover {
  background: #e7ebff;
  color: #3f51b5;
}
/* hover 시에만 노출 */
.dm-user-item:hover .dm-delete {
  display: inline-block;
}
@media (max-width:700px) {
  /* 모바일은 항상 보이도록(터치) */
  .dm-delete { display: inline-block; right: 10px; }
}

/* Unread badge for floating chat */
.chat-unread-badge {
  position: fixed;
  right: 16px;  /* 스크린샷처럼 오른쪽 상단으로 미세 조정 */
  bottom: 66px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: #ff3b30;  /* 빨간색 유지 */
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2001;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ---- responsive search sizing (minimal, no design change) ---- */
@media (max-width:700px){

  /* 모바일: 시간 텍스트가 우측 X/배지와 겹치지 않도록 여백 확보 */
  .user-nick-time { padding-right: 10px; } /* DM 삭제(우측 14px) + 배지(우측 38px) 여유 */
  .last-time { margin-right: 6px; }


  /* 모바일: DM 리스트 배지 위치를 X(삭제) 오른쪽 버튼과 겹치지 않도록 왼쪽으로 이동 */
  .dm-user-item .unread-dot {
    position: absolute;
    right: 38px;           /* X(삭제) 10px + 버튼폭 여유를 고려한 오프셋 */
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
  }

  #user-search-input, #new-chat-search { font-size:16px; padding:10px 12px; }
  .modal-content { width: 92vw; }

  /* (추가) 모바일에서 픽셀 반올림 여유 및 여백 보정 */
  #new-chat-search {
    margin: 12px 16px 0 16px;
    width: calc(100% - 32px);
    max-width: calc(100% - 32px);
  }
}
@media (min-width:701px){
  .modal-content { width: 420px; }
}

/* === zoom/소수점 반올림에도 안 튀게 최종 클램프 === */
.new-chat-modal #new-chat-search{
  width: auto;            /* calc() 제거 효과 */
  max-width: none;        /* 이전 max-width 무효화 */
  margin: 18px 18px 0;    /* 기존 좌우 18px 유지 */
  display: block;
  box-sizing: border-box; /* 안전망 */
}

/* 모바일 여백만 동일하게 보정 */
@media (max-width:700px){
  .new-chat-modal #new-chat-search{
    margin: 12px 16px 0;
  }
}

/* 혹시라도 1px 라인 때문에 보이는 현상 숨김(선택) */
.new-chat-modal .modal-content{ overflow-x:hidden; }


/* DM 리스트 검색창: 컨테이너에 딱 맞게 */
.chat-popup-dm-list #user-search-input{
  width: 100%;           /* 다시 100%로 */
  max-width: 100%;
  display: block;
  box-sizing: border-box; /* 보더 포함 계산 */
}

/* 포커스 시 보더 두께 동일(반올림로 오버플로우 방지) */
#user-search-input{ border-width: 1.2px; }
#user-search-input:focus{
  border-color: #4263eb;
  border-width: 1.2px;   /* ← 1.4px 말고 1.2px로 고정 */
}


/* 컨테이너에 가로 오버플로우 숨김 (혹시 있을 1px 라인도 차단) */
.chat-popup-dm-list .dm-list-search{ overflow-x: hidden; }
