/**
 * Prism.js Tomorrow Night 主题（适配暗色模式）
 * 针对 ITPON Docs 定制
 */

code[class*="language-"],
pre[class*="language-"] {
    color: #ccc;
    background: none;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
    font-size: 14px;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    word-wrap: normal;
    line-height: 1.6;
    tab-size: 4;
    hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
    padding: 16px;
    margin: 24px 0;
    overflow: auto;
    border-radius: 8px;
    background: #1e1e1e;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--primary-color);
}

/* 代码块带标题 */
.code-toolbar {
    position: relative;
    margin: 24px 0;
}

.code-toolbar > .toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.code-toolbar:hover > .toolbar {
    opacity: 1;
}

.code-toolbar > .toolbar button {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.code-toolbar > .toolbar button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Token 颜色 */
.token.comment,
.token.block-comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #999;
}

.token.punctuation {
    color: #ccc;
}

.token.tag,
.token.attr-name,
.token.namespace,
.token.deleted {
    color: #e2777a;
}

.token.function-name {
    color: #6196cc;
}

.token.boolean,
.token.number,
.token.function {
    color: #f08d49;
}

.token.property,
.token.class-name,
.token.constant,
.token.symbol {
    color: #f8c555;
}

.token.selector,
.token.important,
.token.atrule,
.token.keyword,
.token.builtin {
    color: #cc99cd;
}

.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.variable {
    color: #7ec699;
}

.token.operator,
.token.entity,
.token.url {
    color: #67cdcc;
}

.token.important,
.token.bold {
    font-weight: bold;
}

.token.italic {
    font-style: italic;
}

.token.entity {
    cursor: help;
}

.token.inserted {
    color: green;
}

/* 行号 */
.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 #999;
    user-select: none;
}

.line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
}

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: #999;
    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(153, 122, 102, 0.08);
    background: linear-gradient(to right, rgba(153, 122, 102, 0.1) 70%, rgba(153, 122, 102, 0));
    pointer-events: none;
    line-height: inherit;
    white-space: pre;
}

/* 语言标签 */
pre[data-language]::before {
    content: attr(data-language);
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* 暗色模式适配 */
body:not(.dark-mode) code[class*="language-"],
body:not(.dark-mode) pre[class*="language-"] {
    color: #393a34;
}

body:not(.dark-mode) pre[class*="language-"] {
    background: #f5f7fa;
}

body:not(.dark-mode) .token.comment,
body:not(.dark-mode) .token.prolog,
body:not(.dark-mode) .token.doctype,
body:not(.dark-mode) .token.cdata {
    color: #999;
}

body:not(.dark-mode) .token.punctuation {
    color: #393a34;
}

body:not(.dark-mode) .token.tag,
body:not(.dark-mode) .token.attr-name,
body:not(.dark-mode) .token.namespace,
body:not(.dark-mode) .token.deleted {
    color: #e45649;
}

body:not(.dark-mode) .token.function-name {
    color: #4078f2;
}

body:not(.dark-mode) .token.boolean,
body:not(.dark-mode) .token.number,
body:not(.dark-mode) .token.function {
    color: #e45649;
}

body:not(.dark-mode) .token.property,
body:not(.dark-mode) .token.class-name,
body:not(.dark-mode) .token.constant,
body:not(.dark-mode) .token.symbol {
    color: #f5871f;
}

body:not(.dark-mode) .token.selector,
body:not(.dark-mode) .token.important,
body:not(.dark-mode) .token.atrule,
body:not(.dark-mode) .token.keyword,
body:not(.dark-mode) .token.builtin {
    color: #a626a4;
}

body:not(.dark-mode) .token.string,
body:not(.dark-mode) .token.char,
body:not(.dark-mode) .token.attr-value,
body:not(.dark-mode) .token.regex,
body:not(.dark-mode) .token.variable {
    color: #50a14f;
}

body:not(.dark-mode) .token.operator,
body:not(.dark-mode) .token.entity,
body:not(.dark-mode) .token.url {
    color: #0184bc;
}

body:not(.dark-mode) pre[data-language]::before {
    background: rgba(0, 0, 0, 0.1);
    color: #393a34;
}
