/* ============================================================
 *  站内聊天气泡样式 · "淘宝客服"风格
 * ============================================================ */

.chat-floating-btn {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- 主按钮 ---------- */
.chat-toggle {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #2F5A45;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(47, 90, 69, 0.42), 0 2px 6px rgba(0,0,0,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .25s, box-shadow .25s, background .25s;
}
.chat-toggle:hover { transform: scale(1.05); box-shadow: 0 10px 28px rgba(47, 90, 69, .55); }
.chat-toggle .ico-close { display: none; }
body.chat-open .chat-toggle .ico-msg { display: none; }
body.chat-open .chat-toggle .ico-close { display: block; }
body.chat-open .chat-toggle { background: #B8483E; }

.chat-unread {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  background: #B8483E;
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #FBF8F1;
  line-height: 1;
}
.chat-unread.show { display: inline-flex; animation: unread-pop .3s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes unread-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ---------- 聊天面板 ---------- */
.chat-panel {
  position: absolute;
  bottom: 64px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 30px);
  height: 540px;
  max-height: calc(100vh - 100px);
  background: #FBF8F1;
  border-radius: 16px;
  box-shadow: 0 14px 48px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chat-in .3s cubic-bezier(.4, 0, .2, 1);
}
body.chat-open .chat-panel { display: flex; }
@keyframes chat-in {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1);   }
}

/* ---------- 头部 ---------- */
.chat-header {
  padding: 14px 16px;
  background: #2F5A45;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; line-height: 1.3; }
.chat-header-name {
  font-size: 14px;
  font-weight: 600;
}
.header-online {
  font-size: 11.5px;
  font-weight: 400;
  opacity: .8;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.header-online::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #6EE49E;
  border-radius: 50%;
  margin-right: 4px;
  animation: blink-dot 1.8s ease-in-out infinite;
}
@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.chat-header-sub {
  font-size: 11px;
  opacity: .75;
}
.chat-mini {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  width: 26px;
  height: 26px;
  font-size: 14px;
  line-height: 1;
  border-radius: 6px;
  opacity: .7;
}
.chat-mini:hover { opacity: 1; background: rgba(255,255,255,.1); }

/* ---------- 上下文条 ---------- */
.chat-context-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #F1ECDF;
  color: #2F5A45;
  font-size: 11.5px;
  font-weight: 500;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

/* ---------- 消息流 ---------- */
.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #FBF8F1;
  scrollbar-width: thin;
}
.chat-stream::-webkit-scrollbar { width: 5px; }
.chat-stream::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 4px; }

/* 欢迎屏 */
.chat-welcome {
  text-align: center;
  padding: 24px 12px;
  color: #5C5A4A;
}
.chat-welcome-icon {
  width: 56px;
  height: 56px;
  background: #F1ECDF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.chat-welcome p {
  margin: 0 0 6px;
  font-size: 15px;
  color: #1F2A23;
  font-weight: 500;
}
.chat-welcome small {
  font-size: 12.5px;
  line-height: 1.5;
  display: block;
  max-width: 260px;
  margin: 0 auto;
}

/* 单条消息 */
.chat-msg {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  max-width: 100%;
}
.chat-msg.is-user { justify-content: flex-end; }
.chat-msg.is-agent { justify-content: flex-start; }

.chat-msg-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #2F5A45;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.chat-msg-bubble {
  max-width: 78%;
  padding: 8px 12px 6px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 13.5px;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.chat-msg.is-user .chat-msg-bubble {
  background: #2F5A45;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.is-agent .chat-msg-bubble {
  background: #fff;
  color: #1F2A23;
  border-bottom-left-radius: 4px;
}

.chat-msg-text {
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg-time {
  font-size: 10px;
  opacity: .55;
  margin-top: 4px;
  text-align: right;
}

/* ---------- 产品卡片（淘宝客服样式） ---------- */
.chat-card-host { margin: -2px -4px 6px; }
.chat-prod-card {
  display: flex;
  background: rgba(255,255,255,.92);
  color: #1F2A23;
  border-radius: 8px;
  padding: 8px;
  gap: 8px;
  text-decoration: none;
  border: 1px solid rgba(0,0,0,.06);
  transition: background .15s;
}
.chat-msg.is-user .chat-prod-card {
  background: rgba(255,255,255,.95);
  border-color: rgba(255,255,255,.3);
}
.chat-prod-card:hover { background: rgba(255,255,255,1); }
.chat-msg.is-user .chat-prod-card:hover { background: rgba(255,255,255,1); }

.chat-prod-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.7);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Cormorant Garamond', serif;
}
.chat-prod-info { flex: 1; min-width: 0; }
.chat-prod-sku {
  font-size: 10.5px;
  font-weight: 600;
  color: #2F5A45;
  letter-spacing: .04em;
}
.chat-msg.is-user .chat-prod-sku { color: #2F5A45; }
.chat-prod-name {
  font-size: 12.5px;
  font-weight: 500;
  color: #1F2A23;
  margin: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-prod-link {
  font-size: 10.5px;
  color: #2F5A45;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
}
.chat-msg.is-user .chat-prod-link { color: #2F5A45; }

/* ---------- 快捷问题按钮 ---------- */
.chat-quick-row {
  padding: 8px 12px 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #FBF8F1;
  border-top: 1px solid rgba(0,0,0,.05);
}
.chat-quick-row button {
  border: 1px solid rgba(47, 90, 69, .2);
  background: #fff;
  color: #2F5A45;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.chat-quick-row button:hover {
  background: #2F5A45;
  color: #fff;
}

/* ---------- 输入区 ---------- */
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.05);
}
.chat-input {
  flex: 1;
  border: 1px solid rgba(0,0,0,.1);
  background: #FBF8F1;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}
.chat-input:focus { border-color: #2F5A45; background: #fff; }
.chat-send {
  width: 36px;
  height: 36px;
  border: none;
  background: #2F5A45;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .15s;
  flex-shrink: 0;
}
.chat-send:hover { background: #264b39; }
.chat-send:active { transform: scale(.95); }

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  .chat-floating-btn { right: 14px; bottom: 14px; }
  .chat-toggle { width: 50px; height: 50px; }
  .chat-panel {
    width: calc(100vw - 28px);
    right: 0;
    bottom: 60px;
    height: calc(100vh - 120px);
  }
}

/* WhatsApp 浮动按钮自动下移（避免被聊天按钮遮挡） */
body.wa-shifted .wa-float-wrap {
  bottom: 86px;
  transition: bottom .3s;
}
body.wa-shifted .wa-float {
  transform: scale(.85);
  opacity: .88;
}
