/* =============================================
   聊天页样式
   ============================================= */

/* ---------- 页面容器 ---------- */
.chat-page {
  padding-top: 60px;    /* site-header 高度 */
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + var(--browser-bottom-ui, 0px)); /* 底部输入栏高度 + 安全区 + 浏览器地址栏 */
  min-height: 100vh;
  background-color: var(--color-bg, #F5F5F5);
  overscroll-behavior: contain; /* 阻止浏览器原生下拉刷新/上拉溢出 */
}

/* ---------- 消息列表 ---------- */
.chat-msg-list {
  padding: 8px 16px;
  overflow-y: auto;
  max-height: calc(100vh - 60px - 64px - var(--browser-bottom-ui, 0px)); /* 视口高度 - header - input-bar - 浏览器地址栏 */
  /* -webkit-overflow-scrolling: touch — iOS 13+ 已废弃 */
  overscroll-behavior: contain; /* 阻止浏览器原生下拉刷新/上拉溢出 */
}

/* ---------- "已到顶啦"提示（与首页"已到底啦"样式一致：fixed 圆角浮动条） ---------- */
.chat-top-tip {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: rgba(142, 142, 147, 0.55);
  color: #fff;
  padding: 10px 28px;
  border-radius: 20px;
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.chat-top-tip.show {
  opacity: 1;
}

/* ---------- 时间分隔 ---------- */
.chat-time-divider {
  text-align: center;
  margin: 30px 0 8px 0;
  font-size: 12px;
  color: var(--color-text-hint, #8E8E93);
}

/* ---------- 单条消息 ---------- */
.chat-msg-item {
  position: relative;
  display: flex;
  margin-bottom: 16px;
  align-items: flex-start;
}

/* 自己消息（右对齐） */
.chat-msg-item.self {
  flex-direction: row-reverse;
}

/* ---------- 双方头像（圆形首字） ---------- */
.chat-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--color-bg-secondary, #F2F2F7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary, #636366);
}
/* 自己头像使用粉色背景，与气泡颜色呼应 */
.chat-msg-item.self .chat-avatar {
  background-color: var(--color-primary, #FF589B);
  color: #fff;
}

/* ---------- 消息主体 ---------- */
.chat-msg-body {
  max-width: 70%;
  margin: 0 10px;
}

/* 消息气泡 */
.chat-bubble {
  position: relative;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* 对方气泡（白色，箭头朝左） */
.chat-msg-item:not(.self) .chat-bubble {
  background-color: #fff;
  color: var(--color-text-primary, #1C1C1E);
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.chat-msg-item:not(.self) .chat-bubble::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 12px;
  border: 7px solid transparent;
  border-right-color: #fff;
  border-left: 0;
}

/* 自己气泡（粉色，箭头朝右） */
.chat-msg-item.self .chat-bubble {
  background-color: var(--color-primary, #FF589B);
  color: #fff;
  border-radius: 16px 4px 16px 16px;
}
.chat-msg-item.self .chat-bubble::before {
  content: '';
  position: absolute;
  right: -7px;
  top: 12px;
  border: 7px solid transparent;
  border-left-color: var(--color-primary, #FF589B);
  border-right: 0;
}

/* ---------- 底部输入栏 ---------- */
.chat-input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background-color: #fff;
  border-top: 1px solid var(--color-border, #EEEEEE);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  z-index: 100;
}

/* 语音按钮 */
.chat-voice-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: background 0.15s;
}
.chat-voice-btn:active {
  background-color: var(--color-bg-secondary, #F2F2F7);
}

/* 文本输入框 */
.chat-input-field {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--color-border, #EEEEEE);
  border-radius: 20px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--color-text-primary, #1C1C1E);
  background-color: var(--color-bg-secondary, #F2F2F7);
  outline: none;
}
.chat-input-field::placeholder {
  color: var(--color-text-hint, #8E8E93);
}
.chat-input-field:focus {
  border-color: var(--color-primary, #FF589B);
  caret-color: var(--color-primary, #FF589B);
}

/* ---------- 发送按钮（胶囊形，粉色背景） ---------- */
.chat-send-btn {
  flex-shrink: 0;
  height: 36px;
  border: none;
  border-radius: 18px;
  background-color: var(--color-primary, #FF589B);
  color: #fff;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat-send-btn:active {
  opacity: 0.85;
}
.chat-send-btn.visible {
  display: flex;
}

/* ---------- 发送失败标记 ---------- */
.chat-msg-item.send-failed .chat-bubble {
  background-color: #fff0f0 !important;
  border: 1px solid #ff4d4f;
  color: #ff4d4f;
}
.chat-msg-item.send-failed::after {
  content: '发送失败';
  position: absolute;
  right: 0;
  bottom: -18px;
  font-size: 11px;
  color: #ff4d4f;
}

/* 右侧按钮组 */
.chat-right-btns {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 表情按钮 */
.chat-emoji-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: background 0.15s;
}
.chat-emoji-btn:active {
  background-color: var(--color-bg-secondary, #F2F2F7);
}

/* 加号图片按钮 */
.chat-image-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: background 0.15s;
}
.chat-image-btn:active {
  background-color: var(--color-bg-secondary, #F2F2F7);
}