/* ===================================================================
   按钮与微交互统一规范 v4
   原则: 层级清晰(主/次/危险)、反馈即时(loading/success/error)、
        触控友好(≥40px 高)、键盘可达
   =================================================================== */

/* ---- 按钮基础(v3.5 胶囊规范继承)---- */
.btn {
  --btn-bg: var(--s2, #171b24);
  --btn-fg: #fff;
  --btn-border: var(--line, rgba(255, 255, 255, 0.07));
  --btn-hover-bg: var(--s3, #1f242f);
  --btn-hover-fg: #fff;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition:
    background 150ms var(--ease, cubic-bezier(.22,1,.36,1)),
    color 150ms,
    border-color 150ms,
    transform 100ms,
    box-shadow 150ms;
}

.btn:hover {
  background: var(--btn-hover-bg);
  color: var(--btn-hover-fg);
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--primary, #4ca9ff);
  outline-offset: 2px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---- 层级: 主操作(最显眼)---- */
.btn-primary {
  --btn-bg: var(--primary, #00e5c7);
  --btn-fg: #fff;
  --btn-border: transparent;
  --btn-hover-bg: #6ab8ff;
  --btn-hover-fg: #fff;
  box-shadow: 0 2px 12px -4px rgba(76, 169, 255, 0.5);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px -4px rgba(76, 169, 255, 0.7);
}

/* 渐变主按钮(用于 hero/营销位) */
.btn-primary.btn-gradient {
  background: linear-gradient(135deg, #00e5c7 0%, #4ca9ff 60%, #b794ff 100%);
  box-shadow: 0 4px 16px -4px rgba(139, 92, 246, 0.4);
}

.btn-primary.btn-gradient:hover {
  filter: brightness(1.08);
}

/* ---- 层级: 次操作(幽灵)---- */
.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: rgba(255, 255, 255, 0.85);
  --btn-border: var(--line, rgba(255, 255, 255, 0.12));
  --btn-hover-bg: rgba(255, 255, 255, 0.05);
  --btn-hover-fg: #fff;
}

/* ---- 层级: 危险/破坏性 ---- */
.btn-danger {
  --btn-bg: rgba(239, 68, 68, 0.12);
  --btn-fg: #fca5a5;
  --btn-border: rgba(239, 68, 68, 0.3);
  --btn-hover-bg: rgba(239, 68, 68, 0.2);
  --btn-hover-fg: #fecaca;
}

/* ---- 层级: 链接式(最低视觉权重)---- */
.btn-link {
  background: transparent;
  border: 0;
  color: var(--primary, #00e5c7);
  padding: 4px 6px;
  min-height: auto;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
  background: transparent;
  color: #6ab8ff;
}

/* ---- 尺寸 ---- */
.btn-xs { min-height: 28px; padding: 0 10px; font-size: 11.5px; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 12.5px; }
.btn-lg { min-height: 48px; padding: 0 24px; font-size: 15px; }

/* ---- 块级按钮(全宽)---- */
.btn-block { display: flex; width: 100%; }

/* ---- 图标按钮(方)---- */
.btn-icon {
  padding: 0;
  width: 40px;
  min-height: 40px;
}

/* ===================================================================
   微交互: 加载中 / 成功 / 错误
   =================================================================== */

/* 加载中: 按钮内显示 spinner,禁用点击 */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: #fff;
  animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* 成功: 短暂打勾动画 */
.btn.is-success {
  background: #10b981 !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* ===================================================================
   空状态/反馈组件
   =================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--line, rgba(255, 255, 255, 0.1));
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  gap: 12px;
}

.empty-state__icon {
  font-size: 40px;
  opacity: 0.5;
  margin-bottom: 4px;
}

.empty-state__title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.empty-state__desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
  max-width: 320px;
}

.empty-state__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ===================================================================
   Toast(轻量提示) — 用于表单/购买反馈
   =================================================================== */

.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--s2, #171b24);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
  color: #fff;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  animation: toast-in 200ms var(--ease, cubic-bezier(.22,1,.36,1));
}

.toast--success { border-color: rgba(16, 185, 129, 0.3); }
.toast--success::before { content: '✓'; color: #10b981; font-weight: 700; }
.toast--error { border-color: rgba(239, 68, 68, 0.3); }
.toast--error::before { content: '✕'; color: #ef4444; font-weight: 700; }
.toast--info::before { content: 'ℹ'; color: var(--primary, #00e5c7); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===================================================================
   进度条 — 用于支付/上传等长操作
   =================================================================== */

.progress {
  width: 100%;
  height: 6px;
  background: var(--s0, #0b0d12);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress__bar {
  height: 100%;
  background: linear-gradient(90deg, #00e5c7, #4ca9ff, #b794ff);
  border-radius: 999px;
  transition: width 400ms var(--ease, cubic-bezier(.22,1,.36,1));
  position: relative;
  overflow: hidden;
}

.progress__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progress-shimmer 1.5s linear infinite;
}

@keyframes progress-shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* ===================================================================
   偏好减弱动效
   =================================================================== */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .btn:active,
  .toast,
  .progress__bar::after {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}
