/**
 * 右侧浮动客服图标区样式
 * 兼容Bootstrap 3.4.1，但不强制依赖
 * 支持IE9+，现代浏览器完美支持
 */

/* ============================================
   基础容器 - 右侧居中定位
   ============================================ */
.kf-float-bar {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center; /* 确保所有子元素（.kf-group）水平居中 */
  gap: 5px; /* 进一步减小组之间的间距：从8px改为5px，使整体高度约占总高度的62% */
  font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  /* 确保不影响页面其他元素 */
  pointer-events: none;
}

.kf-float-bar > * {
  pointer-events: auto;
}

/* ============================================
   分组容器
   ============================================ */
.kf-group {
  display: flex;
  flex-direction: column;
  align-items: center; /* 确保组内所有内容水平居中 */
  gap: 4px; /* 进一步减小组内图标之间的间距：从6px改为4px */
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 6px 5px; /* 进一步减小组的内边距：从8px 6px改为6px 5px */
  min-width: 56px;
  width: auto; /* 确保宽度自适应内容 */
  transition: box-shadow 0.3s ease;
  margin: 0 auto; /* 额外的水平居中保障 */
}

.kf-group:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.kf-group-title {
  font-size: 11px;
  color: #999;
  text-align: center;
  padding: 1px 0; /* 进一步减小标题的上下内边距：从2px改为1px */
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 1px; /* 进一步减小标题的下边距：从2px改为1px */
  margin-top: 0; /* 明确设置上边距为0 */
  font-weight: normal;
  line-height: 1.1; /* 进一步减小行高：从1.2改为1.1，使文字更紧凑 */
}

/* ============================================
   单个图标项
   ============================================ */
.kf-item {
  position: relative;
  width: 48px; /* 略微减小图标尺寸：从50px改为48px */
  height: 48px; /* 略微减小图标尺寸：从50px改为48px */
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e8e8e8;
  overflow: visible; /* 改为 visible，确保悬停面板不被裁剪 */
  /* 确保内容完全居中 */
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.kf-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(18, 183, 245, 0.05) 0%, rgba(15, 160, 214, 0.05) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.kf-item:hover::before {
  opacity: 1;
}

.kf-item:hover,
.kf-item:focus {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 8px 24px rgba(18, 183, 245, 0.25), 0 2px 8px rgba(0, 0, 0, 0.1);
  border-color: #12b7f5;
  outline: none;
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
}

.kf-item:active {
  transform: translateY(0) scale(0.98);
}

/* 图标容器 */
.kf-icon-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1; /* 确保图标在面板之上，但不遮挡悬停检测 */
  pointer-events: none; /* 允许点击穿透到父元素 */
  /* 确保水平和垂直都完全居中 */
  margin: 0;
  padding: 0;
}

/* 图标样式 */
.kf-icon {
  display: block; /* 改为 block，确保更好的居中控制 */
  width: 26px; /* 略微减小图标尺寸：从28px改为26px */
  height: 26px; /* 略微减小图标尺寸：从28px改为26px */
  background-size: contain;
  background-position: center center; /* 明确指定水平和垂直居中 */
  background-repeat: no-repeat;
  margin: 0; /* 移除所有外边距，由 flex 容器控制居中 */
  padding: 0; /* 移除所有内边距 */
  flex-shrink: 0; /* 防止图标被压缩 */
  flex-grow: 0; /* 防止图标被拉伸 */
  /* 确保图标内容完全居中 */
  text-align: center;
  line-height: 26px; /* 与高度一致，确保垂直居中 */
}

/* QQ图标 */
.kf-icon-qq {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%2312b7f5" d="M12 2C6.48 2 2 6.48 2 12c0 1.54.36 2.98.97 4.29L1 23l6.71-1.97c1.31.61 2.75.97 4.29.97 5.52 0 10-4.48 10-10S17.52 2 12 2zm-1.5 14.5h-1v-6h1v6zm2.5 0h-1v-6h1v6zm2.5 0h-1v-6h1v6z"/></svg>');
}

/* 微信图标 - 使用SVG图标（如果需要在/UploadFiles/weixin-pic/放置wechat-icon.png，可替换此行） */
.kf-icon-wechat {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%2309bb07" d="M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.597-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18 0 .653-.52 1.18-1.162 1.18-.642 0-1.162-.527-1.162-1.18 0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18 0 .653-.52 1.18-1.162 1.18-.642 0-1.162-.527-1.162-1.18 0-.651.52-1.18 1.162-1.18zm5.34 3.48c-2.604 0-4.714 2.11-4.714 4.713 0 2.602 2.11 4.712 4.714 4.712.578 0 1.127-.106 1.637-.296a.722.722 0 0 1 .598.084l1.531.896a.26.26 0 0 0 .135.043c.13 0 .235-.105.235-.234a.443.443 0 0 0-.033-.17l-.312-1.178a.472.472 0 0 1 .17-.558 7.112 7.112 0 0 0 2.15-5.113c0-2.603-2.11-4.713-4.714-4.713zm-2.407 3.48c.52 0 .94.421.94.94 0 .52-.42.94-.94.94-.519 0-.94-.42-.94-.94 0-.519.421-.94.94-.94zm2.407 0c.52 0 .94.421.94.94 0 .52-.42.94-.94.94-.519 0-.94-.42-.94-.94 0-.519.421-.94.94-.94z"/></svg>');
  /* 如需使用外部图标文件，取消注释下面一行，并注释上面一行 */
  /* background-image: url('/UploadFiles/weixin-pic/wechat-icon.png'); */
}

/* 到顶图标 */
.kf-icon-top {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%23666" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"/></svg>');
}

/* 到底图标 */
.kf-icon-bottom {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%23666" d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z"/></svg>');
}

/* 电话图标 */
.kf-icon-phone {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%230fa0d6" d="M6.62 10.79a15.053 15.053 0 0 0 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V21c0 .55-.45 1-1 1C10.4 22 2 13.6 2 3c0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"/></svg>');
}

/* ============================================
   悬浮面板（悬停/点击时显示）
   ============================================ */
.kf-panel {
  position: absolute;
  right: 62px;
  top: 50%;
  transform: translateY(-50%) scale(0.95);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0;
  min-width: 190px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 10001; /* 提高 z-index，确保面板显示在最上层 */
  border: 1px solid rgba(0, 0, 0, 0.05);
  white-space: nowrap; /* 防止内容换行 */
}

/* 在图标和面板之间添加连接区域，防止鼠标移动时面板消失 */
.kf-item::after {
  content: '';
  position: absolute;
  right: -60px;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 200%;
  background: transparent;
  pointer-events: auto;
  z-index: 10000;
  opacity: 0;
}

/* 当面板激活时，连接区域也激活 */
.kf-item.active::after {
  opacity: 1;
}

.kf-item:hover .kf-panel,
.kf-item:focus .kf-panel,
.kf-item.active .kf-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto !important;
  transform: translateY(-50%) translateX(-10px) scale(1);
  transition: opacity 0.1s ease, visibility 0.1s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 当鼠标在面板上时，保持面板显示 */
.kf-panel:hover {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(-50%) translateX(-10px) scale(1) !important;
}

/* 面板显示时立即启用pointer-events，确保可以接收鼠标事件 */
.kf-item.active .kf-panel {
  pointer-events: auto !important;
}

/* 面板箭头 */
.kf-panel::before {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid #fff;
}

.kf-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  text-align: center;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 12px 12px 0 0;
}

.kf-panel-body {
  padding: 16px;
  text-align: center;
}

/* 面板提示文字 */
.kf-panel-tip {
  font-size: 11px;
  color: #999;
  margin-top: 8px;
  margin-bottom: 4px;
  line-height: 1.4;
}

/* ============================================
   微信二维码面板 - 悬停放大效果
   ============================================ */
.kf-panel-wechat .kf-qr-img {
  width: 170px;
  height: 170px;
  display: block;
  margin: 0 auto;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid #f0f0f0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.kf-item.kf-wechat:hover .kf-qr-img {
  transform: scale(1.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
  border-color: #12b7f5;
}

/* ============================================
   QQ面板样式
   ============================================ */
.kf-qq-number {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
}

.kf-qq-value {
  font-size: 16px;
  font-weight: 600;
  color: #12b7f5;
  font-family: "Courier New", monospace;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: inline-block;
}

.kf-qq-value:hover {
  background: rgba(18, 183, 245, 0.1);
  color: #0fa0d6;
  transform: scale(1.05);
}

/* QQ操作按钮组 */
.kf-qq-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.kf-btn-qq-copy {
  background: linear-gradient(135deg, #12b7f5 0%, #0fa0d6 100%) !important;
  box-shadow: 0 2px 8px rgba(18, 183, 245, 0.3) !important;
  border: none;
  cursor: pointer;
}

.kf-btn-qq-copy:hover {
  background: linear-gradient(135deg, #0fa0d6 0%, #0d8fc4 100%) !important;
  box-shadow: 0 4px 12px rgba(18, 183, 245, 0.4) !important;
  transform: translateY(-1px);
}

.kf-btn-qq-add {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%) !important;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3) !important;
}

.kf-btn-qq-add:hover {
  background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%) !important;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4) !important;
}

.kf-btn-qq-try {
  background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%) !important;
  box-shadow: 0 2px 8px rgba(158, 158, 158, 0.3) !important;
  font-size: 12px;
  padding: 8px 16px;
}

.kf-btn-qq-try:hover {
  background: linear-gradient(135deg, #757575 0%, #616161 100%) !important;
  box-shadow: 0 4px 12px rgba(158, 158, 158, 0.4) !important;
}

.kf-btn {
  display: inline-block;
  padding: 10px 20px;
  background: linear-gradient(135deg, #12b7f5 0%, #0fa0d6 100%);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(18, 183, 245, 0.3);
  position: relative;
  overflow: hidden;
}

.kf-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.kf-btn:hover::before {
  width: 300px;
  height: 300px;
}

.kf-btn:hover,
.kf-btn:focus {
  background: linear-gradient(135deg, #0fa0d6 0%, #0d8fc0 100%);
  color: #fff;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(18, 183, 245, 0.4);
}

.kf-btn:active {
  transform: translateY(0);
}

/* ============================================
   电话面板样式
   ============================================ */
.kf-phone-number {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
}

.kf-phone-value {
  font-size: 16px;
  font-weight: 600;
  color: #0fa0d6;
  font-family: "Courier New", monospace;
}

/* ============================================
   滚动按钮组特殊样式
   ============================================ */
.kf-group-scroll {
  padding: 3px; /* 减小滚动按钮组的内边距：从4px改为3px */
}

.kf-scroll-top,
.kf-scroll-bottom {
  background: #f8f8f8;
  border-color: #ddd;
}

.kf-scroll-top:hover,
.kf-scroll-bottom:hover {
  background: #12b7f5;
  border-color: #12b7f5;
}

.kf-scroll-top:hover .kf-icon-top,
.kf-scroll-bottom:hover .kf-icon-bottom {
  filter: brightness(0) invert(1);
}

/* ============================================
   响应式设计 - 移动端适配
   ============================================ */
@media (max-width: 768px) {
  .kf-float-bar {
    right: 10px;
    gap: 4px; /* 移动端进一步减小组之间的间距：从6px改为4px */
  }

  .kf-group {
    padding: 4px 3px; /* 移动端进一步减小组的内边距：从5px 4px改为4px 3px */
    min-width: 48px;
  }

  .kf-item {
    width: 44px;
    height: 44px;
  }

  .kf-icon {
    width: 24px;
    height: 24px;
  }

  .kf-panel {
    right: 56px;
    min-width: 160px;
  }

  .kf-panel-wechat .kf-qr-img {
    width: 140px;
    height: 140px;
  }
}

@media (max-width: 576px) {
  /* 移动端可选择性隐藏或改为底部悬浮 */
  .kf-float-bar {
    right: 8px;
    transform: translateY(-50%) scale(0.9);
  }

  .kf-group-title {
    font-size: 10px;
  }

  .kf-panel {
    right: 52px;
    min-width: 140px;
  }
}

/* ============================================
   无障碍支持 - 键盘导航
   ============================================ */
.kf-item:focus {
  outline: 2px solid #12b7f5;
  outline-offset: 2px;
}

/* ============================================
   打印时隐藏
   ============================================ */
@media print {
  .kf-float-bar {
    display: none !important;
  }
}

/* ============================================
   兼容Bootstrap 3.4.1工具类（如果已引入）
   ============================================ */
.kf-float-bar .text-center {
  text-align: center;
}

/* 如果全局已引入Bootstrap 3.4.1，可以使用以下方式增强样式 */
/* 注意：保持独立样式，避免版本冲突 */
/* .kf-float-bar .btn { } */

/* Bootstrap响应式断点兼容 */
@media (max-width: 767px) {
  /* Bootstrap 3.4.1 的 sm 断点 */
  .kf-float-bar {
    right: 10px;
  }
}

@media (max-width: 991px) {
  /* Bootstrap 3.4.1 的 md 断点 */
  /* 可在此添加中等屏幕的样式调整 */
}

/* ============================================
   加载动画（可选，提升体验）
   ============================================ */
@keyframes kfFadeIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.kf-group {
  animation: kfFadeIn 0.4s ease-out;
}

.kf-group:nth-child(1) { animation-delay: 0.1s; }
.kf-group:nth-child(2) { animation-delay: 0.2s; }
.kf-group:nth-child(3) { animation-delay: 0.3s; }
.kf-group:nth-child(4) { animation-delay: 0.4s; }
