/* /static/css/custom_chat_md.css */

/* --- 1. 修复核心问题：内容溢出和基础样式 --- */
.chat-message.bot-message {
    /* 允许长单词或URL换行 */
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* --- 2. 为 Markdown 生成的 HTML 标签添加样式 --- */

/* 对 bot 消息内的所有内容生效 */
.chat-message.bot-message {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #e0e0e0; /* 适用于深色主题的文字颜色 */
}

/* 段落 */
.chat-message.bot-message p {
    margin-top: 0;
}

/* 标题 (h1, h2, h3) */
.chat-message.bot-message h1,
.chat-message.bot-message h2,
.chat-message.bot-message h3,
.chat-message.bot-message h4,
.chat-message.bot-message h5,
.chat-message.bot-message h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    border-bottom: 1px solid #444; /* 给标题加个下划线，更清晰 */
    padding-bottom: .3em;
}

.chat-message.bot-message h2 {
    font-size: 1.5em;
}

.chat-message.bot-message h3 {
    font-size: 1.25em;
}

/* 列表 (ul, ol) */
.chat-message.bot-message ul,
.chat-message.bot-message ol {
    padding-left: 2em; /* 【已修改】恢复列表的内边距，使其有缩进效果 */
    margin-bottom: 16px;
}

.chat-message.bot-message li {
    margin-bottom: 0.5em;
}

/* 加粗 */
.chat-message.bot-message strong {
    font-weight: 600;
}

/* 引用 */
.chat-message.bot-message blockquote {
    margin: 0 0 16px 0;
    padding: 0 1em;
    color: #999;
    border-left: .25em solid #555;
}

/* 水平线 (---) */
.chat-message.bot-message hr {
    height: .25em;
    padding: 0;
    margin: 24px 0;
    background-color: #555;
    border: 0;
}

/* --- 3. 代码块样式 (非常重要) --- */

/* 行内代码 `code` */
.chat-message.bot-message code {
    padding: .2em .4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(110,118,129,0.4);
    border-radius: 6px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

/* 代码块 ```code``` */
.chat-message.bot-message pre {
    padding: 16px;
    overflow: auto; /* 如果代码太长，显示滚动条 */
    font-size: 85%;
    line-height: 1.45;
    background-color: #161b22; /* 深色代码块背景 */
    border-radius: 6px;
    margin-bottom: 16px;
    white-space: pre-wrap; /* 允许代码块内的长行换行 */
}

.chat-message.bot-message pre code {
    display: inline;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    word-wrap: normal;
    background-color: transparent;
    border: 0;
}

/* --- 4. 超链接样式 (新增) --- */

/* 超链接 a */
.chat-message.bot-message a {
    color: #90caf9; /* 一个在深色主题上易于阅读的蓝色 */
    text-decoration: underline; /* 添加下划线，更明确地表示是链接 */
    transition: color 0.2s ease; /* 添加一个平滑的颜色过渡效果 */
}

/* 鼠标悬停在链接上时的效果 */
.chat-message.bot-message a:hover {
    color: #a9d8ff; /* 鼠标悬停时颜色变浅 */
    text-decoration: underline;
}