/* ============================================================
   在线客服 - 网页悬浮客服组件样式 (自适应)
   通过 css 变量控制主题色，便于集成到任意站点
   ============================================================ */
.cs-widget-mount {
  --cs-primary: #2f6bff;
  --cs-primary-dark: #1f56e0;
  --cs-bg: #ffffff;
  --cs-bubble-bg: #f1f3f7;
  --cs-radius: 12px;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.45;
}

/* 悬浮按钮 */
.cs-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cs-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s, background 0.2s;
  position: relative;
}
.cs-btn:hover { transform: scale(1.06); background: var(--cs-primary-dark); }
.cs-btn svg { width: 30px; height: 30px; fill: #fff; }
.cs-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ff4d4f;
  color: #fff;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-weight: 600;
}
.cs-badge.show { display: flex; }

/* 聊天窗口 */
.cs-panel {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--cs-bg);
  border-radius: var(--cs-radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
}
.cs-panel.open { display: flex; }

.cs-header {
  background: var(--cs-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.cs-header-title { flex: 1; font-size: 15px; font-weight: 600; }
.cs-header-sub { font-size: 12px; opacity: 0.9; margin-top: 2px; }
.cs-header-close {
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  opacity: 0.85;
  padding: 0 4px;
  background: none;
  border: none;
  color: #fff;
}
.cs-header-close:hover { opacity: 1; }

.cs-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cs-msg { max-width: 78%; padding: 9px 12px; border-radius: 10px; font-size: 14px; word-break: break-word; white-space: pre-wrap; }
.cs-msg--customer { background: var(--cs-primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.cs-msg--agent { background: var(--cs-bubble-bg); color: #1a1a1a; align-self: flex-start; border-bottom-left-radius: 3px; }
.cs-msg--system { background: transparent; color: #999; font-size: 12px; text-align: center; align-self: center; max-width: 100%; }
.cs-msg time { display: block; font-size: 11px; opacity: 0.7; margin-top: 3px; }
.cs-msg--customer time { text-align: right; }
.cs-msg img { max-width: 100%; border-radius: 6px; display: block; }
.cs-msg a { color: inherit; }

.cs-typing { display: none; font-size: 13px; color: #999; padding: 4px 2px; }

.cs-footer {
  border-top: 1px solid #ececec;
  padding: 8px;
  background: #fff;
  flex-shrink: 0;
}
.cs-input-row { display: flex; gap: 6px; align-items: flex-end; }
.cs-input {
  flex: 1;
  border: 1px solid #dcdfe6;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 100px;
  font-family: inherit;
  background: #fff;
  color: #1a1a1a;
}
.cs-input:focus { border-color: var(--cs-primary); }
.cs-send-btn {
  background: var(--cs-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}
.cs-send-btn:hover { background: var(--cs-primary-dark); }
.cs-toolbar { display: flex; gap: 4px; padding: 0 2px 6px; }
.cs-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  color: #666;
  font-size: 13px;
}
.cs-icon-btn:hover { background: #f0f1f4; color: #333; }
.cs-name-row { display: flex; gap: 6px; padding: 0 2px 6px; }
.cs-name-row input {
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  flex: 1;
  outline: none;
}
.cs-close-banner { text-align: center; padding: 8px; }
.cs-close-btn {
  background: none;
  border: 1px solid #dcdfe6;
  color: #666;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}

/* 移动端 */
@media (max-width: 480px) {
  .cs-widget-mount, .cs-panel { right: 8px; }
  .cs-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 80px;
    height: 75vh;
  }
}