/* ==========================================================================
   智能客服 (AI Assistant) — Metabam
   ========================================================================== */

/* 触发按钮组 */
.fab-stack{
  position:fixed;right:26px;bottom:26px;z-index:90;
  display:flex;flex-direction:column;align-items:flex-end;gap:14px;
}

.chat-fab{
  position:relative;
  width:60px;height:60px;border-radius:50%;
  background:linear-gradient(145deg,#2b2723,#17140f);
  display:grid;place-items:center;cursor:pointer;
  box-shadow:0 12px 30px rgba(0,0,0,.28);
  transition:transform .35s var(--ease),box-shadow .35s var(--ease);
}
.chat-fab:hover{transform:translateY(-4px) scale(1.04);box-shadow:0 18px 38px rgba(0,0,0,.32);}
.chat-fab svg{width:26px;height:26px;fill:none;stroke:#d9c3a0;stroke-width:1.6;}
.chat-fab .dot{
  position:absolute;top:2px;right:2px;width:12px;height:12px;border-radius:50%;
  background:#e0533d;border:2px solid #fff;display:none;
}
.chat-fab.has-msg .dot{display:block;}
.chat-fab.open svg.icon-chat{display:none;}
.chat-fab svg.icon-close{display:none;}
.chat-fab.open svg.icon-close{display:block;}

/* 面板 */
.chat-panel{
  position:fixed;right:26px;bottom:100px;z-index:95;
  width:392px;max-width:calc(100vw - 32px);
  height:600px;max-height:calc(100vh - 140px);
  background:#fff;border-radius:18px;overflow:hidden;
  box-shadow:0 30px 80px rgba(0,0,0,.22),0 2px 0 rgba(0,0,0,.04);
  display:flex;flex-direction:column;
  opacity:0;visibility:hidden;transform:translateY(16px) scale(.98);
  transform-origin:bottom right;
  transition:opacity .32s var(--ease),transform .32s var(--ease),visibility .32s;
}
.chat-panel.open{opacity:1;visibility:visible;transform:none;}

/* 头部 */
.chat-head{
  flex:0 0 auto;padding:18px 20px;
  background:linear-gradient(135deg,#241f1a,#3a332a);
  color:#fff;display:flex;align-items:center;gap:12px;
}
.chat-ava{
  width:38px;height:38px;flex:0 0 38px;border-radius:50%;
  background:rgba(255,255,255,.1);border:1px solid rgba(217,195,160,.5);
  display:grid;place-items:center;font-size:13px;letter-spacing:.04em;color:#e0cba8;
}
.chat-head .h-txt{flex:1;min-width:0;}
.chat-head b{display:block;font-size:14.5px;font-weight:500;letter-spacing:.01em;}
.chat-head span{display:flex;align-items:center;gap:6px;font-size:11.5px;color:rgba(255,255,255,.66);margin-top:3px;}
.chat-head span i{
  width:6px;height:6px;border-radius:50%;background:#5ec97b;display:inline-block;
  box-shadow:0 0 0 3px rgba(94,201,123,.18);
}
.chat-x{
  width:30px;height:30px;border-radius:50%;display:grid;place-items:center;
  color:rgba(255,255,255,.7);font-size:18px;line-height:1;transition:all .25s;
}
.chat-x:hover{background:rgba(255,255,255,.12);color:#fff;}

/* 消息区 */
.chat-body{
  flex:1 1 auto;min-height:0;overflow-y:auto;padding:20px 18px 8px;
  background:#faf8f5;scroll-behavior:smooth;
}
.chat-body::-webkit-scrollbar{width:6px;}
.chat-body::-webkit-scrollbar-thumb{background:#dcd5cb;border-radius:6px;}

.msg{display:flex;gap:9px;margin-bottom:14px;animation:msgIn .34s var(--ease) both;}
@keyframes msgIn{from{opacity:0;transform:translateY(8px);}to{opacity:1;transform:none;}}
.msg .bubble{
  max-width:82%;padding:11px 14px;border-radius:14px;
  font-size:13.5px;line-height:1.62;color:var(--ink-2);
  background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.05);
  border-bottom-left-radius:4px;
}
.msg .bubble b{color:var(--ink);font-weight:700;}
.msg .bubble ul{margin:8px 0 0;padding-left:16px;list-style:disc;}
.msg .bubble li{margin:3px 0;}
.msg .bubble a{color:var(--gold-d);text-decoration:underline;}
.msg.me{flex-direction:row-reverse;}
.msg.me .bubble{
  background:#2b2723;color:#fff;border-bottom-left-radius:14px;border-bottom-right-radius:4px;
}
.msg.me .bubble a{color:#e8d3ae;}

.msg .mini-ava{
  width:26px;height:26px;flex:0 0 26px;border-radius:50%;margin-top:2px;
  background:#efe9e0;display:grid;place-items:center;
  font-size:10px;color:#9a8f7e;letter-spacing:.02em;
}
.msg.me .mini-ava{display:none;}

/* 输入中 */
.typing{display:flex;gap:4px;padding:4px 2px;}
.typing i{
  width:6px;height:6px;border-radius:50%;background:#b9b0a2;display:block;
  animation:blink 1.2s infinite;
}
.typing i:nth-child(2){animation-delay:.18s;}
.typing i:nth-child(3){animation-delay:.36s;}
@keyframes blink{0%,60%,100%{opacity:.28;transform:translateY(0);}30%{opacity:1;transform:translateY(-3px);}}

/* 快捷问题 */
.chips{
  flex:0 0 auto;
  display:flex;gap:8px;flex-wrap:wrap;padding:6px 18px 12px;background:#faf8f5;
}
.chips button{
  font-size:12px;padding:7px 13px;border-radius:20px;
  border:1px solid #ded6ca;color:#5c5449;background:#fff;
  transition:border-color .25s ease,color .25s ease,background .25s ease;white-space:nowrap;
}
.chips button:hover{border-color:var(--gold);color:var(--gold-d);background:#fffdfa;}

/* 输入栏 */
.chat-input{
  flex:0 0 auto;display:flex;align-items:center;gap:8px;
  padding:12px 14px;border-top:1px solid #eee7dd;background:#fff;
}
.chat-input input{
  flex:1;border:0;outline:none;font-size:13.5px;color:var(--ink);
  padding:9px 4px;font-family:inherit;background:transparent;
}
.chat-input input::placeholder{color:#a9a196;}
.chat-send{
  width:38px;height:38px;flex:0 0 38px;border-radius:50%;
  background:var(--gold);display:grid;place-items:center;
  transition:all .25s var(--ease);
}
.chat-send:hover{background:var(--gold-d);}
.chat-send svg{width:16px;height:16px;fill:none;stroke:#fff;stroke-width:1.9;}

.chat-foot{
  flex:0 0 auto;text-align:center;font-size:10.5px;color:#b3aa9d;
  padding:0 0 9px;background:#fff;
}

/* 移动端 */
@media (max-width:640px){
  .fab-stack{right:16px;bottom:16px;gap:12px;}
      .chat-fab{width:54px;height:54px;}
  .chat-fab svg{width:23px;height:23px;}
  .chat-panel{
    right:0;left:0;bottom:0;width:100%;max-width:100%;
    height:86vh;max-height:86vh;border-radius:18px 18px 0 0;
    transform:translateY(100%);
  }
  .chat-panel.open{transform:none;}
  .msg .bubble{max-width:86%;}
}
