/* ========================================= */
/* Messages Page Styles                     */

/* Message Avatar */
.message-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}

.message-avatar .icon {
  width: 24px;
  height: 24px;
  color: var(--fg-inverse);
}

.message-avatar.admin {
  background: var(--bg-brand);
}

.message-avatar.system {
  background: var(--bg-inverse);   /* 남보라 → 검정 (26-08-30) */
}

.message-avatar.user {
  background: var(--bg-sunken);
}
.message-avatar.user .icon {
  color: var(--fg-primary);   /* 초록 → 회색 면 + 검정 아이콘 (26-08-30) */
}

/* Unread Dot */

/* 쪽지함 (messages, 10-25 라이브 note_* 로 되돌림) — 요약 줄(받은 N · 보낸 N 전환 | 편집) → 목록 → 페이지 번호.
   10-25 사용자: 칩 줄 + 요약 줄 두 겹("Received" 두 번) → 한 줄. 위 탭(Campaigns/Group Buy)과 겹치지 않게 밑줄 없는 글자 전환 */
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-control); min-height: 44px; }
.inbox-box { display: flex; flex-wrap: wrap; gap: var(--space-control); align-items: center; min-width: 0; }
/* 받은·보낸 = 알약 칩 — 고르면 검정 면 + 흰 글자 (10-26 칩 규칙, .sub-tab 과 같은 값) */
.inbox-box-tab { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-full); background: var(--bg-sunken); font: var(--t-tag-14); font-weight: 500; color: var(--fg-secondary); cursor: pointer; }
.inbox-box-tab b { margin-left: 4px; font-weight: inherit; font-variant-numeric: tabular-nums; }
.inbox-box-tab.active { background: var(--bg-inverse); color: var(--fg-inverse); font-weight: 600; }
.inbox-box[hidden], .inbox-all[hidden], .inbox-edit[hidden] { display: none; }
.inbox-all { font: var(--t-label); }
.inbox-edit { flex: none; min-height: 44px; margin-right: -8px; padding: 0 8px; border: 0; background: none; font: var(--t-label); font-weight: 600; color: var(--fg-primary); cursor: pointer; }
.inbox-read { font: var(--t-caption); color: var(--fg-secondary); }
.inbox-read.is-unread { color: var(--fg-secondary); font-weight: 600; }

/* 목록 — 행 사이 선은 글 시작점(16 + 사진 44 + 12 = 72)부터, 묶음 위아래 화면 끝 선 없음 (10-25 화면 끝까지 긋던 선 정리) */
.inbox-list { margin: 0 calc(-1 * var(--space-card)); }
.inbox-list[hidden] { display: none; }
.inbox-row { position: relative; display: flex; align-items: center; }
.inbox-row + .inbox-row::before { content: ""; position: absolute; top: 0; left: 72px; right: 0; border-top: 1px solid var(--border-subtle); }
.inbox-list .list-item { flex: 1; min-width: 0; border: 0; }
.inbox-chk { display: none; flex: none; width: 32px; margin-left: var(--space-card); }   /* 체크 20 이 「Select all」 체크와 같은 왼쪽 16 에. 편집 중엔 줄 전체가 누르는 칸 */
body.is-editing .inbox-chk { display: inline-flex; }
body.is-editing .inbox-list .list-item { padding-left: 0; }
body.is-editing .inbox-row + .inbox-row::before { left: calc(var(--space-card) + 32px + 56px); }   /* 체크 칸만큼 같이 밀림 — 글 시작점 */
body.is-editing .bottomnav { display: none; }   /* 편집 중엔 하단 탭 자리에 「Delete selected」 */

.inbox-pinned[hidden] { display: none; }

.inbox-pinned {
  margin: 0 calc(-1 * var(--space-card)) var(--space-section);   /* 행이 자체 좌우 16 을 가져 main 패딩과 겹치지 않게 bleed */
}

.inbox-pinned:first-child > .list-item:first-child { border-top: 0; }
.inbox-pinned > .list-item { position: relative; border-top: 0; border-bottom: 0; }   /* 공용 행 선(전폭)은 끔 — 아래 글자 시작점부터 선 */
/* 10-27 사용자 "메시지 3개 탭 선 넣는 걸 추천" — 10-26 선 없음을 뒤집음. 사진 오른쪽 글자 시작점(16 + 사진 48 + 12 = 76)부터 오른쪽 끝까지, 줄 사이에만 */
.inbox-pinned > .list-item + .list-item::before { content: ''; position: absolute; top: 0; left: calc(var(--space-card) + 48px + var(--space-content)); right: 0; border-top: 1px solid var(--border-subtle); }
.main-content:has(> .inbox-pinned:first-child) { padding-top: 0; }   /* 위 제목 없이 탭 바로 밑 목록 — 본문 위 16 + 행 안쪽 여백이 겹쳐 띄워졌다. 행 여백 하나만 (10-20 사용자 "패딩 이중") */   /* 라벨 없이 탭 바로 아래 오는 목록(공동구매 채팅) — 탭 밑줄과 선 두 줄 겹침 방지 (10-20 사용자) */

.inbox-thread { padding-block: 12px; }   /* 대화 줄 = 위아래 12 (공용 행 8 → 12, 10-20 사용자 "8 알맞은지 판단"): 사진 44 + 두 줄 글이라 8 이면 둥근 사진이 위아래 선에 닿아 보임. 라이브 메시지·공동구매 채팅 같이 */
.inbox-thread .li-thumb {
  width: 48px; height: 48px; flex: none;   /* 10-26 사용자 "48까지 키워줘" — 세 탭 대화 줄 공통 */
  border-radius: var(--r-full);
}

.inbox-thread .li-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 오른쪽 칸 = 글 두 줄과 같은 높이(20 + 2 + 16). 시간은 제목 줄, 안 읽음 점은 미리보기 줄 가운데에 선다 — 점이 시간 밑에 떠 보였다 (10-22) */
.inbox-thread .li-title { font-weight: 600; }   /* 대화 상대·건 이름 = 카드 안 제목 14/600 (10-22) */
.inbox-row.is-unread .li-sub { color: var(--fg-primary); font-weight: 600; }   /* 안 읽은 쪽지 = 미리보기 검정 600 + 점 (10-25 사용자 되살림) */
.inbox-thread-side {
  flex: none;
  display: grid;
  grid-template-rows: 20px 16px;   /* = 제목 줄 · 미리보기 줄 (점이 없어도 칸은 유지) */
  row-gap: 2px;
  align-items: center;
  justify-items: end;
}

.inbox-thread-time {
  font: var(--t-caption);
  color: var(--fg-secondary);
  font-variant-numeric: tabular-nums;
}

.inbox-thread-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--mark-brand);
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-cta);
  color: var(--fg-inverse);
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32);
}

.fab:active {
  transform: scale(0.95);
}

.fab .icon {
  font-size: 24px;
  color: var(--fg-inverse);
}

/* 쪽지 보기 (10-25) — 머리 = 목록과 같은 대화 줄, 본문 14/20. 답장은 아래 고정 [Reply](라이브 「답장하기」)
   선은 앱바 밑 한 줄만 — 머리 줄 밑선·답장 칸 위 선까지 300px 안에 세 줄이던 것 정리 (10-25) */
.msg-view { padding-top: 0; }
.msg-from { margin: 0 calc(-1 * var(--space-card)); border-top: 0; border-bottom: 0; }
.msg-from .li-sub { white-space: normal; overflow: visible; overflow-wrap: anywhere; }   /* 머리 줄 날짜·읽은 시각은 말줄임 대신 줄바꿈 — 한국어·긴 글에서 읽은 시각이 잘렸다 (10-25) */
.msg-text { margin: 4px 0 0; font: var(--t-body); color: var(--fg-primary); overflow-wrap: anywhere; white-space: pre-line; }   /* 머리 줄 아래 12 + 4 = 16 */

/* 채팅방 — 요약 칸 버튼 · 첨부 버튼 · 끝난 방 안내 */
.cc-sum .btn { margin-top: 4px; }
.cc-ended p { margin: 0; padding: 10px 0; font: var(--t-body); color: var(--fg-secondary); text-align: center; }
