/* ============ 访客聊天页 ============ */
:root { --primary-light: #5c8dff; --primary-bg: #e8eefc; }
html, body { height: 100%; }
body { background: linear-gradient(160deg, var(--primary-bg) 0%, #f3f4f6 60%); overflow: hidden; }
body.is-embed { background: var(--bg); }
#app { height: 100%; display: flex; align-items: center; justify-content: center; }

/* 外框：聊天窗口 + 侧边栏（宽屏电脑） */
.chat-shell { position: relative; display: flex; width: 100%; height: 100%; max-width: 480px; overflow: hidden; }
.chat-shell.embed { max-width: none; }
.chat {
  position: relative; display: flex; flex-direction: column;
  flex: 1; min-width: 0; height: 100%; overflow: hidden; background: var(--bg);
}
@media (min-width: 640px) {
  body:not(.is-embed) .chat-shell { height: min(780px, calc(100vh - 48px)); border-radius: 16px; box-shadow: var(--shadow-lg); }
}
@media (min-width: 900px) {
  body:not(.is-embed) .chat-shell.with-side { max-width: 820px; }
}
.side-panel {
  width: 300px; flex-shrink: 0; overflow-y: auto; padding: 16px; background: #fff; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 18px;
}
.side-title { margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.side-text { white-space: pre-wrap; color: var(--text-2); font-size: 13px; line-height: 1.7; }
.side-img { display: block; width: 100%; border-radius: 8px; }
.side-links { display: flex; flex-direction: column; }
.side-links a, .side-links button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border: none; border-bottom: 1px solid var(--border-2);
  background: none; color: var(--text); font-size: 13px; text-align: left; text-decoration: none; cursor: pointer;
}
.side-links a:hover, .side-links button:hover { color: var(--primary); }
.side-links .ui-icon { color: var(--text-4); }

.chat-header {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(120deg, var(--primary), var(--primary-light)); color: #fff;
}
.header-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: rgba(255, 255, 255, .18); border: 2px solid rgba(255, 255, 255, .4); font-weight: 600; font-size: 16px;
}
.header-avatar img, .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar { overflow: hidden; }

/* 通告：一行小字 */
.notice-bar {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 12px;
  background: #fff8e6; color: #8a5a00; font-size: 12px; line-height: 28px; border-bottom: 1px solid #f5e3b5; overflow: hidden;
}
.notice-bar > svg { flex-shrink: 0; }
.notice-bar.link, .notice-bar.expanded { cursor: pointer; }
.notice-box { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.notice-text { display: block; overflow: hidden; text-overflow: ellipsis; }
.notice-marquee { display: inline-flex; animation: notice-scroll linear infinite; }
.notice-marquee span { padding-right: 48px; }
.notice-bar:hover .notice-marquee { animation-play-state: paused; }
@keyframes notice-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
/* 点击展开全文 */
.notice-bar.expanded { height: auto; align-items: flex-start; padding-top: 5px; padding-bottom: 5px; line-height: 1.6; }
.notice-bar.expanded > svg { margin-top: 4px; }
.notice-full { display: block; white-space: pre-wrap; word-break: break-word; }
.notice-close { flex-shrink: 0; display: flex; padding: 3px; border: none; border-radius: 4px; background: none; color: inherit; cursor: pointer; opacity: .6; }
.notice-close:hover { opacity: 1; background: rgba(0, 0, 0, .05); }
.header-info { flex: 1; min-width: 0; }
.header-title { font-size: 16px; font-weight: 600; line-height: 1.35; }
.header-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .92; min-width: 0; }
.header-sub .status-dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }
.header-sub-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; gap: 2px; }
.icon-btn.light { color: rgba(255, 255, 255, .9); }
.icon-btn.light:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.chat-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.new-tip {
  position: absolute; right: 16px; bottom: 120px; z-index: 20; display: flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 15px; background: #fff;
  color: var(--primary); font-size: 12px; box-shadow: var(--shadow); cursor: pointer;
}

.chat-footer {
  position: relative; flex-shrink: 0; background: #fff; border-top: 1px solid var(--border);
  padding: 4px 10px calc(10px + env(safe-area-inset-bottom));
}
.toolbar { display: flex; gap: 2px; margin-bottom: 2px; }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; min-height: 40px; max-height: 120px; padding: 9px 14px; resize: none; outline: none;
  border: 1px solid var(--border); border-radius: 20px; background: var(--bg-2); line-height: 1.45; font-size: 15px;
  transition: border-color .15s, background .15s;
}
.composer textarea:focus { border-color: var(--primary); background: #fff; }
.send-btn {
  width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; background: var(--primary); color: #fff; cursor: pointer; transition: background .15s, transform .1s;
}
.send-btn:hover:not(:disabled) { background: var(--primary-hover); }
.send-btn:active:not(:disabled) { transform: scale(.94); }
.send-btn:disabled { background: var(--text-4); cursor: default; }
@media (max-width: 640px) { .composer textarea { font-size: 16px; } }

/* 评价卡片 */
.rating-card {
  align-self: center; width: 100%; max-width: 320px; padding: 18px 18px 16px; text-align: center;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
}
.rating-title { font-weight: 600; }
.stars { display: flex; justify-content: center; gap: 4px; margin: 10px 0 2px; }
.star { display: inline-flex; padding: 2px; border: none; background: none; color: var(--text-4); cursor: pointer; transition: color .1s, transform .1s; }
.stars:not(.static) .star:hover { transform: scale(1.12); }
.star.on { color: #ffb400; }
.stars.static .star { cursor: default; }
.rating-label { font-size: 12px; color: var(--text-3); margin-bottom: 12px; min-height: 18px; }
.rating-card .textarea { margin-bottom: 12px; font-size: 14px; }
.rating-comment { margin-top: 6px; color: var(--text-2); font-size: 13px; }

/* 技能组选择 / 人机验证 */
.choice-card { align-self: stretch; padding: 14px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); }
.choice-title { margin-bottom: 10px; font-weight: 600; }
.choice-btn {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; margin-top: 8px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; text-align: left; cursor: pointer; transition: border-color .15s, background .15s;
}
.choice-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.choice-btn span { font-size: 12px; color: var(--text-3); }
.turnstile-box { min-height: 66px; }

/* 询前表单 / 留言 */
.form-card .field { margin-bottom: 10px; }
.form-card .field label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--text-2); }
.form-card .req { margin-left: 2px; color: var(--danger); font-style: normal; }
.form-card .row-end { margin-top: 4px; }
.form-tip-text { margin: -4px 0 10px; font-size: 13px; color: var(--text-3); line-height: 1.6; }
.privacy { margin: 4px 0 12px; font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* 常见问题 */
.faq-card { margin-top: 6px; width: 260px; max-width: 100%; padding: 10px 12px 4px; background: #fff; border-radius: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.faq-title { margin-bottom: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.faq-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 8px 0; border: none;
  border-top: 1px solid var(--border-2); background: none; color: var(--primary); font-size: 13px; text-align: left; cursor: pointer;
}
.faq-item:first-of-type { border-top: none; }
.faq-item:hover { text-decoration: underline; }

/* 快捷按钮 / 快捷菜单 */
.quick-btns { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 4px; scrollbar-width: none; }
.quick-btns::-webkit-scrollbar { display: none; }
.quick-btn {
  flex-shrink: 0; height: 28px; padding: 0 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff;
  color: var(--text-2); font-size: 13px; white-space: nowrap; cursor: pointer;
}
.quick-btn:hover { border-color: var(--primary); color: var(--primary); }
.quick-menu {
  position: absolute; bottom: calc(100% + 6px); left: 8px; z-index: 50; width: 220px; max-height: 300px; overflow-y: auto; padding: 6px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.quick-menu-group { padding: 6px 8px 2px; font-size: 12px; color: var(--text-3); }
.quick-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 8px; border: none; border-radius: 6px;
  background: none; font-size: 14px; text-align: left; cursor: pointer;
}
.quick-menu button:hover { background: var(--bg); }
.quick-menu .ui-icon { color: var(--text-3); }
.icon-btn.on { background: var(--bg); color: var(--primary); }

/* 评价：三级 / 十分制 / 原因标签 */
.levels { display: flex; justify-content: center; gap: 8px; margin: 10px 0 4px; }
.level {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 76px; padding: 8px 4px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; font-size: 12px; color: var(--text-2); cursor: pointer;
}
.level-face { font-size: 24px; line-height: 1.2; }
.level.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.points { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0 4px; }
.point { height: 32px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-variant-numeric: tabular-nums; }
.point.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.rating-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 12px; }
.rtag { height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 13px; background: #fff; color: var(--text-2); font-size: 12px; cursor: pointer; }
.rtag.on { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.rating-tags.static { margin: 8px 0 0; }
.rating-tags.static .rtag { cursor: default; display: inline-flex; align-items: center; }
.rating-result { margin: 8px 0 2px; font-size: 15px; font-weight: 600; color: var(--text); }

.recall-link { padding: 0 0 0 6px; font-size: 11px; color: var(--text-3); }
.recall-link:hover { color: var(--primary); }

/* 预览模式（管理后台「访客端设置」） */
body.is-preview .chat-header { padding-top: 12px; }

/* 智能助手 / 拉黑 */
.human-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 6px; padding: 6px 10px; border-radius: 8px; background: var(--primary-soft); font-size: 12px; color: var(--primary); }
.blocked-bar { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 16px; background: #fff; border-top: 1px solid var(--border); color: var(--text-3); }

/* ---------- 正在浏览的商品 ---------- */
.product-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.product-bar img { flex-shrink: 0; width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #fff; }
.product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.product-info small { font-size: 11px; color: var(--text-3); }
.product-info b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-price { color: var(--danger); font-weight: 600; font-size: 12px; }
.chat-footer .record-bar { margin-top: 2px; }
