/* 基础代码块样式 */
code[class*="language-"],
pre[class*="language-"] {
  font-family: Consolas, Menlo, Monaco, monospace;
  font-size: 14px;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  tab-size: 4;
  hyphens: none;
  color: #8f9d6a;
}

/* 代码块容器 */
pre[class*="language-"] {
  position: relative;
  margin: 0;
  background: inherit;
  border-radius: 0;
  padding: 16px; /* 移除顶部内边距,因为已经由容器处理 */
  overflow: hidden;
}

/* 代码内容 */
pre[class*="language-"] > code {
  display: block;
  padding: 0;
  overflow: auto;
  font-size: 14px;
  line-height: 1.6;
  padding-left: 0; /* 为行号留出空间 */
  padding-right: 40px; /* 为复制按钮留出空间 */
  color: #8f9d6a;
}

/* 行号基础样式 */
pre.line-numbers {
  position: relative;
  padding-left: 3.8em;
  counter-reset: linenumber;
}

pre.line-numbers > code {
  position: relative;
  white-space: pre;
}

.line-numbers .line-numbers-rows {
  position: absolute;
  pointer-events: none;
  top: 1em;  /* 与代码内容对齐 */
  left: -3.8em;
  width: 30px;
  letter-spacing: -1px;
  user-select: none;
  height: calc(100% - 1em);
  color: #aaa;
  border-right: none;
}

.line-numbers-rows > span {
  display: block;
  counter-increment: linenumber;
  height: 1.5em;  /* 设置行高 */
  line-height: 1.5em;
}

.line-numbers-rows > span:before {
  content: counter(linenumber);
  color: #aaa;
  display: block;
  padding-right: 1em;
  text-align: right;
}

/* 行高亮插件基础样式 */
.line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
}

/* 工具栏样式 */
.code-toolbar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 32px;
  background: #090300;
  display: flex;
  align-items: center;
  z-index: 10;
}

/* 按钮组基础样式 */
.toolbar-buttons {
  position: absolute;
  right: 0;
  top: 0;
  height: 32px;
  display: flex;
  z-index: 11; /* 确保按钮在最上层 */
}

/* macOS 风格按钮组 */
.macos-style .toolbar-buttons {
  gap: 8px;
}

.macos-style .window-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: default;
}

.macos-style .window-btn.close { background: #ff5f56; }
.macos-style .window-btn.minimize { background: #ffbd2e; }
.macos-style .window-btn.maximize { background: #27c93f; }

/* 去掉底部边框 */
.code-toolbar {
  border-bottom: none;
}

/* 统一背景色 */
.code-toolbar,
.code-wrapper,
pre[class*="language-"] {
  background: #090300;
}

/* 语言标识 */
.code-lang {
  flex: 1;
  font-size: 14px;
  color: #e0e0c5;
  font-weight: bold;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin-right: auto; /* 推到左侧 */
  padding-left: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  flex: 1;
}

/* 复制按钮 */
.copy-button {
  position: absolute;
  top: 40px; /* 与代码内容对齐 */
  right: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  font-size: 12px;
  color: #6272a4;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

/* 复制按钮悬停状态 */
.copy-button:hover {
  color: #f8f8f2;
  background: rgba(255, 255, 255, 0.1);
}

/* 复制成功状态 */
.copy-button.success {
  color: #52C41A;
  border-color: rgba(82, 196, 26, 0.4);
  background: rgba(82, 196, 26, 0.1);
}

/* 复制失败状态 */
.copy-button.error {
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.1);
}

/* SVG 图标样式 */
.copy-button svg {
  margin: 0;       /* 移除所有边距 */
  padding: 0;      /* 移除所有内边距 */
  width: 16px;     /* 固定图标宽度 */
  height: 16px;    /* 固定图标高度 */
  opacity: 0.8;
  transition: all 0.2s ease;
  display: block;  /* 防止行内元素的额外空间 */
}

.copy-button:hover svg {
  opacity: 1;
}

/* 底部信息栏 */
.code-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  margin-top: 1em;
  font-size: 12px;
}

.code-info {
  display: flex;
  gap: 16px;
}

.code-info span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 滚动条基础样式 */
pre[class*="language-"] > code::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

pre[class*="language-"] > code::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

pre[class*="language-"] > code::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}


/* 代码容器包装器 */
.code-wrapper {
  background: #090300;
  border-radius: 8px;
  overflow: hidden; /* 确保圆角效果 */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); /* 添加轻微阴影 */
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  position: relative;
  padding-top: 32px; /* 为工具栏预留空间 */
}

/* 移除代码块的默认margin */
.code-wrapper pre[class*="language-"] {
  margin: 0;
  border-radius: 0;
}
/* Windows 风格工具栏 */
.code-toolbar.windows-style {
  display: flex;
  align-items: center;
  padding: 0;
  height: 32px;
  background: #090300;
}

/* 语言标识 */
.windows-style .code-lang {
  padding-left: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Windows 风格按钮组 */
.windows-style .toolbar-buttons {
  display: flex;
  gap: 0;
  margin-left: auto;  /* 推到右侧 */
  height: 32px;      /* 确保高度填满工具栏 */
}

.windows-style .window-btn {
  width: 46px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0.7;
  font-family: "Segoe UI", sans-serif;
  font-size: 16px;
}

/* 简化的窗口按钮样式 */
.window-btn {
  width: 46px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: "Segoe UI", sans-serif;
  font-size: 16px;
  user-select: none;
  background: transparent;
  border: none;
  pointer-events: none;
}
