/* ===== 腾讯Knocket风格 客服嵌入组件 ===== */
.kq-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

/* 浮动按钮 */
.kq-btn {
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: #07c160;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(7, 193, 96, 0.35);
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
}
.kq-btn:hover {
  background: #06b357;
  transform: scale(1.04);
  box-shadow: 0 6px 18px rgba(7, 193, 96, 0.45);
}
.kq-btn svg {
  width: 26px;
  height: 26px;
  fill: #fff;
}
.kq-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  background: #ff4d4f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 1.5px solid #fff;
}
.kq-badge.show { display: flex; }

/* 聊天面板 */
.kq-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  height: 560px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.16);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: kqSlideUp 0.28s ease;
}
.kq-panel.open { display: flex; }

@keyframes kqSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 头部 */
.kq-header {
  height: 56px;
  background: #f5f5f5;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
}
.kq-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.kq-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #07c160;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.kq-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}
.kq-status {
  font-size: 12px;
  font-weight: 600;
}
.kq-status.online { color: #52c41a; }
.kq-status.offline { color: #ff4d4f; }
.kq-header-actions {
  display: flex;
  gap: 8px;
}
.kq-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #d9d9d9;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 14px;
}
.kq-icon-btn:hover { background: #f5f5f5; border-color: #bfbfbf; }

/* 消息区域 */
.kq-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f5f5f5;
}
.kq-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
  word-break: break-word;
}
.kq-msg.customer {
  align-self: flex-start;
  background: #ffffff;
  color: #333;
  border-bottom-left-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.kq-msg.agent {
  align-self: flex-end;
  background: #07c160;
  color: #fff;
  border-bottom-right-radius: 2px;
}
.kq-msg.system {
  align-self: center;
  background: transparent;
  color: #999;
  font-size: 12px;
  padding: 6px 0;
  max-width: 100%;
  text-align: center;
}
.kq-time {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 4px;
  display: block;
}
.kq-msg.customer .kq-time { text-align: left; color: #aaa; }
.kq-msg.agent .kq-time { text-align: right; color: rgba(255,255,255,0.8); }

/* 输入区域 */
.kq-input-area {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e8e8e8;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.kq-emoji-btn, .kq-file-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid #d9d9d9;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 16px;
  flex-shrink: 0;
}
.kq-emoji-btn:hover, .kq-file-btn:hover { background: #f5f5f5; }
.kq-input {
  flex: 1;
  height: 34px;
  min-height: 34px;
  max-height: 100px;
  padding: 0 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
}
.kq-input:focus { border-color: #07c160; }
.kq-send {
  min-width: 46px;
  width: auto;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  height: 34px;
  border-radius: 6px;
  background: #d9d9d9;
  color: #fff;
  border: none;
  cursor: not-allowed;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.kq-send.enabled {
  background: #07c160;
  cursor: pointer;
}
.kq-send.enabled:hover { background: #06b357; }
.kq-send svg { width: 18px; height: 18px; fill: #fff; }

/* 欢迎语 */
.kq-welcome {
  position: absolute;
  bottom: 92px;
  right: 24px;
  background: #07c160;
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(7, 193, 96, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.kq-welcome.show { opacity: 1; }

/* 离线提示 */
.kq-offline {
  position: absolute;
  bottom: 92px;
  right: 24px;
  background: #fff;
  border: 1px solid #d9d9d9;
  color: #666;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  pointer-events: none;
  display: none;
  white-space: nowrap;
}

/* 滚动条 */
.kq-messages::-webkit-scrollbar { width: 6px; }
.kq-messages::-webkit-scrollbar-track { background: transparent; }
.kq-messages::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 3px; }

/* 移动端适配 */
@media (max-width: 480px) {
  .kq-widget { bottom: 16px; right: 16px; }
  .kq-btn { bottom: 16px; right: 16px; width: 50px; height: 50px; border-radius: 25px; }
  .kq-panel {
    width: calc(100vw - 32px);
    left: 16px;
    right: auto;
    bottom: 74px;
    height: 70vh;
    max-height: 620px;
  }
  .kq-welcome, .kq-offline { right: 16px; bottom: 90px; left: 16px; text-align: center; }
}