/* 168客服 访客客户端样式 - 居中窗口设计 v2 */
/* 全局规范：卡片圆角12px、按钮圆角8px、消息气泡68%、弹窗过渡0.25s */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, sans-serif;
  background: #e8eaf6;
  overflow: hidden;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10%;
  box-sizing: border-box;
}
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 浮动粒子背景 */
.particles-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  animation: particleFloat linear infinite;
}
@keyframes particleFloat {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) rotate(720deg);
    opacity: 0;
  }
}

/* 光点闪烁效果 */
.sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.8);
  animation: sparkleAnim 3s ease-in-out infinite;
}
@keyframes sparkleAnim {
  0%, 100% { opacity: 0; transform: scale(0); }
  50% { opacity: 1; transform: scale(1); }
}

/* ========== 客服系统容器 - 居中窗口 ========== */
.kefu-fullscreen {
  position: relative;
  width: 100%;
  height: 95%;
  max-width: 800px;
  min-width: 400px;
  background: linear-gradient(180deg, #1a237e 0%, #283593 30%, #3949ab 60%, #5c6bc0 100%);
  overflow: hidden;
  z-index: 1;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

/* 波浪装饰 - SVG背景 */
.kefu-waves {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 200px;
  z-index: 1;
  opacity: 0.6;
  animation: waveMove 8s ease-in-out infinite;
}
@keyframes waveMove {
  0%, 100% { transform: translateX(0) scaleY(1); }
  50% { transform: translateX(-20px) scaleY(1.1); }
}
.kefu-waves svg {
  width: 100%;
  height: 100%;
}

/* 浮动光效 */
.kefu-glow {
  display: none;
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  z-index: 0;
  animation: glowFloat 8s ease-in-out infinite;
}
.kefu-glow.glow1 {
  width: 300px;
  height: 300px;
  background: #7c4dff;
  top: 10%;
  left: 10%;
}
.kefu-glow.glow2 {
  width: 250px;
  height: 250px;
  background: #e91e63;
  bottom: 20%;
  right: 15%;
  animation-delay: -4s;
}
@keyframes glowFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -20px) scale(1.1); }
}

/* 第三个浮动光效 */
.kefu-glow.glow3 {
  width: 200px;
  height: 200px;
  background: #00bcd4;
  top: 50%;
  left: 50%;
  animation-delay: -2s;
  animation-duration: 10s;
}

/* 第四个浮动光效 */
.kefu-glow.glow4 {
  width: 180px;
  height: 180px;
  background: #ff9800;
  top: 30%;
  right: 20%;
  animation-delay: -6s;
  animation-duration: 12s;
}

/* 光晕脉冲效果 */
.kefu-glow {
  display: none;
  animation: glowFloat 8s ease-in-out infinite, glowPulse 4s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.5; }
}

/* ========== 顶部栏 ========== */
.kefu-topbar {
  position: relative;
  z-index: 10;
  height: 60px;
  background: rgba(26, 35, 126, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* 进入界面顶部栏 */
.kefu-topbar.welcome {
  justify-content: center;
  position: relative;
  height: 100px;
}
.kefu-topbar.welcome .topbar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.kefu-topbar.welcome .topbar-title {
  color: #ff6b35;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
}
.kefu-topbar.welcome .topbar-avatars {
  display: flex;
  gap: -8px;
}
.kefu-topbar.welcome .topbar-avatars .avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(26, 35, 126, 0.95);
  overflow: hidden;
  margin-left: -8px;
  background: linear-gradient(135deg, #7c4dff, #e91e63);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.kefu-topbar.welcome .topbar-avatars .avatar-circle:first-child {
  margin-left: 0;
}
.kefu-topbar.welcome .topbar-avatars .avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kefu-topbar.welcome .topbar-power {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.kefu-topbar.welcome .topbar-power:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 聊天界面顶部栏 */
.kefu-topbar.chat {
  justify-content: space-between;
}
.kefu-topbar.chat .topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.kefu-topbar.chat .topbar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
}
.kefu-topbar.chat .topbar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kefu-topbar.chat .topbar-avatar .online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4caf50;
  border: 2px solid #fff;
}
.kefu-topbar.chat .topbar-name {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.kefu-topbar.chat .topbar-status {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  margin-top: 2px;
}

/* 滚动公告 */
.kefu-topbar-chat-notice {
  flex: 1;
  margin-left: 16px;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
  mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}
.kefu-topbar-chat-notice .notice-icon {
  color: #ffd700;
  font-size: 16px;
  margin-right: 8px;
  flex-shrink: 0;
  z-index: 2;
  animation: hornPulse 1.5s ease-in-out infinite;
}
@keyframes hornPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.kefu-topbar-chat-notice .notice-text {
  display: inline-block;
  white-space: nowrap;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  animation: noticeScroll 45s linear infinite;
  padding-left: 100%;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
@keyframes noticeScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}
.kefu-topbar.chat .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kefu-topbar.chat .topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.kefu-topbar.chat .topbar-icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ========== 公告栏 ========== */
.kefu-notice-bar {
  position: relative;
  z-index: 9;
  background: rgba(255, 248, 225, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 193, 7, 0.3);
  padding: 10px 20px;
  max-height: 220px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: #5d4037;
  transition: all 0.3s ease;
}
.kefu-notice-bar .notice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.kefu-notice-bar .notice-title {
  font-weight: 600;
  color: #e65100;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kefu-notice-bar .notice-close {
  background: rgba(230, 81, 0, 0.1);
  border: none;
  color: #e65100;
  font-size: 16px;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
/* 公告层次：主公告 + 普通公告 */
.kefu-notice-bar .notice-list p { margin: 0; padding: 3px 2px; }
.kefu-notice-bar .notice-list .notice-main {
  font-size: 15px; font-weight: 700; color: #b34700; line-height: 1.6;
  padding: 8px 12px; margin-bottom: 8px; border-radius: 8px;
  background: linear-gradient(90deg, rgba(255, 152, 0, 0.16), rgba(255, 87, 34, 0.07));
  border-left: 3px solid #ff8f00;
}
.kefu-notice-bar .notice-list .notice-main b { color: #d84315; }
.kefu-notice-bar .notice-list p.notice-item, .kefu-notice-bar .notice-list p:not(.notice-main) {
  font-size: 13px; color: #5d4037; padding: 3px 4px; border-radius: 6px;
}
.kefu-notice-bar .notice-list p b { color: #e65100; font-weight: 600; }
.kefu-notice-bar .notice-list p.notice-item {
  background: rgba(255, 255, 255, 0.55);
  margin-bottom: 3px;
}

.kefu-notice-bar .notice-close:hover {
  background: rgba(230, 81, 0, 0.2);
}
.kefu-notice-bar p { margin: 3px 0; }
.kefu-notice-bar .c-red { color: #c62828; font-weight: 600; }
.kefu-notice-bar .c-green { color: #2e7d32; font-weight: 600; }
.kefu-notice-bar .c-blue { color: #1565c0; }
.kefu-notice-bar .c-gold { color: #e65100; font-weight: 600; }
.kefu-notice-bar.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  border-bottom: none;
}

/* ========== 进入界面（欢迎页） ========== */
.kefu-welcome-page {
  position: relative;
  z-index: 5;
  flex: 1;
  height: auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInUp 0.5s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.kefu-welcome-card {
  position: relative;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(26, 35, 126, 0.22), 0 2px 8px rgba(26, 35, 126, 0.06);
  width: 90%;
  max-width: 520px;
  padding: 34px 30px 26px;
  text-align: center;
  animation: cardIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.9);
  max-height: 85vh;
  overflow-y: auto;
}
.kefu-welcome-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(90deg, #1a237e 0%, #3949ab 45%, #5c6bc0 70%, #ff6b35 100%);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.kefu-welcome-card .welcome-logo {
  display: none;
}

.kefu-welcome-card .welcome-title {
  display: none;
}

.kefu-welcome-card .welcome-subtitle {
  display: none;
}

.kefu-welcome-card .welcome-brand {
  position: relative;
  margin-bottom: 18px;
  padding-bottom: 14px;
}
.kefu-welcome-card .welcome-brand::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 64px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, #1a237e, #5c6bc0, #ff6b35);
}
.kefu-welcome-card .welcome-brand-title {
  font-size: 22px;
  color: #1a237e;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.5;
}
.kefu-welcome-card .welcome-brand-sub {
  font-size: 13px;
  color: #8a8f9e;
  letter-spacing: 0.5px;
  margin-top: 6px;
}
.kefu-welcome-card .welcome-content {
  display: block;
}
/* 欢迎文字排版层次：加粗强调 + 小标题 + 脚注 */
.kefu-welcome-card .welcome-content p { line-height: 1.7; }
.kefu-welcome-card .welcome-content b { color: #e65100; font-weight: 700; font-size: 1.12em; }
.kefu-welcome-card .welcome-content .welcome-icon-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(90deg, rgba(26, 35, 126, 0.05), rgba(92, 107, 192, 0.09));
  border: 1px solid rgba(26, 35, 126, 0.09);
  border-radius: 12px; padding: 9px 10px; margin: 7px 2px !important;
  font-size: 14.5px; color: #333;
}
.kefu-welcome-card .welcome-content .welcome-section-title {
  font-size: 15px; color: #1a237e; font-weight: 700; letter-spacing: 2px;
  margin: 16px 0 2px !important;
}
.kefu-welcome-card .welcome-content .welcome-section-title b { color: #1a237e !important; }
.kefu-welcome-card .welcome-content .welcome-plain {
  font-size: 14px; color: #444;
}
.kefu-welcome-card .welcome-content .welcome-icon-row b,
.kefu-welcome-card .welcome-content .welcome-line3 b,
.kefu-welcome-card .welcome-content .welcome-plain b,
.kefu-welcome-card .welcome-content .welcome-line1 b {
  color: #ff6b35; font-size: 1.08em;
}
.kefu-welcome-card .welcome-content .welcome-foot {
  color: #a0a4b0; font-size: 12px; margin-top: 12px !important; line-height: 1.6;
}
.kefu-welcome-card .welcome-content p { margin: 7px 0; }
.kefu-welcome-card .welcome-content .welcome-line1 {
  font-size: 15px;
  color: #1a237e;
  font-weight: 600;
}
.kefu-welcome-card .welcome-content .welcome-line2 {
  font-size: 17px;
  color: #ff6b35;
  font-weight: 700;
}
.kefu-welcome-card .welcome-content .welcome-line3 {
  font-size: 14px;
  color: #333;
  font-weight: 500;
  line-height: 1.6;
}
.kefu-welcome-card .welcome-content .welcome-line4 {
  font-size: 14px;
  color: #1a237e;
  font-weight: 700;
}
.kefu-welcome-card .welcome-content .welcome-line5 {
  font-size: 20px;
  color: #d32f2f;
  font-weight: 700;
  margin: 12px 0;
}
.kefu-welcome-card .welcome-content .welcome-line6 {
  font-size: 14px;
  color: #333;
  font-weight: 500;
}
.kefu-welcome-card .welcome-content .welcome-line7 {
  font-size: 12px;
  color: #999;
  font-weight: 400;
  margin-top: 8px;
}
.kefu-welcome-card .welcome-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(26,35,126,0.15), transparent);
  margin: 12px 0;
}

.kefu-start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 80%;
  max-width: 300px;
  height: 48px;
  margin: 18px auto 4px;
  background: linear-gradient(135deg, #1a237e, #3949ab);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 2px;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 6px 20px rgba(26, 35, 126, 0.35);
}
.kefu-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(26, 35, 126, 0.45);
}
.kefu-start-btn:active {
  transform: translateY(0) scale(0.98);
}

/* ========== 聊天界面 ========== */
.kefu-chat-page {
  position: relative;
  z-index: 5;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 聊天消息区 */
.kefu-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 50%, #f0f4f8 100%);
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(102, 126, 234, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(118, 75, 162, 0.05) 0%, transparent 50%),
    linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 50%, #f0f4f8 100%);
  position: relative;
}

/* 聊天消息区背景装饰 */
.kefu-chat-messages::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30%;
  background: linear-gradient(180deg, transparent 0%, rgba(102, 126, 234, 0.03) 100%);
  pointer-events: none;
  z-index: 0;
}
.kefu-chat-messages > * {
  position: relative;
  z-index: 1;
}

/* 客服欢迎长消息 */
.kefu-welcome-msg {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  font-size: 14px;
  line-height: 1.8;
  color: #424242;
  max-width: 100%;
}
.kefu-welcome-msg p { margin: 4px 0; }
.kefu-welcome-msg .highlight-orange { color: #e65100; font-weight: 600; }
.kefu-welcome-msg .highlight-red { color: #c62828; font-weight: 600; }
.kefu-welcome-msg .highlight-blue { color: #1565c0; font-weight: 600; }

/* 系统提示 */
.kefu-system-tip {
  text-align: center;
  color: #9e9e9e;
  font-size: 12px;
  margin: 12px 0;
}

/* 消息 - 微信式布局 */
/* 消息 - 微信式布局：客户靠右，客服靠左 */
.kefu-msg {
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 用户消息 - 靠右（浅紫气泡，无头像） */
.kefu-msg.user {
  justify-content: flex-end;
}
.kefu-msg.user .msg-avatar {
  display: none;
}
.kefu-msg.user .msg-content {
  align-items: flex-end;
}
.kefu-msg.user .bubble {
  background: #e8eaf6;
  color: #212121;
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 12px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}
.kefu-msg.user .msg-time {
  text-align: right;
  order: -1;
  margin-bottom: 4px;
  margin-top: 0;
}
.kefu-msg.user .msg-sender {
  display: none;
}

/* 客服消息 - 靠左（白色气泡，头像+名称在气泡上方） */
.kefu-msg.agent, .kefu-msg.bot {
  justify-content: flex-start;
}
.kefu-msg.agent .msg-avatar, .kefu-msg.bot .msg-avatar {
  margin-right: 10px;
  margin-left: 0;
  margin-top: 18px;
}
.kefu-msg.agent .msg-content, .kefu-msg.bot .msg-content {
  align-items: flex-start;
}
.kefu-msg.agent .bubble, .kefu-msg.bot .bubble {
  background: #fff;
  color: #212121;
  border: 1px solid #f0f0f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 12px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}
.kefu-msg.agent .msg-time, .kefu-msg.bot .msg-time {
  text-align: left;
  display: inline;
  margin-left: 6px;
  margin-top: 0;
}
.kefu-msg.agent .msg-sender, .kefu-msg.bot .msg-sender {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #616161;
  margin-bottom: 4px;
  font-weight: 500;
}

/* 连续消息合并头像（客服消息） */
.kefu-msg.agent.continuous .msg-avatar,
.kefu-msg.bot.continuous .msg-avatar {
  visibility: hidden;
}
.kefu-msg.agent.continuous .msg-sender,
.kefu-msg.bot.continuous .msg-sender {
  visibility: hidden;
  height: 0;
  margin-bottom: 0;
  overflow: hidden;
}
.kefu-msg.agent.continuous,
.kefu-msg.bot.continuous {
  margin-bottom: 6px;
}

/* 连续消息合并（用户消息） */
.kefu-msg.user.continuous {
  margin-bottom: 6px;
}
.kefu-msg.user.continuous .msg-time {
  display: none;
}

/* 消息头像 */
.kefu-msg .msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-start;
  background: #e0e0e0;
}
.kefu-msg .msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 消息内容 */
.kefu-msg .msg-content {
  display: flex;
  flex-direction: column;
  max-width: 68%;
  min-width: 0;
}
.kefu-msg .msg-sender {
  font-size: 12px;
  color: #757575;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kefu-msg .bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}
.kefu-msg .bubble a {
  color: #1a237e;
  text-decoration: underline;
}
.kefu-msg .msg-time {
  font-size: 11px;
  color: #9e9e9e;
  margin-top: 4px;
}

/* 系统消息 */
.kefu-msg.system {
  justify-content: center;
}
.kefu-msg.system .bubble {
  background: transparent;
  color: #9e9e9e;
  font-size: 12px;
  padding: 4px 12px;
  box-shadow: none;
  border: none;
}

/* 转接等待动画 */
.kefu-waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  border-radius: 12px;
  font-size: 13px;
  color: #e65100;
  margin: 12px 0;
  justify-content: center;
}
.kefu-waiting .breath-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e65100;
  animation: breath 1.5s ease-in-out infinite;
}
@keyframes breath {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ========== 底部输入栏 ========== */
.kefu-input-bar {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-top: 1px solid #f0f0f0;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.kefu-input-bar .input-wrapper {
  flex: 1;
  position: relative;
}
.kefu-input-bar textarea {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  transition: all 0.2s;
  background: #fafafa;
}
.kefu-input-bar textarea:focus {
  border-color: #3949ab;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.1);
}

.kefu-input-bar .input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kefu-input-bar .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f5f5f5;
  color: #616161;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}
.kefu-input-bar .icon-btn:hover {
  background: #e8eaf6;
  color: #3949ab;
}
.kefu-input-bar .icon-btn input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.kefu-input-bar .send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1a237e, #3949ab);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(26, 35, 126, 0.3);
}
.kefu-input-bar .send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(26, 35, 126, 0.4);
}
.kefu-input-bar .send-btn:active {
  transform: scale(0.95);
}
.kefu-input-bar .send-btn:disabled {
  background: #bdbdbd;
  cursor: not-allowed;
  box-shadow: none;
}

/* 表情面板 */
.kefu-emoji-panel {
  position: absolute;
  bottom: 60px;
  right: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 12px;
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  width: 280px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 9999;
  animation: panelIn 0.2s ease;
}
.kefu-emoji-panel.open { display: flex; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.kefu-emoji-panel .emoji-item {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.kefu-emoji-panel .emoji-item:hover {
  background: #f5f5f5;
  transform: scale(1.2);
}

/* ========== 评价弹窗 ========== */
.kefu-rating-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.25s ease;
}
.kefu-rating-mask.open { display: flex; }
.kefu-rating-dialog {
  background: #fff;
  border-radius: 12px;
  width: 340px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  animation: dialogIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.kefu-rating-dialog h4 {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 600;
  color: #212121;
}
.kefu-rating-stars {
  font-size: 36px;
  color: #e0e0e0;
  cursor: pointer;
  letter-spacing: 8px;
  margin-bottom: 20px;
  user-select: none;
}
.kefu-rating-stars .on {
  background: linear-gradient(135deg, #ffd700, #ff9800);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kefu-rating-dialog textarea {
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  height: 80px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  margin-bottom: 20px;
  transition: all 0.2s;
}
.kefu-rating-dialog textarea:focus {
  border-color: #3949ab;
  box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.1);
}
.kefu-rating-dialog .btns {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.kefu-rating-dialog .btns button {
  padding: 10px 28px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}
.kefu-rating-dialog .btns .primary {
  background: linear-gradient(135deg, #1a237e, #3949ab);
  color: #fff;
}
.kefu-rating-dialog .btns .primary:hover {
  box-shadow: 0 4px 12px rgba(26, 35, 126, 0.4);
}
.kefu-rating-dialog .btns .plain {
  background: #f5f5f5;
  color: #616161;
}
.kefu-rating-dialog .btns .plain:hover {
  background: #eeeeee;
}

/* 图片消息 */
.kefu-msg .bubble img {
  max-width: 200px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
}

/* 文件消息 */
.kefu-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  min-width: 180px;
}
.kefu-file .file-icon { font-size: 28px; }
.kefu-file .file-info { flex: 1; min-width: 0; }
.kefu-file .file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kefu-file .file-size { font-size: 11px; opacity: 0.7; }

/* 滚动条美化 */
.kefu-chat-messages::-webkit-scrollbar,
.kefu-notice-bar::-webkit-scrollbar,
.kefu-input-bar textarea::-webkit-scrollbar {
  width: 6px;
}
.kefu-chat-messages::-webkit-scrollbar-track,
.kefu-notice-bar::-webkit-scrollbar-track {
  background: transparent;
}
.kefu-chat-messages::-webkit-scrollbar-thumb,
.kefu-notice-bar::-webkit-scrollbar-thumb {
  background: #bdbdbd;
  border-radius: 3px;
}
.kefu-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9e9e9e;
}

/* 移动端适配 */
@media (max-width: 768px) {
  body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  .kefu-fullscreen {
    width: 100%;
    height: 100%;
    max-width: 100%;
    min-width: 100%;
    border-radius: 0;
  }
  .kefu-welcome-card {
    width: 90%;
    padding: 24px;
  }
  .kefu-welcome-card .welcome-title { font-size: 18px; }
  .kefu-welcome-card .welcome-content { font-size: 13px; padding: 12px; }
  .kefu-start-btn { width: 100%; height: 44px; font-size: 14px; }
  .kefu-topbar { height: 52px; padding: 0 16px; }
  .kefu-topbar.chat .topbar-avatar { width: 36px; height: 36px; }
  .kefu-topbar.chat .topbar-name { font-size: 14px; }
  /* 手机版显示滚动公告 */
  .kefu-topbar-chat-notice {
    display: flex;
    flex: 1;
    margin-left: 8px;
    height: 20px;
    mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
  }
  .kefu-topbar-chat-notice .notice-icon {
    font-size: 14px;
    margin-right: 6px;
  }
  .kefu-topbar-chat-notice .notice-text {
    font-size: 12px;
    font-weight: 600;
    animation: noticeScrollMobile 35s linear infinite;
  }
  @keyframes noticeScrollMobile {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
  }
  .kefu-chat-messages { padding: 12px; }
  .kefu-msg .msg-content { max-width: 75%; }
  .kefu-input-bar { padding: 10px 12px; gap: 8px; }
  .kefu-input-bar .icon-btn { width: 36px; height: 36px; font-size: 16px; }
  .kefu-input-bar .send-btn { width: 40px; height: 40px; font-size: 16px; }
  .kefu-notice-bar { padding: 8px 14px; font-size: 12px; max-height: 220px; }
}


/* ========== 新开始界面样式 - 部门按钮列表 ========== */
.kefu-welcome-card .welcome-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.kefu-welcome-card .welcome-avatars {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: -10px;
}

.kefu-welcome-card .welcome-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #fff;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.kefu-welcome-card .welcome-avatar:nth-child(2) {
  margin-left: -12px;
  z-index: 2;
}

.kefu-welcome-card .welcome-avatar:nth-child(3) {
  margin-left: -12px;
  z-index: 3;
}

.kefu-welcome-card .welcome-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 4px;
}

.kefu-welcome-card .dept-btn {
  width: 100%;
  min-height: 56px;
  background: linear-gradient(180deg, #ffeb3b 0%, #ffc107 50%, #ff9800 100%);
  color: #b71c1c;
  border: 2px solid #ff8f00;
  border-radius: 28px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
  letter-spacing: 2px;
  padding: 12px 20px;
  line-height: 1.3;
}

.kefu-welcome-card .dept-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 24px rgba(255, 152, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, #ffee58 0%, #ffca28 50%, #ffa726 100%);
}

.kefu-welcome-card .dept-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 移动端适配 */
@media (max-width: 480px) {
  .kefu-welcome-card {
    width: 95%;
    padding: 16px 12px;
  }
  
  .kefu-welcome-card .dept-btn {
    font-size: 17px;
    min-height: 50px;
    padding: 10px 16px;
  }
  
  .kefu-welcome-card .welcome-avatar {
    width: 42px;
    height: 42px;
  }
}



/* ========== 消息已读状态 ========== */
.kefu-msg.user .msg-read {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  text-align: right;
  padding-right: 4px;
}
.kefu-msg.user .msg-read.read {
  color: #4caf50;
}

/* ========== 对方正在输入指示器 ========== */
.kefu-typing-indicator {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  margin: 4px 0;
}
.kefu-typing-indicator .typing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.kefu-typing-indicator .typing-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kefu-typing-indicator .typing-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kefu-typing-indicator .typing-name {
  font-size: 12px;
  color: #666;
}
.kefu-typing-indicator .typing-bubble {
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.kefu-typing-indicator .typing-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.kefu-typing-indicator .typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.kefu-typing-indicator .typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}
@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 手机版正在输入样式 */
@media (max-width: 768px) {
  .kefu-typing-indicator {
    padding: 6px 8px;
  }
  .kefu-typing-indicator .typing-avatar {
    width: 28px;
    height: 28px;
  }
  .kefu-typing-indicator .typing-bubble {
    padding: 8px 12px;
  }
}
