/* BWE 聊天窗 —— 与主题设计语言同源：红/黑/浅灰、直角、机能风
   信息架构(2026-08-31):状态条 + 消息流 + 输入区为主体;
   政策/会员/登录收纳为 chips 分级卡片,互斥单开。 */
.bwe-chat-widget {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

/* 防御:类规则的 display 会压过 [hidden] 的 UA 样式(2026-08-31 视觉审计修复)——
   门/卡片/即时答案/chips 的隐藏一律以本规则兜底 */
.bwe-chat-widget [hidden] {
  display: none !important;
}

/* ── 状态条:彩色点 + 短语 ── */
.bwe-chat-widget__mode {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 5px 8px;
  background: #0c0c0c;
  color: #efefeb;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.45;
}

.bwe-chat-widget__mode::before {
  content: '';
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #9a9d98;
}

.bwe-chat-widget__mode[data-state='online']::before {
  background: #2fae6e;
  box-shadow: 0 0 6px rgba(47, 174, 110, 0.8);
}

.bwe-chat-widget__mode[data-state='live']::before {
  background: #7ef0c3;
  box-shadow: 0 0 6px rgba(126, 240, 195, 0.7);
}

.bwe-chat-widget__mode[data-state='email']::before {
  background: #9a9d98;
}

.bwe-chat-widget__history {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
  /* Mobile keeps body scrolling; desktop assigns the remaining height to this history. */
  max-height: none;
  overflow: visible;
  padding: 6px;
  background: rgba(0, 0, 0, 0.03);
}

.bwe-chat-widget__history[data-empty='true']::after {
  content: 'Start the conversation — type your question below';
  color: #505450;
  font-size: 13px;
  text-align: center;
  padding: 12px 0;
}

.bwe-chat-msg {
  align-self: flex-end;
  max-width: 85%;
  background: #0c0c0c;
  color: #fff;
  padding: 7px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bwe-chat-msg__time {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.9;
  margin-top: 3px;
}

.bwe-chat-msg[data-state='failed'] {
  background: #fff;
  color: #c00f24; /* V-08:亮面文字红压暗 */
  border: 1px solid #ed2533;
}

/* 客服消息气泡(左侧白底,区别于客户黑底) */
.bwe-chat-msg--staff {
  align-self: flex-start;
  background: #fff;
  color: #0c0c0c;
  border: 1px solid #0c0c0c;
}

.bwe-chat-msg--staff .bwe-chat-msg__time {
  opacity: 0.9;
}

.bwe-chat-widget__notice {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 8px;
  border: 1px dashed #d9d9d2;
  color: #505450;
}

.bwe-chat-widget__notice[data-tone='error'] {
  color: #c00f24; /* V-08:亮面文字红压暗 */
  border-color: #ed2533;
}

.bwe-chat-widget__gate {
  border: 1px solid #0c0c0c;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}

.bwe-chat-widget__gate-copy {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.bwe-chat-widget__field input,
.bwe-chat-widget__field textarea {
  width: 100%;
  border: 1px solid #d9d9d2;
  background: #fff;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  border-radius: 0;
  box-sizing: border-box;
  resize: none;
}

.bwe-chat-widget__field input:focus,
.bwe-chat-widget__field textarea:focus {
  outline: 2px solid #0c0c0c;
  outline-offset: 2px;
  border-color: #0c0c0c;
}

.bwe-chat-widget__gate-btn,
.bwe-chat-widget__send {
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
}

.bwe-chat-widget__gate-btn {
  border: 2px solid #0c0c0c;
  background: #0c0c0c;
  /* V-07(2026-09-02 K3 视觉审计):平台配色方案的链接色(color_button_text_link #3D3819)
     会压过组件单类选择器——草稿实测黑底上 1.66:1 近乎不可见;锚元素必须 !important 自保 */
  color: #fff !important;
  padding: 8px 14px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
  display: block;
  text-align: center;
  text-decoration: none;
}

.bwe-chat-widget__gate-btn:hover {
  background: #c00f24; /* V-08:红底白字 hover 压暗 */
  border-color: #ed2533;
}

.bwe-chat-widget__composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── 分级收纳 chips:低存在感、高频信息就近展开 ── */
.bwe-chat-widget__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bwe-chat-widget__chip {
  border: 1px solid #0c0c0c;
  background: #fff;
  color: #0c0c0c;
  min-height: 44px;
  padding: 8px 12px;
  font: 700 13px/1.2 "Courier New", Courier, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
}

.bwe-chat-widget__chip[aria-pressed='true'] {
  background: #0c0c0c;
  color: #fff;
}

.bwe-chat-widget__chip:hover,
.bwe-chat-widget__chip--link:hover {
  border-color: #ed2533;
  color: #c00f24; /* V-08:亮面文字红压暗(描边保持基准红) */
}

.bwe-chat-widget__chip[aria-pressed='true']:hover {
  color: #fff;
}

.bwe-chat-widget__chip--link {
  display: inline-block;
}

/* ── 展开的卡片(政策/会员)── */
.bwe-chat-widget__card {
  border: 1px solid #0c0c0c;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.bwe-chat-widget__card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: #0c0c0c;
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.bwe-chat-widget__card-head button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  font-size: 24px;
  line-height: 1;
  padding: 0 2px;
}

.bwe-chat-widget__card--help a {
  display: block;
  padding: 8px 10px;
  color: #0c0c0c;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  border-block-end: 1px solid #eee;
}

.bwe-chat-widget__card--help a:last-of-type {
  border-block-end: 0;
}

.bwe-chat-widget__card-tip {
  margin: 0;
  padding: 7px 10px 9px;
  font-size: 13px;
  line-height: 1.5;
  color: #666;
}

/* 会员行(卡片内) */
.bwe-chat-widget__member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.bwe-chat-widget__member-tier {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #0c0c0c;
  color: #fff;
  padding: 3px 8px;
}

.bwe-chat-widget__member-stat {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  margin-left: auto;
}

.bwe-chat-widget__member-stat + .bwe-chat-widget__member-stat {
  margin-left: 0;
}

.bwe-chat-widget__member-stat small {
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #666;
}

.bwe-chat-widget__member-stat strong {
  font-size: 13px;
}

.bwe-chat-widget__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.bwe-chat-widget__reply-note {
  margin: 0 0 0 auto;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  color: #666;
}

.bwe-chat-widget__send {
  border: 2px solid #0c0c0c;
  background: #0c0c0c;
  color: #fff;
  padding: 8px 18px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
}

.bwe-chat-widget__send:hover {
  background: #c00f24; /* V-08:红底白字 hover 压暗 */
  border-color: #ed2533;
}

.bwe-chat-widget__send[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 知识库即时答案(命中才出现) */
.bwe-chat-widget__instant {
  border: 1px solid #0c0c0c;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bwe-chat-widget__instant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0c0c0c;
  color: #fff;
  padding: 4px 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.bwe-chat-widget__instant-head button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

.bwe-chat-widget__instant > p {
  margin: 0 10px;
  font-size: 13px;
  line-height: 1.5;
}

.bwe-chat-widget__instant > p[data-bwe-chat-instant-answer] {
  padding-top: 6px;
}

.bwe-chat-widget__instant-source {
  font-size: 13px;
}

.bwe-chat-widget__instant-source a {
  color: #0c0c0c;
  font-weight: 700;
  text-decoration: underline;
}

.bwe-chat-widget__instant-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-top: 1px dashed #d9d9d2;
  padding: 7px 0 9px !important;
  margin: 0 10px !important;
}

.bwe-chat-widget__instant-feedback button {
  border: 1px solid #0c0c0c;
  background: #fff;
  padding: 6px 10px;
  min-height: 44px;
  font: 700 13px/1.4 "Courier New", Courier, monospace;
  cursor: pointer;
  white-space: nowrap;
}

.bwe-chat-widget__instant-feedback button:hover {
  border-color: #ed2533;
  color: #c00f24; /* V-08:亮面文字红压暗(描边保持基准红) */
}

/* 2026-09-04 会员卡增强:未登录引导行;数据就绪自动隐藏 */
.bwe-chat-widget__member-hint {
  margin: 0 0 6px;
  padding: 6px 8px;
  border: 1px solid rgba(17, 19, 18, 0.14);
  background: rgba(17, 19, 18, 0.04);
  font-size: 13px;
  line-height: 1.45;
  color: inherit;
}

.bwe-chat-widget__card[data-ready="1"] .bwe-chat-widget__member-hint {
  display: none;
}

.bwe-chat-widget__keyboard-hint,
.bwe-chat-widget__recovery {
  margin: 0;
  color: #505450;
  font-size: 13px;
  line-height: 1.5;
}

.bwe-chat-widget__recovery {
  padding: 10px;
  border: 1px solid #5b5e5b;
  background: #fff;
}

.bwe-chat-widget__recovery p {
  margin: 0 0 6px;
}

.bwe-chat-widget__recovery a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: #111312 !important;
  text-decoration: underline;
}

.bwe-chat-widget__status-button {
  min-height: 44px;
  padding: 8px 12px;
  color: #111312;
  background: #fff;
  border: 1px solid #111312;
  font: 700 13px/1.4 "Courier New", Courier, monospace;
  cursor: pointer;
}

@media (max-width: 820px) {
  .bwe-chat-widget__field textarea {
    font-size: 16px;
  }
}

.bwe-chat-widget__history:focus-visible {
  outline: 2px solid #a30e20;
  outline-offset: 2px;
}

/* Recovery actions retain the existing understated text-link treatment. */
.bwe-chat-widget__recovery [data-bwe-chat-copy] {
  color: inherit; background: transparent; border: 0; padding: 4px 0;
  font: inherit; text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer; display: block; min-height: 36px;
}

/* ── ②图片收发(2026-09-12)── */
.bwe-chat-widget__attach {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 2px solid #0c0c0c;
  background: #fff;
  color: #0c0c0c;
  padding: 6px 9px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  font-family: inherit;
}
.bwe-chat-widget__attach:hover { background: #0c0c0c; color: #fff; }
.bwe-chat-widget__attach:disabled { opacity: 0.4; cursor: default; }
.bwe-chat-msg__img { display: inline-block; max-width: 220px; vertical-align: top; }
.bwe-chat-msg__img img {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border: 1px solid currentColor;
  cursor: zoom-in;
}
.bwe-chat-msg__img:not(:has(img)) { font-size: 11px; opacity: 0.7; }

/* ── ③访客兜底路径(2026-09-12)── */
.bwe-chat-widget__gate-alt {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  color: #55554f;
}
.bwe-chat-widget__gate-alt a { color: #0c0c0c; text-decoration: underline; }
.bwe-chat-widget__gate-alt[hidden] { display: none; }
