/* Superneer 在线客服 - 访客聊天窗口 */
#snchat-root,
#snchat-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

#snchat-root {
  --snchat-primary: #0b5fbf;
  --snchat-primary-dark: #094a95;
  --snchat-bg: #ffffff;
  --snchat-panel-bg: #f7f8fa;
  --snchat-text: #1f2430;
  --snchat-muted: #8a93a3;
  --snchat-border: #e6e9ef;
  --snchat-agent-bubble: #ffffff;
  --snchat-shadow: 0 18px 46px rgba(15, 35, 70, 0.18);
  position: fixed;
  z-index: 2147483000;
  right: 24px;
  bottom: 24px;
}

/* 悬浮按钮 */
#snchat-launcher {
  position: relative;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(135deg, #0b5fbf, #0a8ce0);
  box-shadow: 0 10px 24px rgba(11, 95, 191, 0.38);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}

#snchat-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 30px rgba(11, 95, 191, 0.46);
}

#snchat-launcher svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

#snchat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #e5342b;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  display: none;
  box-shadow: 0 0 0 2px #fff;
}

#snchat-badge.show {
  display: block;
}

/* 面板 */
#snchat-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 366px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--snchat-bg);
  border-radius: 18px;
  box-shadow: var(--snchat-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

#snchat-panel.snchat-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* 头部 */
.snchat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0b5fbf, #0a7fe0);
  color: #fff;
  flex: 0 0 auto;
}

.snchat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}

.snchat-head-info {
  flex: 1 1 auto;
  min-width: 0;
}

.snchat-head-info strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.snchat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  opacity: 0.92;
  margin-top: 2px;
}

.snchat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7ef0a6;
  box-shadow: 0 0 0 2px rgba(126, 240, 166, 0.28);
}

.snchat-dot.off {
  background: #ffb3ad;
  box-shadow: 0 0 0 2px rgba(255, 179, 173, 0.28);
}

#snchat-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  opacity: 0.85;
  border-radius: 8px;
}

#snchat-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.14);
}

/* 消息区 */
.snchat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: var(--snchat-panel-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.snchat-msg {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.snchat-msg.agent {
  align-self: flex-start;
  align-items: flex-start;
}

.snchat-msg.me {
  align-self: flex-end;
  align-items: flex-end;
}

.snchat-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.snchat-msg.agent .snchat-bubble {
  background: var(--snchat-agent-bubble);
  color: var(--snchat-text);
  border: 1px solid var(--snchat-border);
  border-bottom-left-radius: 5px;
}

.snchat-msg.me .snchat-bubble {
  background: var(--snchat-primary);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.snchat-msg.me .snchat-bubble.pending {
  opacity: 0.7;
}

.snchat-msg.me .snchat-bubble.failed {
  background: #b42318;
}

/* 富媒体消息：图片 / 文件 / 语音 */
.snchat-bubble.snchat-bubble-media {
  padding: 4px;
  background: transparent !important;
  border: none !important;
}

.snchat-img {
  display: block;
  max-width: 200px;
  max-height: 160px;
  border-radius: 10px;
  cursor: zoom-in;
  object-fit: cover;
}

.snchat-file {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  word-break: break-all;
}

.snchat-msg.agent .snchat-file {
  background: var(--snchat-agent-bubble);
  border: 1px solid var(--snchat-border);
}

.snchat-bubble audio {
  display: block;
  max-width: 220px;
  height: 36px;
}

.snchat-time {
  font-size: 11px;
  color: var(--snchat-muted);
  margin-top: 4px;
}

.snchat-sys {
  align-self: center;
  max-width: 92%;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--snchat-muted);
  background: rgba(11, 95, 191, 0.06);
  border-radius: 10px;
  padding: 8px 12px;
}

.snchat-typing {
  align-self: flex-start;
  font-size: 12px;
  color: var(--snchat-muted);
  padding-left: 4px;
  height: 16px;
}

/* 底部输入 */
.snchat-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--snchat-border);
  background: var(--snchat-bg);
  padding: 10px 12px 12px;
}

.snchat-offline-tip {
  display: none;
  font-size: 12px;
  color: #9a5b00;
  background: #fff7e6;
  border: 1px solid #ffe0a3;
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 8px;
  line-height: 1.5;
}

.snchat-offline-tip.show {
  display: block;
}

.snchat-offline-tip a {
  color: var(--snchat-primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.snchat-input-row {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

/* 工具栏 */
.snchat-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 4px;
}
.snchat-tool {
  width: 30px;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  opacity: 0.82;
  transition: background .15s, opacity .15s;
}
.snchat-tool:hover { background: #eef2ff; opacity: 1; }
.snchat-tool.active { background: #dbeafe; opacity: 1; }

/* 表情面板 */
.snchat-emoji-panel {
  position: absolute;
  left: 12px; right: 12px; bottom: 100%; margin-bottom: 6px;
  width: auto; max-height: 220px; overflow-y: auto;
  background: #fff; border: 1px solid var(--snchat-border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.14); padding: 6px; z-index: 40;
  display: none;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
}
.snchat-emoji-panel span {
  font-size: 19px; text-align: center; cursor: pointer;
  padding: 2px 0; border-radius: 4px; line-height: 1.4;
}
.snchat-emoji-panel span:hover { background: #f1f5f9; }

#snchat-input {
  width: 100%;
  resize: none;
  border: 1px solid var(--snchat-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  max-height: 180px;
  min-height: 76px;
  outline: none;
  color: var(--snchat-text);
  background: var(--snchat-bg);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

#snchat-input:focus {
  border-color: var(--snchat-primary);
  box-shadow: 0 0 0 3px rgba(11, 95, 191, 0.12);
}

/* 发送按钮放在右下方 */
#snchat-send {
  align-self: flex-end;
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--snchat-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease;
}

#snchat-send:hover {
  background: var(--snchat-primary-dark);
}

#snchat-send:disabled {
  opacity: 0.55;
  cursor: default;
}

/* 评价弹窗 */
.snchat-modal {
  position: fixed; inset: 0; z-index: 2147483001;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
}
.snchat-modal-card {
  width: 340px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: 14px; padding: 22px;
  box-shadow: 0 22px 54px rgba(0,0,0,.25);
}
.snchat-modal-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--snchat-text); }
.snchat-stars { display: flex; gap: 8px; margin-bottom: 14px; }
.snchat-stars span {
  font-size: 34px; color: #d1d5db; cursor: pointer; transition: transform .15s, color .15s;
}
.snchat-stars span:hover { transform: scale(1.15); }
.snchat-stars span.on { color: #f59e0b; }
#snchat-rate-note {
  width: 100%; min-height: 64px; resize: none;
  border: 1px solid var(--snchat-border); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; outline: none;
}
#snchat-rate-note:focus { border-color: var(--snchat-primary); box-shadow: 0 0 0 3px rgba(11,95,191,.12); }
.snchat-rate-actions { display: flex; gap: 8px; margin-top: 12px; }
.snchat-rate-actions button {
  height: 34px; padding: 0 14px; border: 0; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.snchat-rate-msg { font-size: 12px; color: var(--snchat-muted); margin-top: 8px; min-height: 16px; }

/* 离线留言表单 */
.snchat-leave {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.snchat-leave.show {
  display: flex;
}

.snchat-leave input,
.snchat-leave textarea {
  width: 100%;
  border: 1px solid var(--snchat-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  color: var(--snchat-text);
  background: var(--snchat-bg);
}

.snchat-leave textarea {
  min-height: 74px;
  resize: vertical;
}

.snchat-leave-actions {
  display: flex;
  gap: 8px;
}

.snchat-leave-actions button {
  flex: 1 1 auto;
  height: 36px;
  border: 0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.snchat-btn-primary {
  background: var(--snchat-primary);
  color: #fff;
}

.snchat-btn-ghost {
  background: transparent;
  color: var(--snchat-muted);
  border: 1px solid var(--snchat-border) !important;
}

.snchat-leave-msg {
  font-size: 12px;
  color: var(--snchat-muted);
  min-height: 16px;
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  #snchat-root {
    --snchat-bg: #171b23;
    --snchat-panel-bg: #10141b;
    --snchat-text: #e8ecf3;
    --snchat-muted: #8b94a6;
    --snchat-border: #2a303b;
    --snchat-agent-bubble: #1d2430;
    --snchat-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
  }

  .snchat-offline-tip {
    background: #2a2213;
    border-color: #4a3a17;
    color: #ffcf7a;
  }
}

/* 移动端全屏 */
@media (max-width: 560px) {
  #snchat-root {
    right: 16px;
    bottom: 16px;
  }

  #snchat-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}

/* ===== 面板拖动 / 缩放 ===== */
#snchat-panel .snchat-head {
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#snchat-panel .snchat-head #snchat-close {
  cursor: pointer;
}

.snchat-resizer {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  z-index: 20;
  cursor: nwse-resize;
  touch-action: none;
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(11, 95, 191, 0.35) 46% 56%, transparent 56% 68%, rgba(11, 95, 191, 0.5) 68% 78%, transparent 78%);
  border-bottom-right-radius: 18px;
}

.snchat-resizer:hover {
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(11, 95, 191, 0.6) 46% 56%, transparent 56% 68%, rgba(11, 95, 191, 0.8) 68% 78%, transparent 78%);
}

body.snchat-dragging,
body.snchat-dragging * {
  cursor: move !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

body.snchat-resizing,
body.snchat-resizing * {
  cursor: nwse-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

@media (max-width: 560px) {
  .snchat-resizer {
    display: none;
  }

  #snchat-panel .snchat-head {
    cursor: default;
  }
}
