/* =========================================================
   北朝物联 · 右侧在线客服对话窗口
   与 assets/js/bc-chat.js 配套使用
   ========================================================= */

.bc-chat,
.bc-chat * {
  box-sizing: border-box;
}

.bc-chat {
  --bc-pink: #e91e63;
  --bc-pink-dark: #c2185b;
  --bc-ink: #24242a;
  --bc-muted: #8b8b93;
  --bc-line: #ececf1;
  --bc-bg: #f5f5f7;
  --bc-green: #34c759;
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 9990;
  width: 0;
  height: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--bc-ink);
  -webkit-font-smoothing: antialiased;
}

.bc-chat button {
  font-family: inherit;
}

.bc-chat button:focus-visible,
.bc-chat a:focus-visible,
.bc-chat textarea:focus-visible {
  outline: 3px solid rgba(233, 30, 99, 0.35);
  outline-offset: 2px;
}

/* ---------- 右下角入口 ---------- */
.bc-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 54px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef3d78 0%, var(--bc-pink) 45%, var(--bc-pink-dark) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(233, 30, 99, 0.34), 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  z-index: 2;
}

.bc-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(233, 30, 99, 0.42), 0 3px 8px rgba(0, 0, 0, 0.1);
}

.bc-chat-launcher:active {
  transform: translateY(0) scale(0.98);
}

.bc-chat-launcher svg {
  width: 23px;
  height: 23px;
  flex: none;
}

.bc-chat-launcher .bc-icon-close {
  display: none;
}

.bc-chat.is-open .bc-chat-launcher .bc-icon-chat {
  display: none;
}

.bc-chat.is-open .bc-chat-launcher .bc-icon-close {
  display: block;
}

.bc-chat-launcher-text {
  white-space: nowrap;
}


.bc-chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff;
  color: var(--bc-pink);
  border: 2px solid var(--bc-pink);
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* ---------- 对话面板 ---------- */
.bc-chat-panel {
  position: fixed;
  right: 84px;
  bottom: 92px;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: 600px;
  height: min(620px, calc(100vh - 132px));
  height: min(620px, calc(100dvh - 132px));
  overflow: hidden;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(17, 17, 26, 0.28), 0 0 0 1px rgba(17, 17, 26, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(0.97);
  transform-origin: right bottom;
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1),
    visibility 0.22s;
  pointer-events: none;
  z-index: 3;
}

.bc-chat.is-open .bc-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

/* 顶部 */
.bc-chat-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  flex: none;
  padding: 15px 14px 14px 16px;
  color: #fff;
  background: linear-gradient(135deg, #2e2e34 0%, #1b1b20 60%, #19191d 100%);
}

.bc-chat-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--bc-pink) 0%, #ff7aa8 38%, rgba(233, 30, 99, 0) 100%);
}

.bc-chat-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.bc-chat-avatar span {
  display: block;
  color: var(--bc-pink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.6px;
  line-height: 1;
}

.bc-chat-heading {
  flex: 1;
  min-width: 0;
}

.bc-chat-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bc-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.66);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bc-chat-status i {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bc-green);
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18);
}

.bc-chat[data-connection="offline"] .bc-chat-status i {
  background: #ff9f0a;
  box-shadow: 0 0 0 3px rgba(255, 159, 10, 0.18);
}

.bc-chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.bc-chat-human {
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.bc-chat-human:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.45);
}

.bc-chat-human[hidden] {
  display: none;
}

.bc-chat-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 23px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.bc-chat-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* 提示条 */
.bc-chat-notice {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 14px;
  border-bottom: 1px solid #f6e7c5;
  background: #fff9ec;
  color: #8a5a00;
  font-size: 11.8px;
  line-height: 1.55;
}

.bc-chat-notice[hidden] {
  display: none;
}

.bc-chat-notice svg {
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 2px;
}

.bc-chat-notice.is-error {
  border-bottom-color: #ffd2d2;
  background: #fff2f2;
  color: #b3261e;
}

/* 消息区 */
.bc-chat-body {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 18px 14px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bc-bg);
  scrollbar-width: thin;
  scrollbar-color: #d3d3da transparent;
}

.bc-chat-body::-webkit-scrollbar {
  width: 6px;
}

.bc-chat-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #d3d3da;
}

.bc-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.bc-chat-date {
  margin: 2px 0 16px;
  color: #a5a5ad;
  font-size: 11px;
  text-align: center;
}

.bc-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 14px;
  animation: bc-chat-in 0.18s ease both;
}

.bc-msg-agent {
  justify-content: flex-start;
}

.bc-msg-visitor {
  justify-content: flex-end;
}

.bc-msg-system {
  justify-content: center;
  margin: 8px 0 14px;
}

.bc-msg-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  overflow: hidden;
  border: 1px solid var(--bc-line);
  border-radius: 50%;
  background: #fff;
  color: var(--bc-pink);
  font-size: 10px;
  font-weight: 700;
}

.bc-msg-main {
  display: flex;
  flex-direction: column;
  max-width: 84%;
  min-width: 0;
}

.bc-msg-visitor .bc-msg-main {
  align-items: flex-end;
}

.bc-msg-meta {
  margin: 0 4px 4px;
  color: #a2a2aa;
  font-size: 10.5px;
  line-height: 1.4;
}

.bc-msg-time {
  margin: 4px 4px 0;
  color: #b0b0b7;
  font-size: 10px;
  line-height: 1;
}

.bc-bubble {
  max-width: 100%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.8px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bc-msg-agent .bc-bubble {
  border-top-left-radius: 4px;
  background: #fff;
  color: #2a2a30;
  box-shadow: 0 2px 6px rgba(20, 20, 30, 0.05);
}

/* 欢迎语分段：同一组气泡之间留出间距，读起来是两段话 */
.bc-msg-main .bc-bubble + .bc-bubble {
  margin-top: 6px;
}

.bc-msg-visitor .bc-bubble {
  border-top-right-radius: 4px;
  background: linear-gradient(135deg, #ef3d78, var(--bc-pink) 50%, var(--bc-pink-dark));
  color: #fff;
  box-shadow: 0 5px 14px rgba(233, 30, 99, 0.22);
}

.bc-msg-system .bc-bubble {
  max-width: 88%;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(20, 20, 30, 0.055);
  color: #82828b;
  font-size: 11.5px;
  line-height: 1.55;
  text-align: center;
}

.bc-msg-error .bc-bubble {
  border: 1px solid #ffd2d2;
  background: #fff2f2;
  color: #b3261e;
}

.bc-msg-pending .bc-bubble {
  opacity: 0.62;
}

/* 正在输入 */
.bc-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 13px 14px;
  border-radius: 14px;
  border-top-left-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(20, 20, 30, 0.05);
}

.bc-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b7b7c0;
  animation: bc-chat-bounce 1.2s infinite ease-in-out;
}

.bc-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.bc-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

/* 扫码联系卡片 */
.bc-contact-card {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 2px 0 18px 36px;
  padding: 12px;
  border: 1px solid var(--bc-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(20, 20, 30, 0.04);
}

.bc-contact-card img {
  width: 86px;
  height: 86px;
  flex: none;
  border-radius: 9px;
  object-fit: cover;
  background: #f2f2f4;
}

.bc-contact-card h4 {
  margin: 0 0 4px;
  color: #2a2a30;
  font-size: 13px;
  font-weight: 600;
}

.bc-contact-card p {
  margin: 0 0 7px;
  color: var(--bc-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.bc-contact-card a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--bc-pink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.bc-contact-card a:hover {
  text-decoration: underline;
}

/* 转人工卡片 */
.bc-human-card {
  margin: 0 0 16px 36px;
  padding: 13px 14px;
  border: 1px solid #ffd3e1;
  border-radius: 14px;
  background: #fff7fa;
}

.bc-human-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--bc-pink-dark);
  font-size: 13px;
  font-weight: 600;
}

.bc-human-card p {
  margin: 0 0 10px;
  color: #7c7c85;
  font-size: 11.8px;
  line-height: 1.6;
}

.bc-human-card button {
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef3d78, var(--bc-pink-dark));
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(233, 30, 99, 0.22);
}

.bc-human-card button:hover {
  filter: brightness(1.04);
}

.bc-human-card button:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* 快捷问题 */
.bc-chat-quick {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 14px 10px;
  background: var(--bc-bg);
}

.bc-chat-quick[hidden] {
  display: none;
}

.bc-quick {
  flex: none;
  padding: 7px 12px;
  border: 1px solid #e3e3e9;
  border-radius: 999px;
  background: #fff;
  color: #4d4d56;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.bc-quick:hover {
  border-color: rgba(233, 30, 99, 0.55);
  background: #fff7fa;
  color: var(--bc-pink-dark);
}

/* 输入区 */
.bc-chat-form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 10px 13px 9px;
  border-top: 1px solid var(--bc-line);
  background: #fff;
}

.bc-chat-input {
  flex: 1;
  min-height: 42px;
  max-height: 104px;
  padding: 10px 12px;
  border: 1px solid #e5e5eb;
  border-radius: 12px;
  background: #f7f7f9;
  color: var(--bc-ink);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  resize: none;
  overflow-y: hidden;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.bc-chat-input::placeholder {
  color: #a8a8b0;
}

.bc-chat-input:focus {
  border-color: rgba(233, 30, 99, 0.55);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.08);
}

.bc-chat-input:disabled {
  background: #f1f1f4;
  cursor: not-allowed;
}

.bc-chat-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef3d78, var(--bc-pink-dark));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(233, 30, 99, 0.28);
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.bc-chat-send svg {
  width: 19px;
  height: 19px;
  transform: translateX(1px);
}

.bc-chat-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 9px 18px rgba(233, 30, 99, 0.34);
}

.bc-chat-send:disabled {
  opacity: 0.38;
  box-shadow: none;
  cursor: not-allowed;
}

.bc-chat-foot {
  flex: none;
  padding: 0 14px 9px;
  background: #fff;
  color: #a7a7af;
  font-size: 10.5px;
  line-height: 1.4;
  text-align: center;
}

/* 转人工引导层 */
.bc-chat-sheet-mask {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(15, 15, 20, 0.34);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
}

.bc-chat-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: #fff;
  box-shadow: 0 -12px 40px rgba(15, 15, 20, 0.18);
  transform: translateY(104%);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bc-chat.is-handoff .bc-chat-sheet {
  transform: none;
}

.bc-chat.is-handoff .bc-chat-sheet-mask {
  opacity: 1;
  visibility: visible;
}

.bc-chat-sheet h3 {
  margin: 0 0 8px;
  color: #24242a;
  font-size: 16px;
  font-weight: 600;
}

.bc-chat-sheet p {
  margin: 0 0 14px;
  color: #767680;
  font-size: 12.5px;
  line-height: 1.7;
}

.bc-chat-sheet-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2ebd59, #1f9d46);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(46, 189, 89, 0.26);
}

.bc-chat-sheet-link:hover {
  color: #fff;
  filter: brightness(1.04);
}

.bc-chat-sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #f3f3f5;
  color: #77777f;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.bc-chat-sheet-tip {
  display: block;
  margin-top: 10px;
  color: #9b9ba3;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

/* 动画 */
@keyframes bc-chat-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bc-chat-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* 移动端全屏 */
@media (max-width: 640px) {
  .bc-chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }

  .bc-chat.is-open .bc-chat-header {
    padding-top: calc(14px + env(safe-area-inset-top));
  }

  .bc-chat-launcher {
    right: 16px;
    bottom: 16px;
    width: 54px;
    height: 54px;
    padding: 0;
    justify-content: center;
  }

  .bc-chat-launcher-text {
    display: none;
  }

  .bc-chat-form {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .bc-chat-foot {
    display: none;
  }

  .bc-chat-input {
    font-size: 16px;
  }

  body.bc-chat-lock {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bc-chat-panel,
  .bc-chat-launcher,
  .bc-chat-sheet,
  .bc-chat-sheet-mask {
    transition: none !important;
  }

  .bc-msg,
  .bc-typing i {
    animation: none !important;
  }
}
