/* ============ 泡泡鱼潮玩 · 客服浮窗 ============ */
#kefu-widget {
  --kefu-pink: #ff6fa5;
  --kefu-pink-deep: #f45a8e;
  --kefu-pink-light: #ffeef4;
  --kefu-blue: #5b9cff;
  --kefu-text: #3a3a3a;
  --kefu-gray: #9a9a9a;
  --kefu-bg: #fff;
  --kefu-radius: 18px;
  position: fixed;
  right: 0;
  bottom: 18px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}
#kefu-widget * { box-sizing: border-box; margin: 0; padding: 0; }
#kefu-widget img { max-width: 100%; }

/* 悬浮气泡: 平时挂在右上角边缘, 漏出左半圆 */
#kefu-bubble {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kefu-pink) 0%, #ff8fb5 60%, #ffb3cc 100%);
  box-shadow: 0 6px 20px rgba(255, 111, 165, .45), 0 0 0 6px rgba(255, 111, 165, .12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  transform: translateX(30px);
  transition: transform .3s ease;
  border: none; outline: none;
}
#kefu-bubble:hover { transform: translateX(20px); }
#kefu-widget.open #kefu-bubble { transform: translateX(64px); }
#kefu-bubble svg { width: 30px; height: 30px; }
#kefu-bubble .kefu-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 22px; height: 22px; padding: 0 6px;
  background: #ff4d4f; color: #fff; font-size: 12px;
  border-radius: 11px; display: none; align-items: center; justify-content: center;
  font-weight: 600; box-shadow: 0 2px 6px rgba(255,77,79,.4);
}
#kefu-bubble .kefu-badge.show { display: flex; }

/* 聊天面板: 右下角弹出 */
#kefu-panel {
  position: fixed; right: 18px; bottom: 88px;
  width: 380px; height: 560px; max-height: calc(100vh - 120px);
  background: var(--kefu-bg);
  border-radius: var(--kefu-radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.16), 0 0 0 1px rgba(255,111,165,.15);
  display: none; flex-direction: column; overflow: hidden;
  animation: kefu-pop .28s ease;
}
#kefu-widget.open #kefu-panel { display: flex; }
@keyframes kefu-pop { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }

/* 头部 */
#kefu-head {
  background: linear-gradient(135deg, var(--kefu-pink) 0%, #ff8fb5 100%);
  color: #fff; padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
#kefu-head .kefu-logo {
  width: 38px; height: 38px; border-radius: 50%;
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 20px; overflow: hidden; flex-shrink: 0;
}
#kefu-head .kefu-logo img { width: 100%; height: 100%; object-fit: cover; }
#kefu-head .kefu-head-text { flex: 1; min-width: 0; }
#kefu-head .kefu-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#kefu-head .kefu-status-line { font-size: 11px; opacity: .92; display: flex; align-items: center; gap: 4px; }
#kefu-head .kefu-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #3ad28f; display: inline-block; }
#kefu-head .kefu-status-dot.off { background: #ffd65c; }
#kefu-close { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; padding: 4px 6px; opacity: .85; line-height: 1; }
#kefu-close:hover { opacity: 1; }

/* FAQ 快捷问题 */
#kefu-faq {
  background: var(--kefu-pink-light);
  padding: 8px 12px; display: none; flex-wrap: wrap; gap: 6px;
  border-bottom: 1px solid rgba(255,111,165,.15);
}
#kefu-faq.show { display: flex; }
#kefu-faq .kefu-faq-item {
  font-size: 12px; color: var(--kefu-pink-deep);
  background: #fff; border: 1px solid #ffc7d8; border-radius: 14px;
  padding: 4px 12px; cursor: pointer; transition: all .2s;
}
#kefu-faq .kefu-faq-item:hover { background: var(--kefu-pink); color: #fff; border-color: var(--kefu-pink); }

/* 消息区 */
#kefu-msgs {
  flex: 1; overflow-y: auto; padding: 12px 12px 8px;
  background: #faf7f9;
  scroll-behavior: smooth;
}
.kefu-msg { display: flex; margin-bottom: 12px; align-items: flex-end; gap: 8px; }
.kefu-msg .kefu-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #ffd1e0, #ff9ec0);
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff;
  overflow: hidden;
}
.kefu-msg .kefu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.kefu-msg .kefu-bubble-text {
  max-width: 82%;
  padding: 9px 13px; border-radius: 16px; font-size: 14px; color: var(--kefu-text);
  word-break: normal; overflow-wrap: break-word; white-space: pre-wrap; overflow: visible;
  line-height: 1.5;
}
.kefu-msg.visitor { flex-direction: row-reverse; }
.kefu-msg.visitor .kefu-bubble-text {
  background: linear-gradient(135deg, var(--kefu-pink), #ff8fb5);
  color: #fff; border-bottom-right-radius: 4px;
}
.kefu-msg.agent .kefu-bubble-text, .kefu-msg.system .kefu-bubble-text {
  background: #fff; border: 1px solid #f2e3e9; border-bottom-left-radius: 4px;
}
.kefu-msg.system .kefu-avatar, .kefu-msg.system .kefu-bubble-text { background: transparent; border: none; }
.kefu-msg.system { justify-content: center; }
.kefu-msg.system .kefu-bubble-text {
  font-size: 12px; color: var(--kefu-gray); background: #f0eef0;
  border-radius: 12px; padding: 5px 12px; max-width: 92%;
  word-break: normal; overflow-wrap: break-word; white-space: pre-wrap; overflow: visible;
}
.kefu-msg .kefu-time { font-size: 10px; color: #c5c5c5; align-self: flex-end; padding: 0 2px 2px; }
.kefu-msg img.kefu-img { max-width: 200px; max-height: 200px; border-radius: 12px; display: block; cursor: zoom-in; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.kefu-product-card {
  width: 230px; background: #fff; border: 1px solid #f2e3e9; border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 2px 10px rgba(0,0,0,.05);
}
.kefu-product-card img { width: 100%; height: 120px; object-fit: cover; }
.kefu-product-card .kefu-pc-body { padding: 8px 10px; }
.kefu-product-card .kefu-pc-title { font-size: 13px; font-weight: 600; color: var(--kefu-text); }
.kefu-product-card .kefu-pc-link { display: block; font-size: 11px; color: var(--kefu-blue); margin-top: 4px; word-break: break-all; }

/* 输入区 */
#kefu-inputbar {
  padding: 10px 12px; background: #fff; border-top: 1px solid #f2e3e9;
  display: flex; flex-direction: column; gap: 8px; position: relative;
}
/* 表情面板 */
#kefu-emoji-panel {
  display: none; position: absolute; left: 10px; right: 10px; bottom: 46px;
  background: #fff; border: 1px solid #f2e3e9; border-radius: 12px;
  box-shadow: 0 6px 20px rgba(255,120,170,.18); padding: 8px; z-index: 9;
  max-height: 170px; overflow-y: auto;
}
#kefu-emoji-panel.show { display: block; }
.kefu-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.kefu-emoji-item {
  background: none; border: none; font-size: 20px; cursor: pointer; line-height: 1.35;
  padding: 4px 2px; border-radius: 8px; transition: background .15s, transform .15s;
}
.kefu-emoji-item:hover { background: #ffeef4; transform: scale(1.18); }
/* ➕ 更多菜单 */
#kefu-plus-menu {
  display: none; position: absolute; left: 10px; bottom: 46px;
  background: #fff; border: 1px solid #f2e3e9; border-radius: 12px;
  box-shadow: 0 6px 20px rgba(255,120,170,.18); padding: 6px; z-index: 10;
  flex-direction: column; gap: 2px; min-width: 120px;
}
#kefu-plus-menu.show { display: flex; }
#kefu-plus-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; font-size: 13px; color: var(--kefu-text);
  padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background .15s;
}
#kefu-plus-menu button:hover { background: #ffeef4; }
#kefu-input-tools { display: flex; align-items: center; gap: 12px; }
#kefu-input-tools button {
  background: none; border: none; font-size: 18px; cursor: pointer; padding: 2px; line-height: 1;
  display: flex; align-items: center; color: var(--kefu-pink-deep); transition: transform .2s;
}
#kefu-input-tools button:hover { transform: scale(1.15); }
#kefu-input-tools .kefu-tip { font-size: 11px; color: var(--kefu-gray); margin-left: auto; }
#kefu-input-row { display: flex; gap: 8px; align-items: flex-end; }
#kefu-input {
  flex: 1; border: 1px solid #ead9e0; border-radius: 20px; padding: 9px 14px;
  font-size: 14px; outline: none; resize: none; max-height: 90px; min-height: 38px;
  font-family: inherit; line-height: 1.5;
  transition: border-color .2s;
}
#kefu-input:focus { border-color: var(--kefu-pink); }
#kefu-send {
  background: linear-gradient(135deg, var(--kefu-pink), #ff8fb5);
  color: #fff; border: none; border-radius: 20px; padding: 9px 20px;
  font-size: 14px; cursor: pointer; font-weight: 600; flex-shrink: 0;
  transition: opacity .2s;
}
#kefu-send:hover { opacity: .88; }
#kefu-send:disabled { opacity: .5; cursor: not-allowed; }
#kefu-img-input { display: none; }

/* 满意度 */
#kefu-rating {
  position: absolute; inset: 0; background: rgba(255,255,255,.97);
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  z-index: 5; padding: 20px; text-align: center;
}
#kefu-rating.show { display: flex; }
#kefu-rating .kefu-rate-title { font-size: 16px; font-weight: 700; color: var(--kefu-text); }
#kefu-rating .kefu-rate-sub { font-size: 12px; color: var(--kefu-gray); }
#kefu-rating .kefu-stars { display: flex; gap: 8px; }
#kefu-rating .kefu-stars span { font-size: 34px; cursor: pointer; filter: grayscale(1); opacity: .4; transition: all .2s; }
#kefu-rating .kefu-stars span.on { filter: none; opacity: 1; transform: scale(1.1); }
#kefu-rating .kefu-rate-btn {
  background: linear-gradient(135deg, var(--kefu-pink), #ff8fb5); color: #fff;
  border: none; padding: 9px 34px; border-radius: 20px; font-size: 14px; cursor: pointer;
}
#kefu-rating .kefu-rate-skip { background: none; border: none; color: var(--kefu-gray); font-size: 12px; cursor: pointer; }

/* 图片预览 */
#kefu-img-preview {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.8);
  z-index: 100000; align-items: center; justify-content: center; cursor: zoom-out;
}
#kefu-img-preview.show { display: flex; }
#kefu-img-preview img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* 移动端 */
@media (max-width: 520px) {
  #kefu-panel { width: 100vw; height: 100vh; max-height: none; right: 0; bottom: 0; border-radius: 0; }
  #kefu-widget.open #kefu-bubble { display: none; }
}
