/* web/css/letters.css — WhatsApp풍 익명 편지 채팅 모듈 전용 스타일 */

#letters-root {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 12px 24px;
}

.letters-container {
  display: flex;
  flex-direction: column;
  height: 460px;
  max-height: calc(85vh - 80px);
  min-height: 360px;
  background-color: var(--chat-bg, #ECE5DD);
  border-radius: 18px;
  border: 1px solid #d1d7db;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
}

/* ---------- 헤더 바 (WhatsApp 스타일) ---------- */
.letters-header {
  background: #008069;
  color: #ffffff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  z-index: 5;
}

.letters-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.letters-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.letters-header-text {
  min-width: 0;
}

.letters-header-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

/* ---------- 채팅 영역 (벽지 패턴) ---------- */
.letters-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--chat-bg, #ECE5DD);
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%239C8E7D' fill-opacity='0.11'%3E%3Cpath d='M14 16a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v6a4 4 0 0 1-4 4h-4l-4 4v-4h-0a4 4 0 0 1-4-4v-6zm42 36a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v6a4 4 0 0 1-4 4h-4l-4 4v-4h-0a4 4 0 0 1-4-4v-6zM56 18a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm-38 46a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm18-24l3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1 3-6z'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  scroll-behavior: smooth;
}

/* 365일 보관 안내 알약 (WhatsApp 보안 안내 스타일) */
.letters-notice-pill {
  align-self: center;
  background: #FFF9DB;
  border: 1px solid #FFE066;
  color: #664D03;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 7.5px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  margin: 0 auto 4px;
  text-align: center;
  max-width: 90%;
  line-height: 1.4;
  user-select: none;
}

/* 날짜 구분선 알약 (WhatsApp 스타일) */
.letters-date-pill {
  align-self: center;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  color: #54656f;
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 7.5px;
  margin: 6px auto;
  user-select: none;
}

/* 빈 상태 말풍선 */
.letters-empty-container {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
}

.letters-empty-bubble {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 2px rgba(11, 20, 26, 0.12);
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 13.5px;
  color: #54656f;
  text-align: center;
  line-height: 1.5;
  border: 1px dashed #d1d5db;
}

/* ---------- 메시지 행 및 말풍선 ---------- */
.letters-msg-row {
  display: flex;
  width: 100%;
}

.letters-msg-row.incoming {
  justify-content: flex-start;
}

.letters-msg-row.outgoing {
  justify-content: flex-end;
}

.letters-bubble {
  position: relative;
  max-width: 82%;
  padding: 7px 10px 5px;
  font-size: 14.5px;
  line-height: 1.45;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  word-break: break-word;
}

/* 수신 말풍선 (흰색, 좌측 꼬리) */
.letters-bubble-in {
  background: var(--bubble-in, #ffffff);
  color: #111b21;
  border-radius: 8px;
  border-top-left-radius: 0;
  margin-left: 8px;
}

.letters-bubble-in::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 0px solid transparent;
  border-right: 8px solid var(--bubble-in, #ffffff);
  border-bottom: 10px solid transparent;
}

/* 발신 말풍선 (연녹색, 우측 꼬리) */
.letters-bubble-out {
  background: var(--bubble-out, #dcf8c6);
  color: #111b21;
  border-radius: 8px;
  border-top-right-radius: 0;
  margin-right: 8px;
}

.letters-bubble-out::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-top: 0px solid transparent;
  border-left: 8px solid var(--bubble-out, #dcf8c6);
  border-bottom: 10px solid transparent;
}

/* 발신자 힌트 (그룹챗 스타일 굵은 첫 줄, 색상 해시) */
.letters-sender-name {
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 3px;
  letter-spacing: -0.2px;
}

/* 받는 사람 힌트 태그 ("→ 받는 사람: ...") */
.letters-recipient-tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  color: #536471;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 4px;
  max-width: 100%;
  word-break: break-all;
}

/* 말풍선 본문 텍스트 */
.letters-bubble-content {
  white-space: pre-wrap;
  color: #111b21;
}

/* 말풍선 우하단 메타 정보 (시간 + 내일 반영 라벨) */
.letters-bubble-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 4px;
}

.letters-bubble-time {
  font-size: 11px;
  color: #667781;
  white-space: nowrap;
}

.letters-pending-badge {
  font-size: 10.5px;
  color: #047857;
  background: rgba(16, 185, 129, 0.18);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- 하단 컴포저 (Composer) ---------- */
.letters-composer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  background: #f0f2f5;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

/* 성씨 뷰 전용 범위 토글 */
.letters-scope-wrap {
  padding: 6px 12px 2px;
  background: #f0f2f5;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.letters-scope-toggle {
  display: flex;
  gap: 6px;
  background: #e9edef;
  padding: 3px;
  border-radius: 8px;
}

.letters-scope-pill {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: #54656f;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  font-family: inherit;
}

.letters-scope-pill.active {
  background: #ffffff;
  color: #111b21;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* 힌트 칩 및 인풋 영역 */
.letters-hints-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px 2px;
  background: #f0f2f5;
}

.letters-hint-item {
  display: inline-flex;
  align-items: center;
}

.letters-hint-chip {
  border: 1px dashed #b4bec4;
  background: #ffffff;
  color: #54656f;
  border-radius: 14px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.letters-hint-chip:hover {
  border-color: #00a884;
  color: #008069;
}

.letters-hint-input-box {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid #00a884;
  border-radius: 14px;
  padding: 2px 8px 2px 10px;
  gap: 4px;
  font-size: 12px;
}

.letters-hint-label {
  color: #008069;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

.letters-hint-field {
  border: none;
  outline: none;
  font-size: 12px;
  color: #111b21;
  width: 130px;
  background: transparent;
  font-family: inherit;
  padding: 0;
}

.letters-hint-clear {
  border: none;
  background: transparent;
  color: #8696a0;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.letters-hint-clear:hover {
  color: #111b21;
}

/* 텍스트 입력창 행 */
.letters-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px 10px;
  background: #f0f2f5;
}

.letters-input-wrap {
  flex: 1;
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  padding: 8px 46px 8px 14px;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.letters-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: #111b21;
  background: transparent;
  max-height: 110px;
  padding: 0;
  margin: 0;
}

.letters-textarea::placeholder {
  color: #8696a0;
  font-size: 13.5px;
}

.letters-char-count {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 10px;
  color: #8696a0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* 원형 녹색 전송 버튼 (WhatsApp 스타일) */
.letters-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #00a884;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: background 0.15s ease, transform 0.1s ease;
}

.letters-send-btn:hover {
  background: #008f6f;
}

.letters-send-btn:active {
  transform: scale(0.94);
  background: #007a5e;
}

.letters-send-icon {
  margin-left: 2px;
}

/* ---------- 토스트 알림 ---------- */
.letters-toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(17, 24, 39, 0.94);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 25;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 90%;
  text-align: center;
  line-height: 1.4;
}

.letters-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  #letters-root {
    padding: 0 6px 28px;
  }
  .letters-container {
    height: 490px;
    border-radius: 14px;
  }
  .letters-hint-field {
    width: 100px;
  }
}
