/* =============================================================================
 * chat.css · 一对一私聊（页面样式）
 * 设计语言沿用站点：玻璃拟态、克制留白、柔和曲线；移动端单栏、无横向溢出。
 * ========================================================================== */

.page--chat {
  padding-block: var(--sp-4) var(--sp-6);
  /* 私聊是「应用型」页面：整体不滚动，滚动只发生在会话列表与消息区 */
  height: calc(100dvh - var(--nav-h, 64px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-wrap {
  width: 100%;
  max-width: var(--container-wide, 1440px);
  margin-inline: auto;
  padding-inline: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  flex: 1;
  min-height: 0;
}

/* ------------------------------------------------------------ 固定风险提示 */
.chat-risk {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r-sm, 12px);
  background: linear-gradient(135deg, rgba(201, 62, 27, .10), rgba(201, 62, 27, .04));
  border: 1px solid rgba(201, 62, 27, .22);
  color: var(--c-brand-ink, #BC3B11);
  font-size: var(--fs-xs, .78rem);
  line-height: 1.55;
  flex: none;
}
.chat-risk__dot {
  flex: none;
  width: 7px; height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--c-danger, #C93E1B);
  box-shadow: 0 0 0 4px rgba(201, 62, 27, .14);
}

/* --------------------------------------------------------------- 主容器 */
.chat-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  background: var(--glass-bg-strong, rgba(255,253,250,.86));
  -webkit-backdrop-filter: blur(var(--glass-blur, 18px)) saturate(var(--glass-saturate, 160%));
  backdrop-filter: blur(var(--glass-blur, 18px)) saturate(var(--glass-saturate, 160%));
  border: 1px solid var(--glass-border, rgba(255,255,255,.58));
  border-radius: var(--r-lg, 26px);
  box-shadow: 0 18px 50px -28px rgba(38, 50, 56, .38);
  overflow: hidden;
}

/* ------------------------------------------------------------- 左栏列表 */
.chat-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--c-line, rgba(38,50,56,.10));
  background: rgba(255, 253, 250, .55);
}

.chat-side__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
}
.chat-side__title {
  font-size: var(--fs-h3, 1.25rem);
  font-weight: 600;
  letter-spacing: var(--ls-tight, -.02em);
  color: var(--c-ink, #263238);
}
.chat-side__sub {
  margin-top: 2px;
  font-size: var(--fs-2xs, .7rem);
  color: var(--c-ink-55, rgba(38,50,56,.55));
}

.chat-side__search { padding: 0 var(--sp-4) var(--sp-3); }
.chat-side__search .input {
  width: 100%;
  height: 38px;
  padding-inline: 12px;
  border-radius: var(--r-full, 999px);
  font-size: var(--fs-sm, .875rem);
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--sp-2) var(--sp-3);
}

.chat-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-md, 18px);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-1, 160ms) var(--ease-out-quint, ease);
}
.chat-item:hover { background: var(--c-ink-04, rgba(38,50,56,.04)); }
.chat-item.is-active { background: var(--grad-brand-soft, linear-gradient(135deg, rgba(255,90,54,.14), rgba(255,61,46,.05))); }

.chat-item__avatar {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: 50%;
  background: var(--c-cream-deep, #F7E9DA);
  border: 1px solid var(--glass-border, rgba(255,255,255,.58));
}
.chat-item__body { min-width: 0; }
.chat-item__top {
  display: flex; align-items: baseline; gap: 6px;
  min-width: 0;
}
.chat-item__name {
  font-size: var(--fs-sm, .875rem);
  font-weight: 600;
  color: var(--c-ink, #263238);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 130px;
}
.chat-item__time {
  flex: none;
  margin-left: auto;
  font-size: var(--fs-2xs, .7rem);
  color: var(--c-ink-40, rgba(38,50,56,.40));
}
.chat-item__task {
  margin-top: 2px;
  font-size: var(--fs-2xs, .7rem);
  color: var(--c-ink-55, rgba(38,50,56,.55));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item__preview {
  margin-top: 3px;
  font-size: var(--fs-xs, .78rem);
  color: var(--c-ink-68, rgba(38,50,56,.68));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item__badge {
  min-width: 18px; height: 18px;
  padding-inline: 5px;
  border-radius: var(--r-full, 999px);
  background: var(--c-brand-red, #CE3814);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 600;
}

.chat-list__empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  font-size: var(--fs-sm, .875rem);
  color: var(--c-ink-55, rgba(38,50,56,.55));
  line-height: 1.7;
}

.chat-skeleton { display: grid; gap: 10px; padding: 10px 12px; }
.chat-skeleton span {
  display: block; height: 44px;
  border-radius: var(--r-md, 18px);
  background: linear-gradient(90deg, var(--c-ink-04) 25%, var(--c-ink-07) 37%, var(--c-ink-04) 63%);
  background-size: 400% 100%;
  animation: chat-shimmer 1.4s ease-in-out infinite;
}
@keyframes chat-shimmer { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

/* --------------------------------------------------------------- 右栏详情 */
.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: rgba(255, 255, 255, .42);
}

.chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px var(--sp-4);
  border-bottom: 1px solid var(--c-line, rgba(38,50,56,.10));
  background: rgba(255, 253, 250, .72);
}
.chat-head__back {
  display: none;
  width: 32px; height: 32px;
  border: 0; border-radius: 50%;
  background: var(--c-ink-04);
  color: var(--c-ink);
  cursor: pointer;
  place-items: center;
}
.chat-head__back svg { width: 18px; height: 18px; }
.chat-head__avatar {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  font-size: 17px;
  border-radius: 50%;
  background: var(--c-cream-deep, #F7E9DA);
}
.chat-head__meta { min-width: 0; flex: 1; }
.chat-head__name {
  font-size: var(--fs-sm, .875rem);
  font-weight: 600;
  color: var(--c-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-head__task {
  font-size: var(--fs-2xs, .7rem);
  color: var(--c-ink-55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-head__link {
  flex: none;
  font-size: var(--fs-xs, .78rem);
  color: var(--c-brand-ink, #BC3B11);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--r-full, 999px);
  background: var(--grad-brand-soft);
}

/* --------------------------------------------------------------- 消息区 */
.chat-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.chat-empty {
  margin: auto;
  max-width: 420px;
  text-align: center;
  color: var(--c-ink-68, rgba(38,50,56,.68));
}
.chat-empty__icon { font-size: 30px; }
.chat-empty__title {
  margin-top: 8px;
  font-size: var(--fs-h4, 1.05rem);
  color: var(--c-ink);
  font-weight: 600;
}
.chat-empty__desc {
  margin: 8px 0 16px;
  font-size: var(--fs-sm, .875rem);
  line-height: 1.75;
}

.chat-day {
  align-self: center;
  padding: 3px 10px;
  border-radius: var(--r-full, 999px);
  background: var(--c-ink-04);
  color: var(--c-ink-55);
  font-size: var(--fs-2xs, .7rem);
}

.chat-loadmore {
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--c-brand-ink, #BC3B11);
  font-size: var(--fs-xs, .78rem);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--r-full, 999px);
}
.chat-loadmore:hover { background: var(--c-ink-04); }

.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 78%;
  align-items: flex-end;
}
.chat-msg.is-me { margin-left: auto; flex-direction: row-reverse; }

.chat-msg__avatar {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 14px;
  border-radius: 50%;
  background: var(--c-cream-deep, #F7E9DA);
}

.chat-bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: 16px 16px 16px 6px;
  background: #fff;
  border: 1px solid var(--c-line, rgba(38,50,56,.10));
  color: var(--c-ink, #263238);
  font-size: var(--fs-sm, .875rem);
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 6px 18px -14px rgba(38,50,56,.5);
}
.chat-msg.is-me .chat-bubble {
  border-radius: 16px 16px 6px 16px;
  background: var(--grad-brand, linear-gradient(135deg, #FF7A52, #FF3D2E));
  border-color: transparent;
  color: #fff;
}

.chat-bubble--image {
  padding: 4px;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
}
.chat-msg.is-me .chat-bubble--image { background: #fff; }
.chat-bubble--image img {
  display: block;
  max-width: 220px;
  max-height: 260px;
  width: auto; height: auto;
  border-radius: 12px;
  cursor: zoom-in;
}

.chat-msg__meta {
  margin-top: 4px;
  font-size: 10px;
  color: var(--c-ink-40);
  text-align: right;
}
.chat-msg.is-me .chat-msg__meta { color: rgba(255,255,255,.78); }
.chat-msg.is-me .chat-msg__flag { color: rgba(255,255,255,.78); }
.chat-msg__flag { font-size: 10px; margin-left: 4px; }

.chat-msg--failed .chat-bubble { opacity: .6; border-style: dashed; }

/* --------------------------------------------------------------- 输入区 */
.chat-compose {
  position: relative;
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px var(--sp-4) calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--c-line, rgba(38,50,56,.10));
  background: rgba(255, 253, 250, .88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.chat-compose__icon {
  flex: none;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--c-line-strong, rgba(38,50,56,.18));
  border-radius: 50%;
  background: #fff;
  color: var(--c-ink-68);
  cursor: pointer;
}
.chat-compose__icon svg { width: 18px; height: 18px; }
.chat-compose__icon:hover { color: var(--c-brand-ink); border-color: var(--c-brand-light, #FFA184); }

.chat-compose__input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 108px;
  padding: 8px 12px;
  border: 1px solid var(--c-line-strong, rgba(38,50,56,.18));
  border-radius: 18px;
  background: #fff;
  color: var(--c-ink);
  font-family: inherit;
  font-size: var(--fs-sm, .875rem);
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  outline: none;
  transition: border-color var(--dur-1) var(--ease-out-quint);
}
.chat-compose__input:focus { border-color: var(--c-brand-light, #FFA184); }
.chat-compose__send { flex: none; height: 36px; }

.chat-compose__tip {
  position: absolute;
  left: 56px;
  top: -18px;
  font-size: 10px;
  color: var(--c-ink-40);
  transition: opacity var(--dur-2);
}

.chat-compose__pending {
  position: absolute;
  right: 16px;
  top: -22px;
  font-size: 11px;
  color: var(--c-brand-ink);
}

/* ------------------------------------------------------------- 图片预览 */
.chat-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast, 200);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 24, 28, .82);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
}
.chat-lightbox img {
  max-width: min(92vw, 900px);
  max-height: 86vh;
  border-radius: var(--r-md, 18px);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8);
}

/* --------------------------------------------------------------- 响应式 */
@media (max-width: 900px) {
  .page--chat {
    padding-block: var(--sp-2) 0;
    height: calc(100dvh - var(--nav-h, 60px));
  }
  .chat-wrap { padding-inline: 10px; gap: 8px; }
  .chat-risk { font-size: 11px; padding: 8px 10px; }
  .chat-shell {
    grid-template-columns: minmax(0, 1fr);
    border-radius: var(--r-md, 18px);
  }
  .chat-side { border-right: 0; }
  /* 单栏切换：默认显示列表，进入会话后显示详情 */
  .chat-shell:not(.is-detail) .chat-main { display: none; }
  .chat-shell.is-detail .chat-side { display: none; }
  .chat-head__back { display: grid; }
  .chat-msg { max-width: 86%; }
  .chat-bubble--image img { max-width: 62vw; }
  .footer { display: none; }
}

@media (max-width: 420px) {
  .chat-compose { gap: 6px; padding-inline: 10px; }
  .chat-compose__send { padding-inline: 12px; }
  .chat-bubble { font-size: 13px; }
}

/* 键盘弹出时（JS 置 data-kb="1"）压缩外壳高度，避免输入框被遮挡 */
@media (max-width: 900px) {
  .chat-shell[data-kb="1"] .chat-head { display: none; }
  .chat-shell[data-kb="1"] #chatDayHint { display: none; }
}

/* ---------------------------------------------- 敏感词一次性提示条（私聊） */
.chat-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm, 12px);
  background: #FFF1F0;
  border: 1px solid #F5B5B5;
  color: #C81E1E;
  font-size: var(--fs-xs, .78rem);
  font-weight: 600;
  line-height: 1.5;
  flex: none;
}
.chat-tip[hidden] { display: none; }
.chat-tip__icon {
  flex: none;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #C81E1E;
  color: #FFF;
  font-size: 11px;
  font-weight: 700;
}
.chat-tip__text { flex: 1 1 auto; }
.chat-tip__close {
  flex: none;
  border: 0;
  background: transparent;
  color: #C81E1E;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: .7;
}
.chat-tip__close:hover { opacity: 1; }
