/* ============================================================
   小伍+ 基础组件库 — 基于统一设计 Token
   依赖: tokens.css (必须在此文件之前引入)
   版本: 2.0.0 | 更新: 2026-07-31

   使用方式: 在 HTML 中按顺序引入:
   <link rel="stylesheet" href="/tokens.css">
   <link rel="stylesheet" href="/components.css">
   然后使用 class="xw-btn xw-btn--primary" 等。
   ============================================================ */

/* ---- Button ---- */
.xw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 11px var(--space-lg);
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  line-height: 20px;
  cursor: pointer;
  transition: background var(--motion-quick) var(--motion-easing),
              opacity var(--motion-quick) var(--motion-easing);
  white-space: nowrap;
  min-height: 44px;
}
.xw-btn:focus-visible,
.xw-list__item:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}
.xw-btn:disabled { opacity: 0.55; cursor: wait; }
.xw-btn:active { transform: scale(0.97); }

.xw-btn--primary {
  background: var(--brand);
  color: var(--text-inverse);
}
.xw-btn--primary:active { background: var(--brand-pressed); }

.xw-btn--secondary {
  background: var(--brand-soft);
  color: var(--brand);
}
.xw-btn--secondary:active { background: var(--brand-subtle); }

.xw-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.xw-btn--ghost:active { background: var(--surface-muted); }

.xw-btn--danger {
  background: var(--danger);
  color: var(--text-inverse);
}

.xw-btn--block { width: 100%; }
.xw-btn--sm { padding: 8px 14px; font-size: 13px; }
.xw-btn--lg { padding: 14px 24px; font-size: 17px; }

/* ---- Card ---- */
.xw-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}
.xw-card--elevated { box-shadow: var(--shadow-md); border-color: transparent; }
.xw-card--inset { background: var(--surface-muted); }

.xw-card__title {
  font: var(--text-headline);
  margin: 0 0 var(--space-sm);
}
.xw-card__body { font: var(--text-body); color: var(--text); }
.xw-card__footer {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ---- Input ---- */
.xw-input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--motion-quick) var(--motion-easing),
              box-shadow var(--motion-quick) var(--motion-easing);
}
.xw-input:focus-visible {
  border-color: var(--brand);
  box-shadow: none;
}
.xw-input::placeholder { color: var(--text-tertiary); }
.xw-input--error { border-color: var(--danger); }
.xw-input--error:focus-visible { outline-color: var(--danger); }

.xw-label {
  display: grid;
  gap: var(--space-xxs);
  margin: var(--space-md) 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ---- Badge / Chip ---- */
.xw-chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  background: var(--brand-soft);
  color: var(--brand);
}
.xw-chip--success { background: var(--success-soft); color: var(--success); }
.xw-chip--warning { background: var(--warning-soft); color: var(--warning); }
.xw-chip--danger { background: var(--danger-soft); color: var(--danger); }
.xw-chip--info { background: var(--info-soft); color: var(--info); }
.xw-chip--neutral { background: var(--surface-muted); color: var(--text-secondary); }

/* ---- List ---- */
.xw-list { display: grid; gap: 1px; background: var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; }
.xw-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
}
.xw-list__item:active { background: var(--surface-muted); }
.xw-list__item__title { flex: 1; font-size: 15px; font-weight: 600; color: var(--text); }
.xw-list__item__subtitle { font-size: 13px; color: var(--text-secondary); }

/* ---- Avatar ---- */
.xw-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: var(--text-inverse);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.xw-avatar--sm { width: 32px; height: 32px; font-size: 13px; }
.xw-avatar--lg { width: 56px; height: 56px; font-size: 20px; }

/* ---- Divider ---- */
.xw-divider { height: 1px; background: var(--border-subtle); border: 0; margin: var(--space-md) 0; }

/* ---- Empty State ---- */
.xw-empty {
  display: grid;
  place-items: center;
  gap: var(--space-sm);
  padding: var(--space-xxxl) var(--space-xl);
  text-align: center;
}
.xw-empty__icon { font-size: 40px; opacity: 0.3; }
.xw-empty__title { font: var(--text-headline); color: var(--text); }
.xw-empty__desc { font: var(--text-subhead); color: var(--text-secondary); max-width: 320px; }

/* ---- Skeleton Loading ---- */
.xw-skeleton {
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--border-subtle) 50%, var(--surface-muted) 75%);
  background-size: 200% 100%;
  animation: xw-shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}
@keyframes xw-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Utility ---- */
.xw-hidden { display: none !important; }
.xw-flex { display: flex; }
.xw-flex-col { display: flex; flex-direction: column; }
.xw-items-center { align-items: center; }
.xw-justify-between { justify-content: space-between; }
.xw-gap-xs { gap: var(--space-xs); }
.xw-gap-sm { gap: var(--space-sm); }
.xw-gap-md { gap: var(--space-md); }
.xw-gap-lg { gap: var(--space-lg); }
.xw-flex-1 { flex: 1; }
.xw-text-center { text-align: center; }
.xw-text-right { text-align: right; }
.xw-mt-sm { margin-top: var(--space-sm); }
.xw-mt-md { margin-top: var(--space-md); }
.xw-mt-lg { margin-top: var(--space-lg); }
.xw-mb-sm { margin-bottom: var(--space-sm); }
.xw-mb-md { margin-bottom: var(--space-md); }
.xw-mb-lg { margin-bottom: var(--space-lg); }
