/* =============================================================================
 * 代码块底色与复制按钮
 * 1) 题面（IDE 题面区）与提交记录页：代码块底色 #f2f3f4
 * 2) 复制按钮：绝对定位在右上角，白色描边胶囊（与题面渲染一致），不占文档流
 * 3) 题解区：只统一复制按钮，不动代码块底色（codenote 渲染有自己的配色）
 * ============================================================================= */

/* ── 题面（ZhContent 等，排除题解 / AI 分析） ─────────────────────────── */
#problemIdeProblemContent .problem_content:not(#content-textSol):not(#content-aiAnalysis) pre,
#problemIdeProblemContent .problem_content:not(#content-textSol):not(#content-aiAnalysis) .code-toolbar pre,
#problemIdeProblemContent .problem_content:not(#content-textSol):not(#content-aiAnalysis) .syntax-hl {
    background: #f2f3f4 !important;
    border-radius: 8px;
}

.theme--dark #problemIdeProblemContent .problem_content:not(#content-textSol):not(#content-aiAnalysis) pre,
.theme--dark #problemIdeProblemContent .problem_content:not(#content-textSol):not(#content-aiAnalysis) .code-toolbar pre {
    background: #23262E !important;
}

/* ── 提交详情（IDE 左侧 submitDetail 面板） ──────────────────────────── */
#content-submitDetail pre,
#content-submitDetail .code-toolbar pre {
    background: #f2f3f4 !important;
    border-radius: 8px;
}

.theme--dark #content-submitDetail pre,
.theme--dark #content-submitDetail .code-toolbar pre {
    background: #23262E !important;
}

/* ── 提交记录页 ─────────────────────────────────────────────────────── */
html.page--record_detail .code-toolbar pre,
html.page--record_detail .section__body pre {
    background: #f2f3f4 !important;
    border-radius: 8px;
}

.theme--dark.page--record_detail .code-toolbar pre,
.theme--dark.page--record_detail .section__body pre {
    background: #23262E !important;
}

/* ── 复制按钮：统一成题面同款胶囊，绝对定位在右上角 ─────────────────── */
html.page--record_detail .code-toolbar,
#content-submitDetail .code-toolbar {
    position: relative;
}

html.page--record_detail .code-toolbar > .toolbar,
#content-submitDetail .code-toolbar > .toolbar {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 5;
    display: flex;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    opacity: 1 !important;
}

html.page--record_detail .code-toolbar .toolbar-item,
#content-submitDetail .code-toolbar .toolbar-item {
    display: flex;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

html.page--record_detail .code-toolbar .toolbar-item > a,
#content-submitDetail .code-toolbar .toolbar-item > a {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 56px;
    height: 26px;
    margin: 0 !important;
    padding: 0 12px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    background: #fff !important;
    color: #111827 !important;
    font-size: 0 !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

html.page--record_detail .code-toolbar .toolbar-item > a::after,
#content-submitDetail .code-toolbar .toolbar-item > a::after {
    content: "复制";
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: #111827;
}

html.page--record_detail .code-toolbar .toolbar-item > a:hover,
#content-submitDetail .code-toolbar .toolbar-item > a:hover {
    background: #f5f7fa !important;
    border-color: #9ca3af !important;
}

.theme--dark.page--record_detail .code-toolbar .toolbar-item > a,
.theme--dark #content-submitDetail .code-toolbar .toolbar-item > a {
    background: #1C1E24 !important;
    border-color: rgba(255, 255, 255, .18) !important;
    box-shadow: none;
}

.theme--dark.page--record_detail .code-toolbar .toolbar-item > a::after,
.theme--dark #content-submitDetail .code-toolbar .toolbar-item > a::after {
    color: #F2F3F5;
}

/* ── 题解区（仅「未开启 codenote 渲染」时介入） ────────────────────────
 * 开启 codenote 渲染时 #content-textSol 会带 .codenote-textsol-body，
 * 那一套配色与复制按钮由 codenote 自己负责，这里不碰。
 * 未开启时：代码块底色保持原样，只把 Prism 的 Copy 换成题面同款胶囊。
 * ─────────────────────────────────────────────────────────────────── */
#content-textSol:not(.codenote-textsol-body) .code-toolbar {
    position: relative;
}

#content-textSol:not(.codenote-textsol-body) .code-toolbar > .toolbar {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 5;
    display: flex;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    opacity: 1 !important;
}

#content-textSol:not(.codenote-textsol-body) .code-toolbar .toolbar-item {
    display: flex;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

#content-textSol:not(.codenote-textsol-body) .code-toolbar .toolbar-item > a {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 56px;
    height: 26px;
    margin: 0 !important;
    padding: 0 12px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    background: #fff !important;
    color: #111827 !important;
    font-size: 0 !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

#content-textSol:not(.codenote-textsol-body) .code-toolbar .toolbar-item > a::after {
    content: "复制";
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: #111827;
}

#content-textSol:not(.codenote-textsol-body) .code-toolbar .toolbar-item > a:hover {
    background: #f5f7fa !important;
    border-color: #9ca3af !important;
}

.theme--dark #content-textSol:not(.codenote-textsol-body) .code-toolbar .toolbar-item > a {
    background: #1C1E24 !important;
    border-color: rgba(255, 255, 255, .18) !important;
    box-shadow: none;
}

.theme--dark #content-textSol:not(.codenote-textsol-body) .code-toolbar .toolbar-item > a::after {
    color: #F2F3F5;
}

/* ── codenote 渲染的官方题解：修正行号代码块的左侧缩进 ──────────────────
 * Prism 主题里有 pre[class*="language-"].line-numbers { padding-left: 3.8em }，
 * 而 codenote 自己又把 3.8em 加在 code 上（行号槽是绝对定位的），
 * 两边叠加后代码正文会离左边界约 100px。这里把 pre 上的那份清掉。
 * 只作用于 codenote 渲染的官方题解容器，不影响普通 markdown 题解。
 * ─────────────────────────────────────────────────────────────────── */
#content-textSol.codenote-textsol-body pre.line-numbers,
#content-textSol.codenote-textsol-body pre.line-numbers[class*="language-"],
#content-textSol.codenote-textsol-body pre.code-panel.line-numbers {
    padding: 0 !important;
}

/* 行号与代码的上下内边距一并去掉，让代码顶到边框 */
#content-textSol.codenote-textsol-body pre.line-numbers code,
#content-textSol.codenote-textsol-body pre.code-panel code {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

#content-textSol.codenote-textsol-body .line-numbers .line-numbers-rows {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* ── 未开启 codenote 渲染的题解：代码块底色 #f2f3f4 ─────────────────── */
#content-textSol:not(.codenote-textsol-body) pre,
#content-textSol:not(.codenote-textsol-body) pre.syntax-hl,
#content-textSol:not(.codenote-textsol-body) .code-toolbar pre {
    background: #f2f3f4 !important;
    border-radius: 8px;
}

.theme--dark #content-textSol:not(.codenote-textsol-body) pre,
.theme--dark #content-textSol:not(.codenote-textsol-body) pre.syntax-hl,
.theme--dark #content-textSol:not(.codenote-textsol-body) .code-toolbar pre {
    background: #23262E !important;
}
