/* 代码高亮样式 - Prism.js 主题 */

/* 基础代码块样式 */
code[class*="language-"],
pre[class*="language-"] {
    color: #f8f8f2;
    background: none;
    text-shadow: 0 1px rgba(0, 0, 0, 0.3);
    font-family: 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    word-wrap: normal;
    line-height: 1.5;
    -moz-tab-size: 4;
    -o-tab-size: 4;
    tab-size: 4;
    -webkit-hyphens: none;
    -moz-hyphens: none;
    -ms-hyphens: none;
    hyphens: none;
}

/* 代码块容器 */
pre[class*="language-"] {
    padding: 1em;
    margin: 0.5em 0;
    overflow: auto;
    border-radius: 8px;
    background: #282a36;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
}

/* 行内代码 */
:not(pre) > code[class*="language-"] {
    padding: 0.2em 0.4em;
    border-radius: 4px;
    background: #f1f3f4;
    color: #e91e63;
    font-size: 0.9em;
}

/* 暗色模式下的行内代码 */
.dark-mode :not(pre) > code[class*="language-"] {
    background: #3c3c3c;
    color: #ff79c6;
}

/* 代码高亮颜色 - Dracula 主题 */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #6272a4;
    font-style: italic;
}

.token.punctuation {
    color: #f8f8f2;
}

.namespace {
    opacity: 0.7;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
    color: #ff79c6;
}

.token.boolean,
.token.number {
    color: #bd93f9;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #50fa7b;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
    color: #f8f8f2;
}

.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
    color: #f1fa8c;
}

.token.keyword {
    color: #8be9fd;
    font-weight: bold;
}

.token.regex,
.token.important {
    color: #ffb86c;
}

.token.important,
.token.bold {
    font-weight: bold;
}

.token.italic {
    font-style: italic;
}

.token.entity {
    cursor: help;
}

/* 特定语言的高亮 */
.language-javascript .token.template-string .token.interpolation {
    color: #f8f8f2;
}

.language-javascript .token.template-string .token.interpolation .token.punctuation {
    color: #ff79c6;
}

.language-css .token.property {
    color: #50fa7b;
}

.language-css .token.function {
    color: #8be9fd;
}

.language-html .token.attr-name {
    color: #50fa7b;
}

.language-html .token.attr-value {
    color: #f1fa8c;
}

.language-php .token.variable {
    color: #ff79c6;
}

.language-python .token.decorator {
    color: #ff79c6;
}

.language-json .token.property {
    color: #8be9fd;
}

/* 行号样式 */
pre[class*="language-"].line-numbers {
    position: relative;
    padding-left: 3.8em;
    counter-reset: linenumber;
}

pre[class*="language-"].line-numbers > code {
    position: relative;
    white-space: inherit;
}

.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid #44475a;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.line-numbers-rows > span {
    pointer-events: none;
    display: block;
    counter-increment: linenumber;
}

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: #6272a4;
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

/* 高亮行 */
.line-highlight {
    position: absolute;
    left: 0;
    right: 0;
    padding: inherit 0;
    margin-top: 1em;
    background: rgba(255, 255, 255, 0.08);
    background: linear-gradient(to right, rgba(255, 255, 255, 0.1) 70%, rgba(255, 255, 255, 0));
    pointer-events: none;
    line-height: inherit;
    white-space: pre;
}

.line-highlight:before,
.line-highlight[data-end]:after {
    content: attr(data-start);
    position: absolute;
    top: 0.4em;
    left: 0.6em;
    min-width: 1em;
    padding: 0 0.5em;
    background-color: rgba(255, 255, 255, 0.4);
    color: #282a36;
    font: bold 65%/1.5 sans-serif;
    text-align: center;
    vertical-align: 0.3em;
    border-radius: 999px;
    text-shadow: none;
    box-shadow: 0 1px white;
}

.line-highlight[data-end]:after {
    content: attr(data-end);
    top: auto;
    bottom: 0.4em;
}

/* 代码复制按钮 */
.code-toolbar {
    position: relative;
}

.code-toolbar > .toolbar {
    position: absolute;
    top: 0.3em;
    right: 0.2em;
    transition: opacity 0.3s ease-in-out;
    opacity: 0;
    z-index: 10;
}

.code-toolbar:hover > .toolbar {
    opacity: 1;
}

.code-toolbar > .toolbar .toolbar-item {
    display: inline-block;
    margin-left: 0.5em;
}

.code-toolbar > .toolbar a {
    cursor: pointer;
}

.code-toolbar > .toolbar button {
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    line-height: normal;
    overflow: visible;
    padding: 0;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    cursor: pointer;
}

.code-toolbar > .toolbar a,
.code-toolbar > .toolbar button,
.code-toolbar > .toolbar span {
    color: #f8f8f2;
    font-size: 0.8em;
    padding: 0.3em 0.6em;
    background: rgba(68, 71, 90, 0.8);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.code-toolbar > .toolbar a:hover,
.code-toolbar > .toolbar a:focus,
.code-toolbar > .toolbar button:hover,
.code-toolbar > .toolbar button:focus,
.code-toolbar > .toolbar span:hover,
.code-toolbar > .toolbar span:focus {
    background: rgba(68, 71, 90, 1);
    text-decoration: none;
    transform: translateY(-1px);
}

/* 语言标签 */
.code-language {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 121, 198, 0.8);
    color: #282a36;
    padding: 0.2em 0.6em;
    font-size: 0.75em;
    border-radius: 0 8px 0 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 代码折叠 */
.code-collapse {
    position: absolute;
    top: 0.5em;
    left: 0.5em;
    background: rgba(68, 71, 90, 0.8);
    color: #f8f8f2;
    border: none;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.7em;
    transition: all 0.2s ease;
}

.code-collapse:hover {
    background: rgba(68, 71, 90, 1);
}

.code-collapsed pre {
    max-height: 3em;
    overflow: hidden;
}

/* 差异高亮 */
.token.deleted {
    background-color: rgba(255, 0, 0, 0.2);
    color: #ff5555;
}

.token.inserted {
    background-color: rgba(0, 255, 0, 0.2);
    color: #50fa7b;
}

/* 匹配括号高亮 */
.rainbow-braces .token.punctuation.brace-level-1,
.rainbow-braces .token.punctuation.brace-level-5,
.rainbow-braces .token.punctuation.brace-level-9 {
    color: #ff79c6;
}

.rainbow-braces .token.punctuation.brace-level-2,
.rainbow-braces .token.punctuation.brace-level-6,
.rainbow-braces .token.punctuation.brace-level-10 {
    color: #8be9fd;
}

.rainbow-braces .token.punctuation.brace-level-3,
.rainbow-braces .token.punctuation.brace-level-7,
.rainbow-braces .token.punctuation.brace-level-11 {
    color: #50fa7b;
}

.rainbow-braces .token.punctuation.brace-level-4,
.rainbow-braces .token.punctuation.brace-level-8,
.rainbow-braces .token.punctuation.brace-level-12 {
    color: #f1fa8c;
}

/* 浅色主题 */
.light-theme code[class*="language-"],
.light-theme pre[class*="language-"] {
    color: #383a42;
    background: #fafafa;
    text-shadow: none;
}

.light-theme pre[class*="language-"] {
    background: #fafafa;
    border: 1px solid #e1e4e8;
}

.light-theme .token.comment,
.light-theme .token.prolog,
.light-theme .token.doctype,
.light-theme .token.cdata {
    color: #a0a1a7;
}

.light-theme .token.punctuation {
    color: #383a42;
}

.light-theme .token.property,
.light-theme .token.tag,
.light-theme .token.boolean,
.light-theme .token.number,
.light-theme .token.constant,
.light-theme .token.symbol,
.light-theme .token.deleted {
    color: #e45649;
}

.light-theme .token.selector,
.light-theme .token.attr-name,
.light-theme .token.string,
.light-theme .token.char,
.light-theme .token.builtin,
.light-theme .token.inserted {
    color: #50a14f;
}

.light-theme .token.operator,
.light-theme .token.entity,
.light-theme .token.url,
.light-theme .language-css .token.string,
.light-theme .style .token.string {
    color: #0184bc;
}

.light-theme .token.atrule,
.light-theme .token.attr-value,
.light-theme .token.keyword {
    color: #a626a4;
}

.light-theme .token.function,
.light-theme .token.class-name {
    color: #c18401;
}

/* 滚动条样式 */
pre[class*="language-"]::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

pre[class*="language-"]::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

pre[class*="language-"]::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

pre[class*="language-"]::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 响应式设计 */
@media (max-width: 768px) {
    code[class*="language-"],
    pre[class*="language-"] {
        font-size: 13px;
    }
    
    pre[class*="language-"] {
        padding: 0.8em;
        margin: 0.5em -1rem;
        border-radius: 0;
    }
    
    .line-numbers .line-numbers-rows {
        left: -2.8em;
        width: 2em;
    }
    
    pre[class*="language-"].line-numbers {
        padding-left: 2.8em;
    }
    
    .code-toolbar > .toolbar {
        position: static;
        opacity: 1;
        margin-top: 0.5em;
        text-align: right;
    }
    
    .code-language {
        position: static;
        display: inline-block;
        margin-bottom: 0.5em;
        border-radius: 4px;
    }
}

@media (max-width: 480px) {
    code[class*="language-"],
    pre[class*="language-"] {
        font-size: 12px;
    }
    
    pre[class*="language-"] {
        padding: 0.6em;
    }
}

/* 打印样式 */
@media print {
    code[class*="language-"],
    pre[class*="language-"] {
        text-shadow: none;
        color: #000;
        background: #fff;
        border: 1px solid #ccc;
    }
    
    .code-toolbar > .toolbar {
        display: none;
    }
    
    .code-language {
        display: none;
    }
}

/* 可访问性增强 */
@media (prefers-reduced-motion: reduce) {
    .code-toolbar > .toolbar,
    .code-toolbar > .toolbar a,
    .code-toolbar > .toolbar button,
    .code-toolbar > .toolbar span {
        transition: none;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    code[class*="language-"],
    pre[class*="language-"] {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .token.comment,
    .token.prolog,
    .token.doctype,
    .token.cdata {
        color: #ccc;
    }
}