/* ---------- 右下角功能圆（左侧竖向子菜单） ---------- */
.fab {
  /* 位置变量：嵌入带底部导航的环境（如 newapi）时上调 --fab-bottom 即可避让 */
  --fab-right: 26px;
  --fab-bottom: 170px;
  position: fixed;
  right: var(--fab-right);
  bottom: var(--fab-bottom);
  z-index: 9989;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* 主圆钮 */
.fab-main {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
  transition: transform 0.25s, box-shadow 0.25s;
}
/* 主圆钮购物车数量徽标 */
.fab-main-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
  display: none;
}
.fab-main-count.show { display: block; }
/* 主圆钮弹跳反馈 */
@keyframes fab-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.25); }
  70% { transform: scale(0.94); }
  100% { transform: scale(1); }
}
.fab-main.pop { animation: fab-pop 0.45s ease; }
.fab-main svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s;
}
.fab:hover .fab-main,
.fab.open .fab-main {
  transform: scale(1.06);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.55);
}
.fab:hover .fab-main svg,
.fab.open .fab-main svg {
  transform: scale(1.12);
}

/* 子按钮（初始收在主圆中心） */
.fab-item {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
  opacity: 0;
  transform: translate(0, 0) scale(0);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fab-item svg {
  width: 20px;
  height: 20px;
}
/* 文字提示气泡 */
.fab-item .fab-tip {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.fab-item:hover .fab-tip {
  opacity: 1;
}
/* 在线咨询未读红点 */
.fab-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.5);
  display: none;
}
.fab-chat-badge.show {
  display: block;
}

/* 展开左侧竖向子菜单（hover 桌面 / open 移动端点击） */
.fab:hover .fab-item,
.fab.open .fab-item {
  opacity: 1;
  pointer-events: auto;
}
/* 子按钮在圆饼左侧竖直排列（从下往上：咨询 → 购物车 → 语言 → 个人中心），
   相邻间距统一 12px：按钮间中心距 54px，主圆-按钮中心距 61px（28+21+12），
   向上展开不会超出屏幕底部 */
.fab:hover .fab-chat,
.fab.open .fab-chat {
  transform: translate(-61px, 0) scale(1);
  transition-delay: 0.02s;
}
.fab:hover .fab-cart-btn,
.fab.open .fab-cart-btn {
  transform: translate(-61px, -54px) scale(1);
  transition-delay: 0.06s;
}
.fab:hover .fab-lang-btn,
.fab.open .fab-lang-btn {
  transform: translate(-61px, -108px) scale(1);
  transition-delay: 0.10s;
}
.fab:hover .fab-user,
.fab.open .fab-user {
  transform: translate(-61px, -162px) scale(1);
  transition-delay: 0.14s;
}
/* 子按钮配色：购物车橙红 / 个人中心绿色 */
.fab-cart-btn {
  background: linear-gradient(135deg, #f59e0b, #ef4444) !important;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.38) !important;
}
.fab-user {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.38) !important;
}
/* 购物车按钮数量徽标 */
.fab-cart-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #fff;
  color: #ef4444;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  border: 2px solid #ef4444;
  box-shadow: 0 1px 4px rgba(239, 68, 68, 0.4);
  display: none;
}
.fab-cart-badge.show { display: block; }

/* ---------- 购物车面板 ---------- */
.fab-cart {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 284px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.2s, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.2s;
  overflow: hidden;
  z-index: 9990;
}
.fab-cart.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.fab-cart-head {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
}
.fab-cart-list { max-height: 264px; overflow-y: auto; padding: 6px 10px; }
.fab-cart-list::-webkit-scrollbar { width: 5px; }
.fab-cart-list::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }
.fab-cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 13px;
  color: #334155;
}
.fab-cart-item + .fab-cart-item { border-top: 1px dashed #f1f5f9; }
.fab-cart-item:hover { background: #f8fafc; }
.fab-cart-item .n {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab-cart-item .nm {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fab-cart-rm {
  border: none;
  background: none;
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.fab-cart-rm:hover { color: #ef4444; background: #fef2f2; }
.fab-cart-empty { padding: 24px 14px; text-align: center; color: #94a3b8; font-size: 12.5px; line-height: 1.6; }
.fab-cart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}
.fab-cart-clear {
  border: none;
  background: none;
  color: #94a3b8;
  font-size: 12.5px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}
.fab-cart-clear:hover { color: #ef4444; background: #fef2f2; }
.fab-cart-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 5px 14px rgba(99, 102, 241, 0.35);
  transition: filter 0.15s, transform 0.15s;
}
.fab-cart-submit:hover { filter: brightness(1.08); transform: translateY(-1px); color: #fff; }
.fab-cart-submit.disabled { opacity: 0.45; pointer-events: none; }

/* 语言子菜单气泡 */
.fab-lang {
  position: absolute;
  right: 150px;
  bottom: 64px;
  width: 156px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.fab-lang.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.fab-lang-title {
  font-size: 12px;
  color: #94a3b8;
  padding: 4px 10px 6px;
}
.fab-lang a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: #1e293b;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.fab-lang a:hover {
  background: #f1f5f9;
  color: #6366f1;
}
.fab-lang a.active {
  color: #6366f1;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.08);
}

/* 移动端适配 */
@media (max-width: 768px) {
  .fab {
    --fab-right: 16px;
    --fab-bottom: 150px;
  }
  .fab-main {
    width: 50px;
    height: 50px;
  }
  .fab-item {
    width: 40px;
    height: 40px;
    right: 5px;
    bottom: 5px;
  }
  .fab:hover .fab-chat,
  .fab.open .fab-chat {
    transform: translate(-55px, 0) scale(1);
  }
  .fab:hover .fab-cart-btn,
  .fab.open .fab-cart-btn {
    transform: translate(-55px, -50px) scale(1);
  }
  .fab:hover .fab-lang-btn,
  .fab.open .fab-lang-btn {
    transform: translate(-55px, -100px) scale(1);
  }
  .fab:hover .fab-user,
  .fab.open .fab-user {
    transform: translate(-55px, -150px) scale(1);
  }
  .fab-lang {
    right: 120px;
    bottom: 52px;
  }
  .fab-cart {
    width: 262px;
    bottom: 68px;
  }
}
