/* 自定义代码块样式 - VS Code 风格优化 */

/* 代码块基础样式 - Light 模式 */
.highlight {
    background: #ffffff !important;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    margin: 1rem 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.highlight pre {
    background: #ffffff !important;
    color: #24292e !important;
    padding: 1.25rem;
    margin: 0;
    overflow-x: auto;
    font-family: 'Cascadia Code', 'Fira Code', 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 400;
}

.highlight pre code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    font-family: inherit !important;
}

/* 行号样式 */
.highlight .linenos {
    background: #f8f9fa !important;
    color: #6a737d !important;
    border-right: 1px solid #e1e4e8;
    padding: 1.25rem 0.75rem;
    text-align: right;
    user-select: none;
    font-size: 13px;
    line-height: 1.6;
    min-width: 3.5rem;
    font-family: inherit;
}

.highlight .linenos a {
    color: #6a737d !important;
    text-decoration: none;
    transition: color 0.2s ease;
}

.highlight .linenos a:hover {
    color: #24292e !important;
}

/* 语法高亮颜色 - VS Code Light 风格 */
.highlight .k { color: #0000ff !important; font-weight: 600; } /* 关键字 - 蓝色加粗 */
.highlight .kt { color: #267f99 !important; font-weight: 600; } /* 类型 - 青色加粗 */
.highlight .kd { color: #0000ff !important; font-weight: 600; } /* 声明 - 蓝色加粗 */
.highlight .kn { color: #0000ff !important; font-weight: 600; } /* 关键字 - 蓝色加粗 */
.highlight .kr { color: #0000ff !important; font-weight: 600; } /* 保留字 - 蓝色加粗 */

.highlight .s { color: #a31515 !important; } /* 字符串 - 深红色 */
.highlight .s1 { color: #a31515 !important; } /* 单引号字符串 */
.highlight .s2 { color: #a31515 !important; } /* 双引号字符串 */
.highlight .sh { color: #a31515 !important; } /* 字符串 */
.highlight .sx { color: #a31515 !important; } /* 字符串 */

.highlight .c { color: #008000 !important; font-style: italic; } /* 注释 - 绿色斜体 */
.highlight .c1 { color: #008000 !important; font-style: italic; } /* 单行注释 */
.highlight .cm { color: #008000 !important; font-style: italic; } /* 多行注释 */
.highlight .cp { color: #008000 !important; font-style: italic; } /* 预处理器注释 */

.highlight .n { color: #24292e !important; } /* 名称 - 默认文本色 */
.highlight .nf { color: #795e26 !important; font-weight: 600; } /* 函数名 - 棕色加粗 */
.highlight .nc { color: #267f99 !important; font-weight: 600; } /* 类名 - 青色加粗 */
.highlight .no { color: #0000ff !important; font-weight: 600; } /* 常量 - 蓝色加粗 */
.highlight .na { color: #795e26 !important; } /* 属性 - 棕色 */
.highlight .nb { color: #0000ff !important; font-weight: 600; } /* 内置函数 - 蓝色加粗 */

.highlight .o { color: #000000 !important; font-weight: 600; } /* 操作符 - 黑色加粗 */
.highlight .p { color: #24292e !important; } /* 标点符号 - 默认色 */

.highlight .m { color: #098658 !important; font-weight: 600; } /* 数字 - 绿色加粗 */
.highlight .mi { color: #098658 !important; font-weight: 600; } /* 整数 */
.highlight .mf { color: #098658 !important; font-weight: 600; } /* 浮点数 */

.highlight .cpf { color: #008000 !important; font-style: italic; } /* 预处理器 */
.highlight .c1 { color: #008000 !important; font-style: italic; } /* 注释 */

/* 特殊标记 */
.highlight .err { color: #d73a49 !important; background: #ffeef0 !important; } /* 错误 */
.highlight .w { color: #24292e !important; } /* 警告 */

/* 行高亮 */
.highlight .hll {
    background: #fff3cd !important;
    border-left: 3px solid #ffc107;
    padding-left: 0.5rem;
    margin-left: -0.5rem;
}

/* 代码块标题栏 */
.highlight::before {
    content: '';
    display: block;
    background: linear-gradient(90deg, #e1e4e8, #f8f9fa);
    height: 2px;
    margin: 0;
}

/* 代码块滚动条 */
.highlight pre::-webkit-scrollbar {
    height: 8px;
}

.highlight pre::-webkit-scrollbar-track {
    background: #f6f8fa;
}

.highlight pre::-webkit-scrollbar-thumb {
    background: #d0d7de;
    border-radius: 4px;
}

.highlight pre::-webkit-scrollbar-thumb:hover {
    background: #a8b1ba;
}

/* 内联代码样式 - VS Code 风格 */
code {
    background: #f1f3f4 !important;
    color: #d73a49 !important;
    padding: 0.2em 0.4em !important;
    border-radius: 4px !important;
    font-family: 'Cascadia Code', 'Fira Code', 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace !important;
    font-size: 0.9em !important;
    border: 1px solid #e1e4e8 !important;
    font-weight: 500;
}

/* Dark 模式下的代码块样式 - VS Code Dark+ 风格 */
[data-theme="dark"] .highlight,
.dark .highlight {
    background: #1e1e1e !important;
    border: 1px solid #3c3c3c;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .highlight pre,
.dark .highlight pre {
    background: #1e1e1e !important;
    color: #d4d4d4 !important;
}

[data-theme="dark"] .highlight pre code,
.dark .highlight pre code {
    background: transparent !important;
    border: none !important;
}

[data-theme="dark"] .highlight .linenos,
.dark .highlight .linenos {
    background: #252526 !important;
    color: #858585 !important;
    border-color: #3c3c3c !important;
}

/* Dark 模式下的语法高亮 - VS Code Dark+ 风格 */
[data-theme="dark"] .highlight .k,
.dark .highlight .k { color: #569cd6 !important; font-weight: 600; } /* 关键字 - 蓝色加粗 */
[data-theme="dark"] .highlight .kt,
.dark .highlight .kt { color: #4ec9b0 !important; font-weight: 600; } /* 类型 - 青色加粗 */
[data-theme="dark"] .highlight .kd,
.dark .highlight .kd { color: #569cd6 !important; font-weight: 600; } /* 声明 - 蓝色加粗 */
[data-theme="dark"] .highlight .kn,
.dark .highlight .kn { color: #569cd6 !important; font-weight: 600; } /* 关键字 - 蓝色加粗 */
[data-theme="dark"] .highlight .kr,
.dark .highlight .kr { color: #569cd6 !important; font-weight: 600; } /* 保留字 - 蓝色加粗 */

[data-theme="dark"] .highlight .s,
.dark .highlight .s { color: #ce9178 !important; } /* 字符串 - 橙色 */
[data-theme="dark"] .highlight .s1,
.dark .highlight .s1 { color: #ce9178 !important; } /* 单引号字符串 */
[data-theme="dark"] .highlight .s2,
.dark .highlight .s2 { color: #ce9178 !important; } /* 双引号字符串 */
[data-theme="dark"] .highlight .sh,
.dark .highlight .sh { color: #ce9178 !important; } /* 字符串 */
[data-theme="dark"] .highlight .sx,
.dark .highlight .sx { color: #ce9178 !important; } /* 字符串 */

[data-theme="dark"] .highlight .c,
.dark .highlight .c { color: #6a9955 !important; font-style: italic; } /* 注释 - 绿色斜体 */
[data-theme="dark"] .highlight .c1,
.dark .highlight .c1 { color: #6a9955 !important; font-style: italic; } /* 单行注释 */
[data-theme="dark"] .highlight .cm,
.dark .highlight .cm { color: #6a9955 !important; font-style: italic; } /* 多行注释 */
[data-theme="dark"] .highlight .cp,
.dark .highlight .cp { color: #6a9955 !important; font-style: italic; } /* 预处理器注释 */

[data-theme="dark"] .highlight .n,
.dark .highlight .n { color: #d4d4d4 !important; } /* 名称 - 默认文本色 */
[data-theme="dark"] .highlight .nf,
.dark .highlight .nf { color: #dcdcaa !important; font-weight: 600; } /* 函数名 - 黄色加粗 */
[data-theme="dark"] .highlight .nc,
.dark .highlight .nc { color: #4ec9b0 !important; font-weight: 600; } /* 类名 - 青色加粗 */
[data-theme="dark"] .highlight .no,
.dark .highlight .no { color: #569cd6 !important; font-weight: 600; } /* 常量 - 蓝色加粗 */
[data-theme="dark"] .highlight .na,
.dark .highlight .na { color: #dcdcaa !important; } /* 属性 - 黄色 */
[data-theme="dark"] .highlight .nb,
.dark .highlight .nb { color: #569cd6 !important; font-weight: 600; } /* 内置函数 - 蓝色加粗 */

[data-theme="dark"] .highlight .o,
.dark .highlight .o { color: #d4d4d4 !important; font-weight: 600; } /* 操作符 - 默认色加粗 */
[data-theme="dark"] .highlight .p,
.dark .highlight .p { color: #d4d4d4 !important; } /* 标点符号 - 默认色 */

[data-theme="dark"] .highlight .m,
.dark .highlight .m { color: #b5cea8 !important; font-weight: 600; } /* 数字 - 浅绿色加粗 */
[data-theme="dark"] .highlight .mi,
.dark .highlight .mi { color: #b5cea8 !important; font-weight: 600; } /* 整数 */
[data-theme="dark"] .highlight .mf,
.dark .highlight .mf { color: #b5cea8 !important; font-weight: 600; } /* 浮点数 */

[data-theme="dark"] .highlight .cpf,
.dark .highlight .cpf { color: #6a9955 !important; font-style: italic; } /* 预处理器 */
[data-theme="dark"] .highlight .c1,
.dark .highlight .c1 { color: #6a9955 !important; font-style: italic; } /* 注释 */

/* Dark 模式下的行高亮 */
[data-theme="dark"] .highlight .hll,
.dark .highlight .hll {
    background: #2d2d30 !important;
    border-left: 3px solid #007acc;
    padding-left: 0.5rem;
    margin-left: -0.5rem;
}

/* Dark 模式下的代码块标题栏 */
[data-theme="dark"] .highlight::before,
.dark .highlight::before {
    background: linear-gradient(90deg, #3c3c3c, #252526);
}

/* Dark 模式下的内联代码 */
[data-theme="dark"] code,
.dark code {
    background: #2d2d30 !important;
    color: #ce9178 !important;
    border-color: #3c3c3c !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .highlight {
        margin: 0.5rem 0;
        border-radius: 4px;
    }
    
    .highlight pre {
        padding: 0.75rem;
        font-size: 13px;
    }
    
    .highlight .linenos {
        padding: 0.75rem 0.25rem;
        font-size: 11px;
    }
}

/* 代码块标题栏 */
.highlight::before {
    content: '';
    display: block;
    background: #d0d7de;
    height: 1px;
    margin: 0;
}

[data-theme="dark"] .highlight::before,
.dark .highlight::before {
    background: #30363d;
}

/* 代码块底部阴影 */
.highlight::after {
    content: '';
    display: block;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
    height: 1px;
    margin: 0;
}

[data-theme="dark"] .highlight::after,
.dark .highlight::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}
