﻿/* ============ 客服系统 · 访客端样式（移动端优先） ============ */
:root {
  --bg: #0c0a12;
  --panel: #15111f;
  --panel2: #1d1830;
  --line: rgba(255, 255, 255, .09);
  --txt: #ece9f7;
  --dim: #9a93b6;
  --dim2: #6d6685;
  --accent: #7c5cff;
  --accent2: #ff5c8a;
  --ok: #35d0a0;
  --danger: #ff5f6d;
  --bubble: #1d182d;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--txt);
  background:
    radial-gradient(900px 600px at 12% -10%, rgba(124, 92, 255, .28), transparent 60%),
    radial-gradient(800px 500px at 100% 110%, rgba(255, 92, 138, .18), transparent 60%),
    var(--bg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- 布局 ---------- */
.page {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 0;
}
.card {
  position: relative;
  width: min(760px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(24, 19, 36, .96), rgba(15, 12, 22, .98));
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  overflow: hidden;
}
@media (min-width: 760px) {
  .page { padding: 28px 20px; }
  .card {
    height: min(780px, calc(100dvh - 56px));
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  }
}

/* ---------- 头部 ---------- */
.head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: calc(12px + var(--safe-t)) 14px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 16, 30, .92);
  backdrop-filter: blur(12px);
  z-index: 5;
}
.ava {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #6f4dff, #c056ff);
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 8px 22px rgba(124, 92, 255, .4);
}
.head-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.head-info strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-info small { color: var(--dim2); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.head-info .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(53, 208, 160, .16);
}
.head-info .dot.off { background: var(--dim2); box-shadow: none; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  border-radius: 11px; cursor: pointer; color: var(--txt);
  flex: 0 0 auto;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:active { transform: scale(.94); }

.banner {
  margin: 8px 12px 0;
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: 12px;
  background: rgba(255, 182, 72, .1);
  border: 1px solid rgba(255, 182, 72, .3);
  color: #ffd694;
}
.banner.ok { background: rgba(53, 208, 160, .1); border-color: rgba(53, 208, 160, .3); color: #9ff0d3; }

/* ---------- 消息 ---------- */
.msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.welcome {
  align-self: center;
  max-width: 88%;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.8;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .04);
  border: 1px dashed var(--line);
}
.welcome b { display: block; color: var(--txt); font-size: 14px; margin-bottom: 4px; }

.sys {
  align-self: center;
  max-width: 86%;
  text-align: center;
  font-size: 12px;
  color: var(--dim);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 12px;
}
.msg { display: flex; gap: 9px; align-items: flex-start; animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg .ava { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 11px; font-size: 12.5px; margin-top: 16px; box-shadow: none; }
.msg .body { display: flex; flex-direction: column; gap: 3px; min-width: 0; max-width: min(80%, 520px); }
.msg .meta { font-size: 11px; color: var(--dim2); padding: 0 4px; display: flex; gap: 6px; }
.bubble {
  padding: 9px 13px;
  border-radius: 4px 16px 16px 16px;
  background: var(--bubble);
  border: 1px solid var(--line);
  font-size: 14.5px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-user-select: text; user-select: text;
}
.bubble img { display: block; max-width: 100%; max-height: 300px; border-radius: 12px; margin: -3px -5px; cursor: zoom-in; }
.bubble.img-bubble { padding: 0; background: transparent; border-color: transparent; box-shadow: none; }
.bubble.img-bubble img { margin: 0; max-height: 320px; }
.msg.me { flex-direction: row-reverse; }
.msg.me .body { align-items: flex-end; }
.msg.me .meta { flex-direction: row-reverse; }
.msg.me .bubble {
  background: linear-gradient(135deg, #6a49ff, #b04bff 70%, #d94bd0);
  border-color: transparent; color: #fff;
  border-radius: 16px 4px 16px 16px;
  box-shadow: 0 8px 24px rgba(110, 70, 255, .28);
}
.msg .read { font-size: 10.5px; color: var(--dim2); }
.msg.me .read { text-align: right; }

/* ---------- 快捷问题 ---------- */
.typing { height: 17px; padding: 0 18px; font-size: 11.5px; color: var(--dim2); font-style: italic; }
.quick {
  display: flex; gap: 7px; overflow-x: auto;
  padding: 2px 12px 8px;
  scrollbar-width: none;
}
.quick::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid rgba(124, 92, 255, .45);
  background: rgba(124, 92, 255, .12);
  color: #c9bcff;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  max-width: 70vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip:active { transform: scale(.97); }

/* ---------- 输入区 ---------- */
.composer {
  position: relative;
  display: flex; align-items: flex-end; gap: 7px;
  padding: 8px 10px calc(8px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: rgba(18, 14, 27, .95);
}
.composer .icon-btn { width: 38px; height: 38px; border-radius: 11px; }
#input {
  flex: 1; min-width: 0; max-height: 120px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .05);
  border-radius: 14px; padding: 10px 13px; resize: none; outline: none;
  line-height: 1.45; font-size: 15px;
}
#input:focus { border-color: rgba(124, 92, 255, .7); background: rgba(124, 92, 255, .08); }
#input:disabled { opacity: .6; }
.btn.send {
  width: 46px; height: 38px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 13px;
  background: linear-gradient(135deg, #6f4dff, #ff5c8a);
  color: #fff;
  box-shadow: 0 8px 22px rgba(124, 92, 255, .4);
  cursor: pointer;
}
.btn.send svg { width: 20px; height: 20px; }
.btn.send:disabled { filter: grayscale(.6); box-shadow: none; }
.emoji-panel {
  position: absolute; left: 8px; right: 8px; bottom: calc(62px + var(--safe-b));
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  max-height: 190px; overflow-y: auto;
  padding: 8px;
  background: #191426;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
  z-index: 20;
}
.emoji-panel button { border: 0; background: transparent; font-size: 21px; padding: 5px 0; border-radius: 9px; cursor: pointer; }
.emoji-panel button:hover { background: rgba(255, 255, 255, .08); }

.foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px 10px;
  font-size: 11.5px; color: var(--dim2);
  border-top: 1px solid rgba(255, 255, 255, .05);
}
.foot a { color: var(--dim); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .62);
  display: grid; place-items: center;
  padding: 18px;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #211a35, #161123);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .6);
}
.modal-card h3 { margin: 0 0 6px; font-size: 17px; }
.modal-card p { margin: 0 0 14px; color: var(--dim); font-size: 13px; }
.stars { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.stars button {
  border: 0; background: transparent; cursor: pointer;
  font-size: 32px; line-height: 1; color: rgba(255, 255, 255, .18);
  transition: transform .12s, color .15s;
  padding: 0 2px;
}
.stars button.on { color: #ffca3a; text-shadow: 0 0 18px rgba(255, 202, 58, .45); }
.stars button:active { transform: scale(1.15); }
.modal-card textarea, .modal-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
}
.modal-card textarea:focus, .modal-card input:focus { border-color: rgba(124, 92, 255, .7); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field > span { font-size: 12px; color: var(--dim); }
.modal-acts { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
}
.btn.primary { background: linear-gradient(135deg, #6f4dff, #ff5c8a); border-color: transparent; color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn:active { transform: scale(.97); }

/* ---------- 提示 ---------- */
.toasts {
  position: fixed; top: calc(16px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(33, 26, 53, .97);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 13px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
  animation: tin .2s ease;
  max-width: 88vw;
}
.toast.err { border-color: rgba(255, 95, 109, .5); color: #ffc2c7; }
.toast.ok { border-color: rgba(53, 208, 160, .5); color: #9ff0d3; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .93);
  display: grid; place-items: center; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- 开启提醒提示条 ---------- */
.notify-tip {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 12px 0; padding: 8px 10px;
  background: rgba(124, 92, 255, .12);
  border: 1px solid rgba(124, 92, 255, .4);
  border-radius: 12px;
  font-size: 12px; color: #cbb8ff;
}
.notify-tip span { flex: 1; line-height: 1.4; }
.notify-tip button {
  border: 0; border-radius: 8px; padding: 5px 10px;
  background: linear-gradient(135deg, #6f4dff, #ff5c8a);
  color: #fff; font-size: 12px; cursor: pointer; flex: 0 0 auto;
}
.notify-tip .tip-x { background: transparent; color: #9a93b6; padding: 4px 6px; }
