/* macOS 风格代码高亮样式 */

/* 基础代码块样式 - macOS 窗口风格 */
pre {
  position: relative;
  background: #1e1e1e !important;
  border-radius: 8px !important;
  padding: 2.5rem 1rem 1rem !important;
  margin: 1.5rem 0 !important;
  overflow-x: auto;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* macOS 窗口标题栏 */
pre::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5rem;
  background: #2d2d2d;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid #1a1a1a;
}

/* macOS 窗口控制按钮（红黄绿） */
pre::after {
  content: '';
  position: absolute;
  top: 0.75rem;
  left: 1rem;
  width: 12px;
  height: 12px;
  background: #ff5f57;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.1),
    20px 0 0 0 #febc2e,
    20px 0 0 1px rgba(0, 0, 0, 0.1),
    40px 0 0 0 #28c840,
    40px 0 0 1px rgba(0, 0, 0, 0.1);
}

/* 代码容器 */
pre code {
  display: block;
  padding: 0 !important;
  background: transparent !important;
  color: #d4d4d4;
  font-size: 0.875rem;
  line-height: 1.6;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
}

/* 复制按钮容器 */
.code-block-wrapper {
  position: relative;
}

/* 复制按钮 */
.copy-code-button {
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #d4d4d4;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
  opacity: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.code-block-wrapper:hover .copy-code-button {
  opacity: 1;
}

.copy-code-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.copy-code-button:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.95);
}

.copy-code-button.copied {
  background: #28c840;
  border-color: #28c840;
  color: white;
}

/* highlight.js 语法高亮主题 - VS Code Dark+ 风格 */
.hljs {
  color: #d4d4d4;
  background: transparent;
}

.hljs-comment,
.hljs-quote {
  color: #6a9955;
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-type {
  color: #569cd6;
}

.hljs-number {
  color: #b5cea8;
}

.hljs-string,
.hljs-regexp {
  color: #ce9178;
}

.hljs-subst {
  color: #d4d4d4;
}

.hljs-title,
.hljs-section,
.hljs-selector-id {
  color: #dcdcaa;
  font-weight: bold;
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable {
  color: #9cdcfe;
}

.hljs-function,
.hljs-built_in,
.hljs-builtin-name {
  color: #dcdcaa;
}

.hljs-tag,
.hljs-name {
  color: #569cd6;
}

.hljs-meta {
  color: #d4d4d4;
}

.hljs-meta-keyword {
  color: #569cd6;
}

.hljs-meta-string {
  color: #ce9178;
}

.hljs-symbol,
.hljs-bullet,
.hljs-link {
  color: #9cdcfe;
}

.hljs-deletion {
  color: #ff5370;
  background: rgba(255, 83, 112, 0.1);
}

.hljs-addition {
  color: #91b859;
  background: rgba(145, 184, 89, 0.1);
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: bold;
}

/* 行内代码样式 */
:not(pre) > code {
  padding: 0.125rem 0.375rem;
  font-size: 0.875em;
  background: rgba(135, 131, 120, 0.15);
  border-radius: 3px;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
}

/* 暗色模式适配 */
html.dark pre {
  background: #1e1e1e !important;
}

html.dark pre::before {
  background: #2d2d2d;
  border-bottom-color: #1a1a1a;
}

html.dark :not(pre) > code {
  background: rgba(255, 255, 255, 0.1);
  color: #d4d4d4;
}

/* 亮色模式适配 */
html:not(.dark) pre {
  background: #f5f5f5 !important;
}

html:not(.dark) pre::before {
  background: #e8e8e8;
  border-bottom-color: #d0d0d0;
}

html:not(.dark) pre code {
  color: #24292e;
}

html:not(.dark) .copy-code-button {
  color: #24292e;
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

html:not(.dark) .copy-code-button:hover {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
}

html:not(.dark) :not(pre) > code {
  background: rgba(135, 131, 120, 0.15);
  color: #24292e;
}

/* 亮色模式语法高亮 */
html:not(.dark) .hljs {
  color: #24292e;
}

html:not(.dark) .hljs-comment,
html:not(.dark) .hljs-quote {
  color: #6a737d;
}

html:not(.dark) .hljs-keyword,
html:not(.dark) .hljs-selector-tag,
html:not(.dark) .hljs-literal,
html:not(.dark) .hljs-type {
  color: #d73a49;
}

html:not(.dark) .hljs-number {
  color: #005cc5;
}

html:not(.dark) .hljs-string,
html:not(.dark) .hljs-regexp {
  color: #032f62;
}

html:not(.dark) .hljs-title,
html:not(.dark) .hljs-section,
html:not(.dark) .hljs-selector-id {
  color: #6f42c1;
}

html:not(.dark) .hljs-attr,
html:not(.dark) .hljs-attribute,
html:not(.dark) .hljs-variable,
html:not(.dark) .hljs-template-variable {
  color: #005cc5;
}

html:not(.dark) .hljs-function,
html:not(.dark) .hljs-built_in,
html:not(.dark) .hljs-builtin-name {
  color: #6f42c1;
}
