/* Foxes UI 质感与动效层 v3：Bento 卡片层次、黑金紫通行证质感、容器自适应动效
 * 回滚：恢复 /opt/new-api/backup_ui_upgrade_20261206_2250/ 即可。 */

#fx-dashboard-root,
#fx-keys-page,
#fx-pool-page,
#fx-reseller-page,
#fx-guide-page {
  --fx-ease: cubic-bezier(.22, 1, .36, 1);
  --fx-brand: #7a48f2;
  --fx-gold: #ffa83a;
  --fx-flash: #059669;
  --fx-t: 0ms;
}

/* ---------- 雕塑感卡片层次 ---------- */
#fx-dashboard-root .fxo-card,
#fx-keys-page .k2-card {
  box-shadow: var(--fx-shadow-sm, 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px -10px rgba(15, 23, 42, .09));
  transition: border-color .2s ease, box-shadow .22s ease, transform .22s var(--fx-ease);
}
#fx-dashboard-root .fxo-kpi:hover,
#fx-dashboard-root .fxo-meta:hover {
  border-color: var(--fx-brand-line, rgba(122, 72, 242, .32));
  box-shadow: var(--fx-shadow-md, 0 14px 32px -14px rgba(15, 23, 42, .16));
  transform: translateY(-2px);
}

/* ---------- 鼠标追光（用于通行证资料卡 / 管理员命令卡） ---------- */
.fx-spotlight {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.fx-spotlight::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(460px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .13), transparent 60%);
  transition: opacity .3s ease;
}
.fx-spotlight:hover::before {
  opacity: 1;
}

/* ---------- 数字排版 ---------- */
.fxn-int { font-variant-numeric: tabular-nums; }
.fxn-cur { font-size: .58em; font-weight: 600; opacity: .65; margin-right: 2px; }
.fxn-dec { font-size: .58em; font-weight: 600; opacity: .55; }
.fxn-post { font-size: .52em; font-weight: 500; opacity: .62; margin-left: 3px; }

/* ---------- 黑曜紫金属磨砂通行证（用户资料卡 & 管理员指挥卡） ---------- */
#fx-dashboard-root .fxo-pass {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  border: 1px solid rgba(196, 181, 253, .22) !important;
  background:
    radial-gradient(95% 130% at 100% 0%, rgba(255, 168, 58, .24) 0%, transparent 48%),
    radial-gradient(85% 110% at 4% 100%, rgba(122, 72, 242, .42) 0%, transparent 56%),
    linear-gradient(135deg, #1b1038 0%, #2d1466 48%, #130b29 100%);
  box-shadow: var(--fx-shadow-hero, 0 22px 50px -20px rgba(38, 14, 92, .62));
  --fx-flash: #86efac;
}
#fx-dashboard-root .fxo-pass.warn {
  box-shadow: inset 4px 0 0 #fbbf24, var(--fx-shadow-hero, 0 22px 50px -20px rgba(38, 14, 92, .62));
}
#fx-dashboard-root .fxo-pass.err {
  box-shadow: inset 4px 0 0 #f87171, var(--fx-shadow-hero, 0 22px 50px -20px rgba(38, 14, 92, .62));
}
#fx-dashboard-root .fxo-pass-gridbg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255, 255, 255, .11) 1px, transparent 1px);
  background-size: 20px 20px;
  -webkit-mask-image: linear-gradient(135deg, rgba(0, 0, 0, .05) 0%, #000 62%, transparent 100%);
  mask-image: linear-gradient(135deg, rgba(0, 0, 0, .05) 0%, #000 62%, transparent 100%);
  opacity: .55;
}
#fx-dashboard-root .fxo-pass .fxn-cur { color: #ffc978; opacity: 1; }
#fx-dashboard-root .fxo-pass .fxn-dec { opacity: .72; }
#fx-dashboard-root .fxo-pass .fxo-up { color: #86efac; }
#fx-dashboard-root .fxo-pass .fxo-down { color: #fca5a5; }

/* ---------- 排行榜金银铜徽章 ---------- */
#fx-dashboard-root .fxo-lb li:nth-child(1) .fxo-rank.top {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  box-shadow: 0 4px 12px -3px rgba(245, 158, 11, .65);
}
#fx-dashboard-root .fxo-lb li:nth-child(2) .fxo-rank.top {
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  color: #fff;
  box-shadow: 0 3px 10px -3px rgba(100, 116, 139, .5);
}
#fx-dashboard-root .fxo-lb li:nth-child(3) .fxo-rank.top {
  background: linear-gradient(135deg, #f59e0b, #c2410c);
  color: #fff;
  box-shadow: 0 3px 10px -3px rgba(194, 65, 12, .5);
}

/* ---------- 骨架屏 ---------- */
.fx-skel {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: color-mix(in srgb, var(--muted, #e6e9f0) 90%, transparent);
}
.fx-skel::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .62), transparent);
  animation: fx-shimmer 1.35s infinite;
}
.dark .fx-skel::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent);
}
.fx-skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* ---------- 首次进入交错动效 ---------- */
.fx-enter {
  animation: fx-in .38s var(--fx-ease) both;
}
#fx-dashboard-root.fx-first [data-bar-idx] rect:last-child {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: fx-grow .58s var(--fx-ease) both;
  animation-delay: calc(110ms + var(--fx-bi, 0ms) + var(--fx-t));
}
#fx-dashboard-root.fx-first .fxo-bar > i,
#fx-dashboard-root.fx-first .fxo-meter > i {
  transform-origin: 0 50%;
  animation: fx-fill .72s var(--fx-ease) both;
  animation-delay: calc(150ms + var(--fx-t));
}
.fx-up-flash { animation: fx-flash 1s ease; }

/* ---------- 按钮/复制反馈 ---------- */
#fx-dashboard-root :is(.fxo-btn, .fxo-seg button, .fxo-link, .fxo-mchip, .fxo-pass-btn-solid, .fxo-pass-btn-ghost),
#fx-keys-page :is(.k2-btn, .k2-icon, .k2-mchip, .k2-act) {
  transition: transform .13s ease, background .16s ease, border-color .16s ease, color .16s ease, box-shadow .18s ease, filter .16s ease;
}
#fx-dashboard-root :is(.fxo-btn, .fxo-seg button, .fxo-mchip, .fxo-pass-btn-solid, .fxo-pass-btn-ghost):active,
#fx-keys-page :is(.k2-btn, .k2-icon, .k2-mchip, .k2-act):active:not(:disabled) {
  transform: scale(.97);
}
.fx-copied {
  color: #059669 !important;
  border-color: rgba(16, 185, 129, .5) !important;
  background: rgba(16, 185, 129, .1) !important;
}
.dark .fx-copied { color: #34d399 !important; }

#fx-keys-page .k2-backdrop { animation: fx-fade .2s ease both; }
#fx-keys-page .k2-modal { animation: fx-pop .26s var(--fx-ease) both; }

/* 呼吸状态点 */
#fx-dashboard-root .fxo-dot,
#fx-keys-page .k2-dot.ok { position: relative; }
#fx-dashboard-root .fxo-dot::after,
#fx-keys-page .k2-dot.ok::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: fx-pulse 2.2s ease-out infinite;
}

/* 语义彩色图标徽章 */
#fx-dashboard-root .fxo-kpi-label { display: flex; align-items: center; }
#fx-dashboard-root .fxo-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin-right: 10px;
  border-radius: 10px;
  background: rgba(122, 72, 242, .11);
  color: #7a48f2;
}
#fx-dashboard-root .fxo-ic.cyan { background: rgba(6, 182, 212, .12); color: #0891b2; }
#fx-dashboard-root .fxo-ic.amber { background: rgba(245, 158, 11, .13); color: #d97706; }
#fx-dashboard-root .fxo-ic.emerald { background: rgba(16, 185, 129, .12); color: #059669; }
#fx-dashboard-root .fxo-ic svg { width: 16px; height: 16px; }
.dark #fx-dashboard-root .fxo-ic { background: rgba(122, 72, 242, .22); color: #c4b5fd; }
.dark #fx-dashboard-root .fxo-ic.cyan { background: rgba(6, 182, 212, .20); color: #67e8f9; }
.dark #fx-dashboard-root .fxo-ic.amber { background: rgba(245, 158, 11, .20); color: #fcd34d; }
.dark #fx-dashboard-root .fxo-ic.emerald { background: rgba(16, 185, 129, .20); color: #6ee7b7; }

/* ---------- 图表悬浮玻璃气泡 ---------- */
#fx-dashboard-root .fxo-plot { position: relative; padding-top: 56px; }
#fx-dashboard-root .fxo-plot-in { position: relative; }
#fx-dashboard-root .fxo-tip {
  position: absolute;
  top: 0;
  z-index: 3;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(20, 14, 40, .95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .1), 0 12px 28px -8px rgba(15, 10, 35, .6);
  opacity: 0;
  visibility: hidden;
  transition: opacity .14s ease, visibility .14s ease, left .18s var(--fx-ease), transform .18s var(--fx-ease);
}
#fx-dashboard-root .fxo-tip.is-open { opacity: 1; visibility: visible; }
#fx-dashboard-root .fxo-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: rgba(20, 14, 40, .95);
  transition: left .18s var(--fx-ease);
}
#fx-dashboard-root .fxo-tip[data-edge="l"] { transform: translateX(-14%); }
#fx-dashboard-root .fxo-tip[data-edge="l"]::after { left: 14%; }
#fx-dashboard-root .fxo-tip[data-edge="r"] { transform: translateX(-86%); }
#fx-dashboard-root .fxo-tip[data-edge="r"]::after { left: 86%; }
#fx-dashboard-root .fxo-tip-t { font-weight: 650; margin-bottom: 2px; color: #e9d5ff; }
#fx-dashboard-root .fxo-tip-r { display: inline-flex; gap: 5px; margin-right: 12px; color: rgba(255, 255, 255, .65); }
#fx-dashboard-root .fxo-tip-r:last-child { margin-right: 0; }
#fx-dashboard-root .fxo-tip-r b { color: #fff; font-weight: 650; }
#fx-dashboard-root .fxo-tip-r.err b { color: #fca5a5; }
#fx-dashboard-root .fxo-guide {
  position: absolute;
  top: -8px;
  width: 0;
  border-left: 1px dashed rgba(122, 72, 242, .6);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .14s ease, visibility .14s ease, left .18s var(--fx-ease), height .18s var(--fx-ease);
}
#fx-dashboard-root .fxo-guide.is-open { opacity: 1; visibility: visible; }

/* 原生页面切换入场 */
main[data-slot="sidebar-inset"][data-fx-enter] main > *:not(#fx-dashboard-root):not(#fx-keys-page):not(#fx-guide-page):not(#fx-pool-page):not(#fx-reseller-page):not([data-fx-dash-hidden]):not([data-fx-keys-hidden]) {
  animation: fx-in .36s var(--fx-ease) both;
}
main[data-slot="sidebar-inset"][data-fx-enter] main > *:nth-child(2) { animation-delay: 45ms; }
main[data-slot="sidebar-inset"][data-fx-enter] main > *:nth-child(3) { animation-delay: 90ms; }
main[data-slot="sidebar-inset"][data-fx-enter] main > *:nth-child(n+4) { animation-delay: 135ms; }
main[data-slot="sidebar-inset"] [data-slot="tabs-content"][data-state="active"] { animation: fx-fade .22s ease both; }

@keyframes fx-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fx-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fx-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes fx-shimmer { to { transform: translateX(100%); } }
@keyframes fx-flash { 0%, 35% { color: var(--fx-flash); } 100% {} }
@keyframes fx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fx-pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fx-pulse { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(2.8); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  #fx-dashboard-root *, #fx-keys-page *, #fx-pool-page *, #fx-reseller-page *, #fx-guide-page *,
  main[data-slot="sidebar-inset"] *, .fx-enter, .fx-skel::after {
    animation: none !important;
    transition: none !important;
  }
}
