/* ============ 门店客服聊天窗 ============ */
.chat {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  font-size: .875rem;
}

/* 收起时的按钮 */
.chat-toggle {
  display: flex;
  align-items: center;
  gap: .45rem;
  background: var(--orange);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: .55rem .9rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 3px 14px rgba(61, 43, 34, .22);
  margin-left: auto;
}
.chat-toggle .chat-dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: #ff3b30;
  display: none;
}
.chat.has-unread .chat-toggle .chat-dot { display: block; }

/* 面板 */
.chat-panel {
  position: absolute;
  right: 0;
  bottom: 3.1rem;
  width: min(300px, calc(100vw - 2rem));
  max-height: min(380px, 60vh);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(61, 43, 34, .2);
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.chat.is-open .chat-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* 头部 */
.chat-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .7rem;
  background: #fdf1e6;
  border-bottom: 1px solid var(--line);
}
.chat-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  font-size: .95rem;
  background: var(--orange);
  color: #fff;
  overflow: hidden;
}
.chat-avatar.blank {
  background: #e7e3de;
  border: 1px dashed rgba(61, 43, 34, .25);
  color: transparent;
}
.chat-who { min-width: 0; }
.chat-who strong {
  display: block;
  font-size: .83rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-who small { color: var(--muted); font-size: .7rem; }
.chat-x {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: .15rem .3rem;
}

/* 消息区 */
.chat-body {
  padding: .7rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  background: #fffaf5;
}
.chat-msg {
  max-width: 86%;
  padding: .45rem .6rem;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  line-height: 1.55;
  word-break: break-word;
  animation: chat-in .22s ease both;
}
@keyframes chat-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.chat-msg time {
  display: block;
  margin-top: .15rem;
  color: #a2948a;
  font-size: .68rem;
}
.chat-msg.read::after {
  content: "已读";
  display: block;
  margin-top: .1rem;
  color: #b3a79f;
  font-size: .66rem;
  text-align: right;
}
.chat-sys {
  align-self: center;
  color: #9c8d83;
  font-size: .7rem;
  text-align: center;
  padding: .15rem .5rem;
}
.chat-typing {
  color: #a2948a;
  font-size: .72rem;
  padding-left: .2rem;
}
.chat-typing::after {
  content: "…";
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

/* 底部已知按钮 */
.chat-ack {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: .5rem .7rem;
}
.chat-ack button {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: .4rem;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
.chat-ack button:hover { border-color: var(--orange); color: var(--ink); }

/* 手机：改成底部单行通知条，不挡内容 */
@media (max-width: 760px) {
  .chat { left: .6rem; right: .6rem; bottom: .6rem; }
  .chat-toggle {
    width: 100%;
    justify-content: center;
    border-radius: 10px;
  }
  .chat-panel {
    left: 0;
    right: 0;
    bottom: 3.2rem;
    width: auto;
    max-height: 56vh;
  }
}

/* 关闭后就剩按钮时的占位，避免盖住页脚 */
body.chat-open .chat-toggle { display: none; }
