/* 网页客服系统 · 访客聊天窗口（对齐 kf.12k.lol slim-blue 视觉） */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
:root {
  color-scheme: light;
  --kf-color: #635bff;
  --window-ink: #15243a;
  --window-muted: #8b9bb2;
  --line: rgba(69, 103, 151, .12);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--window-ink);
  background: #f5f8fc;
  -webkit-text-size-adjust: 100%;
}
.support-page { padding: 20px; }

.support-window {
  position: relative;
  width: min(100%, 420px);
  height: min(720px, calc(100vh - 40px));
  margin: auto;
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr) auto auto;
  border: 1px solid var(--line);
  border-radius: 27px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(35, 63, 105, .18), 0 2px 10px rgba(35, 63, 105, .05);
  overflow: hidden;
}

/* ---------------- 头部 ---------------- */
.support-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 17px 0;
  overflow: visible;
  color: var(--window-ink);
  background: linear-gradient(135deg, #dce9ff 0%, #eaf3ff 58%, #f8fbff 100%);
}
.support-head:before {
  content: "";
  position: absolute;
  right: -15px;
  top: -52px;
  width: 160px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .35);
  pointer-events: none;
}
.support-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  color: #2463ba;
  background-color: #e8f2ff;
  box-shadow: 0 6px 18px rgba(42, 98, 171, .16);
  font-weight: 800;
}
.support-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.support-head-copy { position: relative; z-index: 1; min-width: 0; display: grid; gap: 3px; }
.support-head-copy strong {
  color: var(--window-ink);
  font-size: 16px;
  font-weight: 820;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.support-head-copy small {
  position: relative;
  padding-left: 13px;
  color: #44566f;
  font-size: 10px;
  font-weight: 650;
}
.support-head-copy small:before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: #2bc46b;
  box-shadow: 0 0 0 3px rgba(43, 196, 107, .16);
}
.support-head-actions { position: relative; z-index: 1; margin-left: auto; display: flex; align-items: center; gap: 7px; }
.support-safe {
  padding: 4px 9px;
  border-radius: 999px;
  color: #2463ba;
  background: rgba(255, 255, 255, .72);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------------- 消息区 ---------------- */
.support-messages {
  position: relative;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  background: #f5f8fc;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.support-loading { margin: auto; color: var(--window-muted); font-size: 13px; text-align: center; }

.support-welcome-row {
  align-self: flex-start;
  width: 100%;
  max-width: 94%;
  display: flex;
  align-items: flex-start;
  gap: 7px;
}
.support-welcome {
  min-width: 0;
  max-width: calc(100% - 39px);
  padding: 10px 14px;
  border: 1px solid rgba(60, 60, 67, .06);
  border-radius: 14px 14px 14px 5px;
  background: #fff;
  color: #4b5b73;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 12px rgba(31, 37, 51, .055);
}
.support-welcome-text { white-space: pre-wrap; }
.support-welcome-text + .support-welcome-text { margin-top: 8px; }
.support-welcome img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 280px;
  margin-top: 8px;
  border-radius: 10px;
  cursor: zoom-in;
}
.support-welcome img:first-child { margin-top: 0; }

.support-message { max-width: 94%; display: flex; align-items: flex-end; gap: 7px; }
.support-message-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(39, 62, 94, .12);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
}
.support-message-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.support-message-avatar-agent { color: #2371ca; background: #e9f3ff; }
.support-message-avatar-visitor { color: #7689a3; background: linear-gradient(145deg, #f4f7fb, #e8eef5); }

.support-message.agent {
  align-self: flex-start;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-areas: "avatar bubble" ". time";
  align-items: start;
  column-gap: 7px;
  row-gap: 3px;
}
.support-message.agent .support-message-avatar { grid-area: avatar; }
.support-message.agent .support-bubble { grid-area: bubble; min-width: 0; }
.support-message.agent .support-time { grid-area: time; justify-self: start; }

.support-message.visitor { align-self: flex-end; flex-direction: row-reverse; }
.support-message.visitor .support-bubble {
  border: 0;
  border-radius: 17px 17px 5px 17px;
  background: linear-gradient(145deg, #7d76ff, var(--kf-color));
  color: #fff;
  box-shadow: 0 6px 16px rgba(99, 91, 255, .26);
}
.support-message.visitor .support-time { justify-self: end; }

.support-bubble {
  min-width: 0;
  max-width: 100%;
  padding: 10px 13px;
  border: 1px solid rgba(60, 60, 67, .06);
  border-radius: 17px 17px 17px 5px;
  background: #fff;
  color: #172033;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 12px rgba(31, 37, 51, .055);
}
.support-bubble.is-image { padding: 6px; background: #fff; }
.support-bubble img { display: block; width: auto; max-width: 100%; max-height: 300px; border-radius: 12px; cursor: zoom-in; }
.support-bubble .image-caption { margin-top: 7px; padding: 0 6px 4px; font-size: 13px; white-space: pre-wrap; }
.support-time { margin: 0 2px; color: #9aa6b8; font-size: 10px; }

.support-day { align-self: center; margin: 2px 0; color: #9aa6b8; font-size: 11px; }

/* ---------------- 输入区 ---------------- */
.support-composer {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 7px;
  padding: 10px 88px 8px 11px;
  border-top: 1px solid rgba(60, 60, 67, .1);
  background: rgba(255, 255, 255, .96);
}
.support-compose-tools { display: flex; align-items: center; }
.support-tool-toggle {
  width: 40px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  color: #55627a;
  background: #f2f4f8;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background .18s, transform .18s;
}
.support-tool-toggle:hover { background: #e8ecf4; }
.support-tool-toggle:active { transform: scale(.96); }
.support-composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  max-height: 96px;
  padding: 11px;
  border: 0;
  border-radius: 12px;
  color: #172033;
  background: rgba(118, 118, 128, .075);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  outline: 0;
}
.support-composer textarea:focus {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 91, 255, .13), inset 0 0 0 1px rgba(99, 91, 255, .3);
}
.support-send {
  position: absolute;
  right: 11px;
  top: 10px;
  min-width: 64px;
  height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #7d76ff, var(--kf-color));
  box-shadow: 0 6px 14px rgba(99, 91, 255, .28);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter .18s, transform .18s;
}
.support-send:hover { filter: brightness(1.05); }
.support-send:active { transform: scale(.97); }
.support-send[disabled] { color: #a9b0bf; background: #e6e9ef; box-shadow: none; cursor: not-allowed; }

.support-tip { padding: 0 12px 8px; color: #b04a4a; background: rgba(255, 255, 255, .96); font-size: 11px; }
.support-tip:empty { display: none; }
.support-error {
  margin: 0 14px 10px;
  padding: 10px 12px;
  border: 1px solid #f2d2d2;
  border-radius: 12px;
  color: #b04a4a;
  background: #fdf5f5;
  font-size: 12px;
  line-height: 1.6;
}
.support-error[hidden] { display: none !important; }

/* 图片放大 */
.support-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 18, 30, .86);
}
.support-lightbox.is-open { display: flex; }
.support-lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

@media (max-width: 520px) {
  .support-page { padding: 0; background: #fff; }
  .support-window {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .support-composer textarea { font-size: 16px; }
}
