/* ============================================================
   deepcat v7.9.41 代码块重构样式
   目标：紧凑、整齐、深浅色双主题、兼容旧缓存残留的 <br> 污染
   ============================================================ */

/* 1) 安全网：屏蔽旧版本（缓存残留 JS）在 header/按钮里注入的 <br> */
.message-bubble .code-block-header br,
.message-bubble .code-copy-btn br {
    display: none !important;
}

/* 2) 头部紧凑化：固定一行高度，语言标签单行省略，复制按钮不换行不拉伸 */
.message-bubble .code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 38px;
    min-height: 38px;
    max-height: 38px;
    padding: 0 10px 0 14px;
    box-sizing: border-box;
    gap: 10px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color, #d0d7de);
}

.message-bubble .code-language {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 38px;
    font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
    text-transform: lowercase;
    font-weight: 600;
}

.message-bubble .code-copy-btn {
    flex: 0 0 auto;
    height: 26px;
    min-height: 26px;
    max-height: 26px;
    padding: 0 10px;
    margin: 0;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    line-height: 1;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.message-bubble .code-copy-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.message-bubble .code-copy-btn.copied {
    background: #dcfce7;
    border-color: #86efac;
    color: #16a34a;
}

/* 3) 代码区域：紧凑行高、横向滚动、移动端细滚动条 */
.message-bubble .code-block-wrapper {
    margin: 1em 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color, #d0d7de);
    background: #f6f8fa;
}

.message-bubble .code-block-wrapper pre {
    margin: 0;
    padding: 14px 16px;
    background: #f6f8fa;
    border: none;
    border-radius: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.message-bubble .code-block-wrapper pre code {
    background: none !important;
    padding: 0 !important;
    font-size: 13.5px;
    line-height: 1.65;
    font-family: "SF Mono", Monaco, Menlo, Consolas, "Courier New", monospace;
    tab-size: 4;
    font-variant-ligatures: none;
    word-break: normal;
    white-space: pre;
}

/* 4) 深色模式：整体统一猫薄荷深色系 */
[data-theme="dark"] .message-bubble .code-block-wrapper {
    background: #16161e;
    border-color: #313244;
}

[data-theme="dark"] .message-bubble .code-block-header {
    background: #1e1e2e;
    border-bottom-color: #313244;
}

[data-theme="dark"] .message-bubble .code-language {
    color: #a6adc8;
}

[data-theme="dark"] .message-bubble .code-copy-btn {
    background: #313244;
    border: 1px solid #45475a;
    color: #cdd6f4;
}

[data-theme="dark"] .message-bubble .code-copy-btn:hover {
    background: #45475a;
    border-color: #585b70;
    color: #f5f5f9;
}

[data-theme="dark"] .message-bubble .code-copy-btn.copied {
    background: #1e3a2f;
    border-color: #2f6b4f;
    color: #7ee2a8;
}

[data-theme="dark"] .message-bubble .code-block-wrapper pre {
    background: #16161e;
}

[data-theme="dark"] .message-bubble .code-block-wrapper pre code {
    color: #cdd6f4;
}

/* 5) 移动端更紧凑 */
@media (max-width: 480px) {
    .message-bubble .code-block-header {
        padding: 0 8px 0 12px;
    }
    .message-bubble .code-block-wrapper pre {
        padding: 12px;
    }
    .message-bubble .code-block-wrapper pre code {
        font-size: 12.5px;
        line-height: 1.6;
    }
}
