/* =====================================================
   Components v4.0 - 现代组件体系
   ===================================================== */

/* ===== Buttons（更精致的按钮）===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  line-height: 1.4;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Primary */
.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-sm);
}
.btn-primary:active {
  box-shadow: none;
}

/* Secondary */
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--text-tertiary);
}

/* Accent */
.btn-accent {
  background: var(--accent);
  color: var(--text-inverse);
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}
.btn-accent:hover {
  background: var(--accent-light);
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #DC2626;
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

/* Link */
.btn-link {
  background: transparent;
  color: var(--primary);
  padding: 4px 8px;
  font-weight: var(--font-medium);
}
.btn-link:hover {
  text-decoration: underline;
}

/* Sizes */
.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-sm);
  border-radius: var(--radius-xs);
}
.btn-lg {
  padding: 14px 28px;
  font-size: var(--text-lg);
  border-radius: var(--radius);
}
.btn-block {
  width: 100%;
}

/* Icon Button */
.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
}
.icon-btn:active {
  transform: scale(0.95);
}

/* ===== Cards（更精致的卡片）===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.card-interactive:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.card-body {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1.6;
}

.card-footer {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== Stat Card ===== */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--space-4);
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-icon {
  font-size: 24px;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-card .stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-card .stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
  font-weight: var(--font-medium);
}

/* ===== Form Elements（更精致的表单）===== */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--text);
  transition: all var(--transition-fast);
  line-height: 1.5;
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
  border-color: var(--text-tertiary);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.1);
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-textarea:focus,
[data-theme="dark"] .form-select:focus {
  box-shadow: 0 0 0 3px rgba(250, 250, 250, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.6;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2371717A'%3E%3Cpath d='M4.5 6L8 9.5 11.5 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-1);
}

/* Input with icon */
.input-group {
  position: relative;
}

.input-group .form-input {
  padding-left: 40px;
}

.input-group .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: var(--text-lg);
  line-height: 1;
  pointer-events: none;
}

/* ===== Tags / Chips ===== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  line-height: 1.5;
  white-space: nowrap;
}

.tag-primary { background: var(--bg-secondary); color: var(--text); }
.tag-accent { background: var(--accent-bg); color: var(--accent); }
.tag-success { background: var(--success-bg); color: var(--success); }
.tag-warning { background: var(--warning-bg); color: var(--warning); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-info { background: var(--info-bg); color: var(--info); }

/* Selectable Chip */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
  background: var(--card);
}
.chip:hover {
  border-color: var(--text-tertiary);
  background: var(--bg);
}
.chip.selected {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.chip:active {
  transform: scale(0.96);
}

/* ===== Badge（小圆点指示器）===== */
.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ===== Progress Bar（更精致的进度条）===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar-fill.accent {
  background: var(--accent-gradient);
}

.progress-bar-sm {
  height: 4px;
}

.progress-bar-lg {
  height: 12px;
}

/* ===== XP Bar（游戏化专用）===== */
.xp-bar {
  width: 100%;
  height: 10px;
  background: var(--xp-bar-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.xp-bar-fill {
  height: 100%;
  background: var(--xp-bar-gradient);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.xp-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.3), transparent);
  border-radius: var(--radius-full) var(--radius-full) 0 0;
}

/* ===== Avatar ===== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--text-base); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-2xl); }

/* ===== List Item ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  cursor: pointer;
}
.list-item:hover {
  background: var(--bg);
}
.list-item:active {
  background: var(--bg-secondary);
}

/* ===== Toggle Switch ===== */
.toggle {
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.toggle.active {
  background: var(--primary);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}
.toggle.active::after {
  left: 22px;
}
