/* ==========================================================================
   chat.css —— 企业微信「AI 智能客服」会话界面
   ========================================================================== */

.chat-app {
  flex: 1 1 auto;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

/* ---------------- 会话导航栏 ---------------- */
.chat-nav {
  flex: none; position: relative; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.chat-nav-back { width: 26px; height: 26px; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.chat-nav-back svg { width: 17px; height: 17px; }

.chat-nav-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }

.chat-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--brand-grad); display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .5px;
  box-shadow: 0 3px 9px rgba(199,0,11,.24);
  overflow: hidden;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 5px; background: #fff; }

.chat-title { font-size: 14.5px; font-weight: 700; letter-spacing: .3px; line-height: 1.2; }
.chat-status { margin-top: 3px; display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--ink-4); }
.chat-status .live {
  display: inline-flex; align-items: center; gap: 3px; color: var(--success); font-weight: 700;
}
.chat-status .live::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 2.5px var(--success-bg);
}
.chat-nav-tools { display: flex; align-items: center; gap: 13px; color: var(--ink-3); flex: none; }
.chat-nav-tools svg { width: 18px; height: 18px; }

/* ---------------- 会话主体 ---------------- */
.chat-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 14px 13px 6px;
  display: flex; flex-direction: column; gap: 13px;
  scroll-behavior: smooth;
  background:
    radial-gradient(520px 260px at 100% 0%, #FFF3F3 0%, rgba(255,243,243,0) 62%),
    var(--bg);
}

/* 日期分隔 */
.chat-day { align-self: center; font-size: 10.5px; color: var(--ink-4); background: rgba(255,255,255,.9);
  padding: 3px 11px; border-radius: var(--r-pill); border: 1px solid var(--line); }

/* 系统提示条 */
.chat-sys {
  align-self: center; max-width: 88%;
  font-size: 10.5px; line-height: 1.6; color: var(--warn);
  background: var(--warn-bg); border: 1px solid #FBE3B8;
  padding: 6px 12px; border-radius: var(--r-m); text-align: center;
}

/* 时间分割标签（主动提醒场景） */
.chat-push {
  align-self: center; display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: var(--brand); background: var(--brand-50);
  border: 1px solid var(--brand-100); padding: 3px 11px; border-radius: var(--r-pill); font-weight: 600;
}
.chat-push svg { width: 11px; height: 11px; }

/* ---------------- 消息行 ---------------- */
.msg { display: flex; gap: 8px; align-items: flex-start; animation: msgIn .3s cubic-bezier(.22,1,.36,1) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

.msg.user { flex-direction: row-reverse; }

.msg-ava {
  width: 30px; height: 30px; border-radius: 9px; flex: none; overflow: hidden;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff;
  margin-top: 2px;
}
.msg.bot .msg-ava { background: var(--brand-grad); box-shadow: 0 3px 8px rgba(199,0,11,.22); }
.msg.bot .msg-ava img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 4px; }
.msg.user .msg-ava { background: linear-gradient(135deg, #6FA8F5, #2B6CD4); }
.msg.agent .msg-ava { background: linear-gradient(135deg, #34C4B0, #0E9E8E); }

.msg-col { max-width: 262px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.msg.user .msg-col { align-items: flex-end; }

.msg-name { font-size: 10px; color: var(--ink-4); padding: 0 3px; }

.msg-bubble {
  position: relative;
  padding: 10px 13px;
  border-radius: 4px 14px 14px 14px;
  background: #fff;
  font-size: 13.5px; line-height: 1.62; color: var(--ink);
  box-shadow: var(--sh-1);
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.user .msg-bubble {
  background: var(--brand-grad); color: #fff;
  border-radius: 14px 4px 14px 14px;
  box-shadow: 0 5px 14px rgba(199,0,11,.22);
}
.msg.agent .msg-bubble { border-radius: 4px 14px 14px 14px; background: #fff; }

.msg-bubble b, .msg-bubble strong { color: var(--brand); font-weight: 700; }
.msg.user .msg-bubble b, .msg.user .msg-bubble strong { color: #fff; }
.msg-bubble .em { color: var(--brand); font-weight: 700; }

/* 输入中动画 */
.typing { display: flex; align-items: center; gap: 4px; padding: 13px 15px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand-300);
  animation: typing 1.15s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes typing { 0%,60%,100% { transform: none; opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------------- 消息内富卡片 ---------------- */
.msg-col.wide { max-width: 300px; }

.card {
  background: #fff; border-radius: var(--r-l); overflow: hidden;
  box-shadow: var(--sh-2); border: 1px solid var(--line);
}
.card + .card { margin-top: 8px; }

.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 13px;
  background: linear-gradient(135deg, #FFF6F6 0%, #FFFDFD 100%);
  border-bottom: 1px solid var(--line);
}
.card-head.grad { background: var(--brand-grad); border-bottom: 0; }
.card-head.grad .card-title,
.card-head.grad .card-sub { color: #fff; }
.card-head.grad .card-ic { background: rgba(255,255,255,.2); color: #fff; }

.card-ic {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 16px;
  background: var(--brand-50); color: var(--brand);
}
.card-ic svg { width: 17px; height: 17px; }
.card-hd-txt { flex: 1; min-width: 0; }
.card-title { font-size: 13.5px; font-weight: 700; letter-spacing: .2px; }
.card-sub { margin-top: 3px; font-size: 10.5px; color: var(--ink-4); }

.card-body { padding: 12px 13px; }
.card-body.tight { padding: 9px 13px; }

/* 键值行 */
.kv { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 12.5px; }
.kv + .kv { border-top: 1px dashed var(--line); }
.kv .k { color: var(--ink-4); flex: none; }
.kv .v { color: var(--ink); font-weight: 600; text-align: right; word-break: break-all; }
.kv .v.brand { color: var(--brand); }
.kv .v.ok { color: var(--success); }
.kv .v.warn { color: var(--warn); }

/* 保单卡片 */
.policy-card { position: relative; overflow: hidden; }
.policy-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-grad);
}
.policy-card.gold::before { background: var(--gold-grad); }
.policy-card.blue::before { background: var(--blue-grad); }
.policy-card .card-body { padding-left: 17px; }

.policy-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.policy-name { font-size: 13.5px; font-weight: 700; letter-spacing: .2px; }
.policy-plate {
  font-size: 11px; font-weight: 700; color: var(--ink-2);
  background: #F0F2F5; padding: 2px 8px; border-radius: 5px; letter-spacing: .5px;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; padding: 2.5px 8px; border-radius: var(--r-pill);
  background: var(--success-bg); color: var(--success); letter-spacing: .3px;
}
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.brand { background: var(--brand-50); color: var(--brand); }
.badge.grey { background: #F0F2F5; color: var(--ink-3); }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }

/* 卡片内操作按钮组 */
.card-actions { display: flex; gap: 8px; padding: 10px 13px 12px; border-top: 1px solid var(--line); }
.act {
  flex: 1; height: 33px; border-radius: var(--r-s);
  font-size: 12.5px; font-weight: 600; color: var(--brand);
  background: var(--brand-50); border: 1px solid var(--brand-100);
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: all .14s ease;
}
.act:hover { background: var(--brand-100); }
.act:active { transform: scale(.97); }
.act.ghost { color: var(--ink-3); background: #F5F6F8; border-color: var(--line-2); }
.act.ghost:hover { background: #EDEEF1; }
.act.solid { background: var(--brand-grad); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(199,0,11,.22); }
.act.solid:hover { filter: brightness(1.06); }
.act svg { width: 13px; height: 13px; }
.act:disabled { opacity: .45; pointer-events: none; }

/* 权益 / 服务宫格 */
.svc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding: 12px 13px; }
.svc {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 11px 4px 9px; border-radius: var(--r-m);
  background: var(--bg-2); border: 1px solid var(--line);
  transition: all .14s ease; text-align: center;
}
.svc:hover { border-color: var(--brand-200); background: var(--brand-50); transform: translateY(-1px); }
.svc:active { transform: scale(.96); }
.svc-ic {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  font-size: 19px; color: #fff;
}
.svc-ic svg { width: 20px; height: 20px; }
.svc-ic.red { background: var(--brand-grad); box-shadow: 0 4px 10px rgba(199,0,11,.22); }
.svc-ic.amber { background: var(--amber-grad); box-shadow: 0 4px 10px rgba(255,122,24,.22); }
.svc-ic.teal { background: var(--teal-grad); box-shadow: 0 4px 10px rgba(14,158,142,.22); }
.svc-ic.blue { background: var(--blue-grad); box-shadow: 0 4px 10px rgba(43,108,212,.22); }
.svc-ic.violet { background: var(--violet-grad); box-shadow: 0 4px 10px rgba(107,78,230,.22); }
.svc-ic.gold { background: var(--gold-grad); box-shadow: 0 4px 10px rgba(200,150,62,.24); }
.svc-name { font-size: 12px; font-weight: 600; color: var(--ink); }
.svc-tip { font-size: 9.5px; color: var(--ink-4); }

/* 进度条 */
.bar { height: 6px; border-radius: 99px; background: #EEF0F3; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--brand-grad); }

/* 时间轴 */
.timeline { padding: 4px 2px 2px 6px; }
.tl { position: relative; padding: 0 0 15px 22px; }
.tl:last-child { padding-bottom: 0; }
.tl::before {
  content: ""; position: absolute; left: 5px; top: 4px; width: 9px; height: 9px;
  border-radius: 50%; background: #D9DCE1; border: 2px solid #fff; box-shadow: 0 0 0 1px #D9DCE1;
}
.tl::after {
  content: ""; position: absolute; left: 9px; top: 15px; bottom: -1px; width: 1.5px; background: #E6E8EC;
}
.tl:last-child::after { display: none; }
.tl.done::before { background: var(--success); box-shadow: 0 0 0 1px var(--success); }
.tl.done::after { background: var(--success); opacity: .35; }
.tl.now::before { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--brand-100); } 50% { box-shadow: 0 0 0 6px var(--brand-50); } }
.tl-title { font-size: 12.5px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl.done .tl-title { color: var(--ink-2); }
.tl-time { font-size: 10.5px; color: var(--ink-4); margin-top: 3px; font-variant-numeric: tabular-nums; }
.tl-desc { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; line-height: 1.6; }

/* 表单卡片 */
.form-row { padding: 10px 0; }
.form-row + .form-row { border-top: 1px solid var(--line); }
.form-label { font-size: 11.5px; color: var(--ink-4); margin-bottom: 7px; display: flex; align-items: center; gap: 5px; }
.form-label .req { color: var(--brand); }
.form-input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--bg-2); font-size: 13px; color: var(--ink);
  outline: none; transition: all .15s ease;
}
.form-input::placeholder { color: #B9BEC6; }
.form-input:focus { border-color: var(--brand-300); background: #fff; box-shadow: 0 0 0 3px var(--brand-50); }

.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  padding: 8px 13px; border-radius: var(--r-s);
  background: var(--bg-2); border: 1px solid var(--line-2);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  transition: all .14s ease;
}
.opt:hover { border-color: var(--brand-300); color: var(--brand); }
.opt.on { background: var(--brand-50); border-color: var(--brand); color: var(--brand); font-weight: 700; box-shadow: 0 0 0 2px var(--brand-50); }

.upload {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-direction: column;
  height: 88px; border-radius: var(--r-m);
  border: 1.5px dashed var(--brand-200); background: var(--brand-50);
  color: var(--brand); font-size: 12px; font-weight: 600;
}
.upload svg { width: 22px; height: 22px; }
.upload.done { border-style: solid; border-color: var(--success); background: var(--success-bg); color: var(--success); }

/* 提示条 */
.tipbar {
  display: flex; gap: 8px; padding: 10px 12px; border-radius: var(--r-m);
  background: var(--brand-50); border: 1px solid var(--brand-100);
  font-size: 11.5px; line-height: 1.62; color: var(--brand-600);
}
.tipbar .ic { flex: none; font-size: 13px; line-height: 1.35; }
.tipbar.grey { background: var(--bg-2); border-color: var(--line); color: var(--ink-3); }

/* 小程序跳转引导卡 */
.mp-jump {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 13px; border-radius: var(--r-l);
  background: linear-gradient(135deg, #FFF5F5 0%, #FFFFFF 70%);
  border: 1px solid var(--brand-100);
  box-shadow: 0 4px 14px rgba(199,0,11,.09);
  transition: all .16s ease;
}
.mp-jump:hover { box-shadow: 0 8px 22px rgba(199,0,11,.16); transform: translateY(-1px); }
.mp-jump:active { transform: scale(.98); }
.mp-jump .mp-ic {
  width: 42px; height: 42px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: var(--brand-grad); color: #fff; font-size: 21px;
  box-shadow: 0 5px 12px rgba(199,0,11,.26);
}
.mp-jump .mp-txt { flex: 1; min-width: 0; }
.mp-jump .mp-t { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mp-jump .mp-t .mp-flag {
  font-size: 9px; font-weight: 700; color: #fff; background: var(--brand);
  padding: 1.5px 5px; border-radius: 4px; letter-spacing: .4px;
  flex: none; white-space: nowrap;
}
.mp-jump .mp-d { margin-top: 4px; font-size: 10.5px; color: var(--ink-4); line-height: 1.5; }
.mp-jump .mp-go {
  flex: none; height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--brand-grad); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px; box-shadow: 0 4px 10px rgba(199,0,11,.22);
  white-space: nowrap;
}
.mp-jump .mp-go svg { width: 12px; height: 12px; }
.mp-jump.opened { opacity: .62; }
.mp-jump.opened .mp-go { background: #C9CDD4; box-shadow: none; }

/* 快捷问题气泡 */
.quick-wrap { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.quick-title { font-size: 10.5px; color: var(--ink-4); padding-left: 3px; }
.quick {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: var(--r-pill);
  background: #fff; border: 1px solid var(--brand-100);
  font-size: 12.5px; color: var(--brand); font-weight: 600;
  box-shadow: var(--sh-1); transition: all .14s ease; text-align: left;
}
.quick:hover { background: var(--brand-50); border-color: var(--brand-300); transform: translateX(2px); }
.quick:active { transform: scale(.97); }
.quick::after { content: "›"; font-size: 14px; color: var(--brand-300); line-height: 1; }
.quick.plain { color: var(--ink-2); border-color: var(--line-2); }
.quick.plain::after { color: var(--ink-4); }
.quick.plain:hover { background: var(--bg-2); border-color: var(--line-2); }

/* ---------------- 输入区 ---------------- */
.chat-input {
  flex: none; background: #fff; border-top: 1px solid var(--line);
  padding: 8px 11px 10px;
}
.chat-input-top {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  overflow-x: auto; scrollbar-width: none; padding-bottom: 1px;
}
.chat-input-top::-webkit-scrollbar { display: none; }
.qi {
  flex: none; height: 27px; padding: 0 11px; border-radius: var(--r-pill);
  background: var(--brand-50); border: 1px solid var(--brand-100);
  color: var(--brand); font-size: 11.5px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px; transition: all .14s ease;
}
.qi:hover { background: var(--brand-100); }
.qi:active { transform: scale(.96); }

.chat-input-bar { display: flex; align-items: center; gap: 9px; }
.ci-ic { width: 30px; height: 30px; display: grid; place-items: center; color: var(--ink-3); flex: none; }
.ci-ic svg { width: 21px; height: 21px; }
.ci-field {
  flex: 1; height: 36px; border-radius: var(--r-pill);
  background: var(--bg-2); border: 1px solid var(--line-2);
  padding: 0 15px; font-size: 13px; color: var(--ink); outline: none;
}
.ci-field::placeholder { color: #B9BEC6; }
.ci-field:focus { border-color: var(--brand-300); background: #fff; box-shadow: 0 0 0 3px var(--brand-50); }
.ci-send {
  flex: none; height: 36px; padding: 0 17px; border-radius: var(--r-pill);
  background: var(--brand-grad); color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 11px rgba(199,0,11,.24); transition: all .14s ease;
}
.ci-send:hover { filter: brightness(1.06); }
.ci-send:active { transform: scale(.95); }
.ci-send:disabled { background: #D9DCE1; box-shadow: none; }

/* 滚动到底部按钮 */
.scroll-bottom {
  position: absolute; right: 14px; bottom: 118px; z-index: 25;
  width: 36px; height: 36px; border-radius: 50%; background: #fff;
  box-shadow: var(--sh-2); display: grid; place-items: center; color: var(--ink-3);
  border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.scroll-bottom.show { opacity: 1; pointer-events: auto; }
.scroll-bottom svg { width: 16px; height: 16px; }

/* 转人工排队浮层 */
.queue-layer {
  position: absolute; inset: 0; z-index: 45;
  background: rgba(20,22,26,.42); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 30px;
  animation: fadeIn .22s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.queue-card {
  width: 100%; background: #fff; border-radius: var(--r-xl);
  padding: 22px 20px 18px; text-align: center; box-shadow: var(--sh-3);
  animation: popIn .28s cubic-bezier(.22,1,.36,1) both;
}
@keyframes popIn { from { opacity: 0; transform: scale(.92) translateY(10px); } to { opacity: 1; transform: none; } }
.queue-ring {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 50%;
  border: 3px solid var(--brand-50); border-top-color: var(--brand);
  animation: spin 1s linear infinite;
  display: grid; place-items: center;
}
@keyframes spin { to { transform: rotate(360deg); } }
.queue-ring span { font-size: 17px; font-weight: 800; color: var(--brand); animation: spin 1s linear infinite reverse; }
.queue-t { font-size: 14.5px; font-weight: 700; }
.queue-d { margin-top: 7px; font-size: 12px; color: var(--ink-4); line-height: 1.7; }
