/* ==========================
   全局样式
   styles.css
========================== */

/* 全局设置 box-sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #f5f7f9;
    font-family: 'Segoe UI', 'Microsoft YaHei', 'Noto Sans SC', 'PingFang SC', Arial, sans-serif;
    color: #343a40;
    user-select: text;
    overflow-x: hidden;
    /* 只禁止水平滚动 */
    overflow-y: auto;
}

/* 确保图标样式与普通文本一致，覆盖 Bootstrap 默认的斜体 */
i.bi,
i[class^="bi-"] {
    font-style: normal;
}

/* 图片上传相关样式 - 从模板中提取的重复样式 */
#image-preview-container {
    transition: opacity 0.3s;
}

#clear-image-btn {
    opacity: 0.7;
    transition: opacity 0.2s;
}

#clear-image-btn:hover {
    opacity: 1;
}


/* 仅登录页订阅区块玻璃感（bg-white 已去掉或用 !important 覆盖） */
.login-page .subscription-info {
    background-color: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: saturate(180%) blur(8px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05) !important;
}

/* 登录页标题渐变 & 下划强调 */
.page-header h2 {
    font-family: 'Segoe UI', 'Microsoft YaHei', 'Noto Sans SC', 'PingFang SC', Arial, sans-serif;
    font-weight: 700;
    font-size: 2rem;
    /* 略微放大 */
    background: linear-gradient(90deg, #667eea, #764ba2);
    background-clip: text;
    /* Safari/Chrome 需要前缀 */
    -webkit-background-clip: text;
    /* 使文字透明，从而展示背景渐变 */
    -webkit-text-fill-color: transparent;
    position: relative;
    margin-bottom: 0.5rem;
}


h1 {
    font-size: 1.4rem;
    /* 根据需求调整字体大小 */
    margin: 0.2em 0;
    /* 根据需要设置上下间距 */
}

h2 {
    font-size: 1.3rem;
}

h3 {
    font-size: 1.2rem;
}

h4 {
    font-size: 1.1rem;
}

/* =========================
   容器样式
========================== */
.container-fluid {
    padding: 2px;
    /* 去掉多余内边距 */
    background-color: #fff;
    border: none;
    /* 如不需要边框，可去掉 */
    border-radius: 0.3rem;
    box-shadow: none;
    /* 如不需要阴影，也可去掉 */
    margin: 0;
    /* 去掉自动居中 */
    max-width: none;
    /* 取消1200px限制 */
    flex: 1;
    /* 占据剩余空间 */
    display: flex;
    /* 使用 flex 布局 */
    flex-direction: column;
    /* 垂直方向 */
    min-height: 0;
    /* 关键 */
    margin-bottom: 0;
}

/* ==========================
   表单样式
========================== */
.form-control {
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    padding: 0.2rem 0.4rem;
    resize: none;
    overflow-y: auto;
    max-height: 300px;
    min-height: 38px;
    flex: 1;
    height: auto;
}

.chat-textarea,
.auto-resize-input {
    max-height: 60vh;
}

/* 输入框滚动条强制显示样式 */
#chat-input,
.chat-textarea {
    overflow-y: auto !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1) !important;
}

/* Webkit浏览器滚动条样式 */
#chat-input::-webkit-scrollbar,
.chat-textarea::-webkit-scrollbar {
    width: 8px !important;
}

#chat-input::-webkit-scrollbar-thumb,
.chat-textarea::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.5) !important;
    border-radius: 4px !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#chat-input::-webkit-scrollbar-thumb:hover,
.chat-textarea::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.7) !important;
}

#chat-input::-webkit-scrollbar-track,
.chat-textarea::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.1) !important;
    border-radius: 4px !important;
}

.form-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}

/* 下拉菜单完整显示样式 */
.form-select {
    width: 100%;
    white-space: normal;
    text-overflow: clip;
}

.form-select option {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    padding: 5px;
}

optgroup {
    font-weight: bold;
}

/* 登录容器居中样式 */
.login-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 30px;
    /* 保持内边距 */
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    min-height: 100vh;
    /* 已有的视口高度设置 */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* 调整输入框大小 */
.login-container .form-control {
    padding: 10px 15px;
    /* 增加输入框内边距 */
    font-size: 16px;
    /* 稍微增大字体 */
    height: auto;
    /* 确保高度适应内容 */
}

/* 调整按钮大小 */
.login-container .btn {
    padding: 10px 20px;
    /* 增加按钮内边距 */
    font-size: 16px;
    /* 增大按钮文字 */
    height: 45px;
    /* 增加按钮高度 */
}

/* 确保标题大小合适 */
.login-container h2 {
    font-size: 28px;
    /* 增大标题字体 */
    margin-bottom: 25px;
    /* 底部间距 */
}

/* 在较小屏幕上仍然保持良好的响应式布局 */
@media (max-width: 767px) {
    .login-container {
        max-width: 95%;
        /* 在小屏幕上占据更多宽度 */
        padding: 20px;
        /* 减少内边距以适应小屏幕 */
        min-height: 90vh;
        /* 在移动设备上稍微减少高度 */
    }
}

/* ==========================
   按钮样式
========================== */
.btn {
    transition: background-color 0.3s ease;
    margin: 2px 0;
    padding: 8px 14px;
    border-radius: 5px;
    line-height: 1.4;
    display: inline-flex;
    /* 使用flex布局 */
    align-items: center;
    /* 垂直居中内容 */
    justify-content: center;
    /* 水平居中内容 */
    margin: 0;
    /* 移除外边距确保对齐 */
}


/* 合并按钮的通用样式 */
.btn-primary,
.btn-secondary,
.btn-danger {
    color: white;
    transition: background-color 0.3s ease;
}

/* 只保留不同的属性 */
.btn-primary {
    background-color: #5A9EC8;
    border-color: #5A9EC8;
}

/* 登录按钮组样式优化 */
.btn-secondary {
    background-color: #adc0e6;
    display: inline-flex;
    /* 使用flex布局 */
    align-items: center;
    /* 垂直居中内容 */
    justify-content: center;
    /* 水平居中内容 */
}

/* 确保按钮链接与普通按钮一致 */
a.btn {
    text-decoration: none;
    box-sizing: border-box;
    /* 确保padding计入总高度 */
}

/* 专门针对忘记密码按钮的样式 */
a.btn-secondary {
    text-decoration: none;
    /* 移除下划线 */
    height: auto;
    /* 高度自适应内容 */
}

/* 登录按钮容器样式 */
.d-flex.gap-2 {
    display: flex;
    align-items: center;
    /* 垂直居中对齐所有子元素 */
    gap: 10px;
    /* 调整间距 */
}

/* 确保所有按钮高度一致 */
.d-flex .btn {
    height: 38px;
    /* 统一按钮高度 */
}

.btn-danger {
    background-color: #90b5dd;
}

/* 模态框操作按钮统一样式 */
.modal-action-btn {
    min-width: 100px;
}

/* 图标按钮样式 */
.btn-icon {
    background-color: transparent;
    border: none;
    color: #6c757d;
    font-size: 1.2rem;
    padding: 5px;
    /* 稍微减少按钮的内边距，从6px减少到5px */
    cursor: pointer;
    margin-bottom: 0;
    /* 移除底部间距 */
    /* 确保按钮即使没有图标也有足够的点击区域 */
    min-width: 36px;
    /* 增加最小宽度，从32px增加到36px */
    min-height: 36px;
    /* 增加最小高度，从32px增加到36px */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    /* 添加图标和文字之间的间距 */
}

/* 专门控制新文件夹按钮的图标和文字间距 */
#new-folder-btn {
    gap: 2px;
}

.btn-icon:hover {
    color: #343a40;
}

/* 处理 flex 布局的按钮 */
.sidebar-buttons {
    display: flex;
    align-items: center;
    gap: 2px;
    /* 进一步减少按钮之间的间距，从4px减少到2px */
}

/* 添加文本替代图标样式 */
.btn-icon .btn-text-fallback {
    display: none;
    /* 默认隐藏文本 */
    font-size: 0.75rem;
    font-weight: bold;
    white-space: nowrap;
    /* 防止文本换行 */
}

/* 当图标加载失败时显示文本 */
.btn-icon .bi:not(.bi-*),
.btn-icon i:empty {
    display: none;
}

.btn-icon:not(:has(i:not(:empty))) .btn-text-fallback {
    display: inline;
}

/* 显示侧边栏的按钮样式 */
.show-sidebar-btn {
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    border: none;
    color: #6c757d;
    font-size: 1.5rem;
    padding: 0.2rem;
    cursor: pointer;
    position: sticky;
    /* 使用粘性定位 */
    top: 20px;
    margin-left: 10px;
    /* 使用外边距代替定位 */
    align-self: flex-start;
    /* 在Flex容器中靠上对齐 */
    z-index: 1000;
    display: none;
    /* 初始隐藏 */
}

.show-sidebar-btn:hover {
    color: #403434;
    transform: scale(1.1);
    /* 鼠标悬停时稍微放大 */
}

/* ==========================
   历史项目与侧边栏
========================== */
/* 调整历史项目条目内边距，使高度更紧凑 */
#conversation-list .list-group-item {
    padding: 1px 8px;
    /* 适中内边距 */
    margin-bottom: 1px;
    display: block;
    /* 占满整行宽度 */
}

/* 文件夹内会话条目与会话列表保持一致 */
#folder-tree .folder-conversations .list-group-item {
    padding: 1px 8px;
    margin-bottom: 1px;
    display: block;
}

/* 文件夹名称指针样式 */
.folder-name {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 80px);
    /* 为文件夹操作按钮留出空间 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.folder-toggle {
    cursor: pointer;
}

/* Folder list items */
.folder-item:not(.active) {
    background-color: #f8f9fa;
    border-left: 3px solid #dee2e6;
}

/* 会话标题过长时截断显示 */
.conversation-title {
    display: inline-block;
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 60px);
    /* 动态计算最大宽度，为下拉菜单留出空间 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 0.25rem;
    cursor: pointer;
    transition: max-width 0.1s ease;
}

/* 当侧边栏宽度增加时，项目标题可以显示更多内容 */
.chat-sidebar[style*="width: 280px"] .conversation-title,
.chat-sidebar[style*="width: 300px"] .conversation-title,
.chat-sidebar[style*="width: 350px"] .conversation-title,
.chat-sidebar[style*="width: 400px"] .conversation-title,
.chat-sidebar[style*="width: 450px"] .conversation-title,
.chat-sidebar[style*="width: 500px"] .conversation-title {
    max-width: calc(100% - 60px);
}

.sidebar-header {
    position: sticky;
    top: 0;
    background-color: #fff;
    padding: 2px 0;
    z-index: 100;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0;
    padding-top: 0;
}

.sidebar-title {
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.2;
}

/* ==========================
   聊天容器与布局
========================== */
.chat-layout {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    position: relative;
    height: calc(100vh - 80px);
    /* 减少高度，为标题留出更少空间，从100vh改为calc(100vh - 80px) */
}

/* 侧边栏样式 */
.chat-sidebar {
    display: flex;
    flex-direction: column;
    width: 300px;
    /* 进一步增加默认宽度，从280px增加到300px */
    min-width: 240px;
    /* 相应增加最小宽度，从220px增加到240px */
    max-width: 500px;
    /* 最大宽度 */
    height: 100%;
    /* 占满高度 */
    overflow-y: auto;
    /* 独立滚动条 */
    overflow-x: visible;
    /* 允许子菜单横向溢出 */
    border-right: 1px solid #eee;
    position: relative;
    /* 为拖拽手柄定位 */
    transition: width 0.1s ease;
    /* 平滑过渡 */
}

/* 拖拽手柄样式 */
.sidebar-resizer {
    position: absolute;
    right: -3px;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 1000;
    transition: background-color 0.2s ease;
    border-radius: 3px;
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging {
    background-color: rgba(0, 123, 255, 0.3);
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.4);
}

.sidebar-resizer::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background-color: #007bff;
    border-radius: 1px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar-resizer:hover::after,
.sidebar-resizer.dragging::after {
    opacity: 1;
}

/* 拖拽时的全局样式 */
body.resizing {
    cursor: col-resize !important;
    user-select: none !important;
}

body.resizing * {
    cursor: col-resize !important;
}

/* 侧边栏内容区域样式 */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    /* 允许子菜单横向溢出 */
    padding: 0;
    margin: 0;
}

.chat-container-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

/* 右侧内容区域样式 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    height: 100%;
    max-height: 100vh;
    /* 确保不超过视口高度 */
}

/* 输入区：固定在底部，不随消息滚动 */
.chat-input-form {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: #fff;
    border-top: 1px solid #eee;
    padding: 0.5rem;
    flex-shrink: 0;
}


#message-container,
.message-container {
    flex: 1;
    overflow-y: auto;
    /* 独立滚动条 */
    overflow-x: hidden;
    padding: 10px;
    padding-bottom: 10px !important;
    position: relative;
    z-index: 1;
    background-color: #fff;
    border-top: 1px solid #f0f0f0;
    min-height: 0;
    /* 允许收缩 */
}

/* 修复滚动条样式 - 统一定义所有滚动条 */
/* Firefox 支持 */
.chat-sidebar,
#message-container,
.message-container,
.sidebar-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
}

.chat-sidebar::-webkit-scrollbar,
#message-container::-webkit-scrollbar,
.message-container::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar {
    width: 8px;
    /* 增加宽度使其更明显 */
}

.chat-sidebar::-webkit-scrollbar-thumb,
#message-container::-webkit-scrollbar-thumb,
.message-container::-webkit-scrollbar-thumb,
.sidebar-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.5);
    /* 增加不透明度使其更明显 */
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* 添加边框 */
}

.chat-sidebar::-webkit-scrollbar-thumb:hover,
#message-container::-webkit-scrollbar-thumb:hover,
.message-container::-webkit-scrollbar-thumb:hover,
.sidebar-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.7);
    /* 悬停时更深色 */
}

.chat-sidebar::-webkit-scrollbar-track,
#message-container::-webkit-scrollbar-track,
.message-container::-webkit-scrollbar-track,
.sidebar-content::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.1);
    /* 添加轻微背景色 */
    border-radius: 4px;
}

.logout-container {
    /* 利用 margin-top:auto 把它推到底部 */
    margin-top: auto;
    flex-shrink: 0;
    border-top: 1px solid #ddd;
    background-color: #fff;
    padding: 8px 0;
}


/* ==========================
   Logout & Membership
========================== */
.logout-container {
    /* 保证底部区域不被滚动内容覆盖 */
    position: sticky;
    bottom: 0;
    z-index: 10;
    /* 保证在列表之上 */
    flex-shrink: 0;
    /* 不收缩 */
    border-top: 1px solid #ddd;
    background-color: #fff;
    /* 防止透出滚动内容 */
    padding: 6px 0;
}

.logout-container .btn {
    flex-shrink: 0;
}

/* internal系统退出按钮样式 - 浅蓝色背景，无红色边框 */
.logout-btn-internal {
    background-color: #0d6efd !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 4px;
    box-shadow: none !important;
}

.logout-btn-internal:hover {
    background-color: #0b5ed7 !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
}

.logout-btn-internal:focus,
.logout-btn-internal:active {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.logout-container .membership-type {
    margin-left: 10px;
    font-size: 0.9rem;
    color: #6c757d;
}

/* ==========================
   响应式设计
========================== */
@media (min-width: 768px) {
    .chat-layout {
        flex-direction: row;
    }

    .chat-sidebar {
        max-width: none;
        flex-shrink: 0;
        min-width: 240px;
    }

    .chat-container {
        margin-bottom: 15px;
    }
}

@media (max-width: 767.98px) {
    .chat-layout {
        flex-direction: column;
        overflow: visible;
    }

    .chat-sidebar {
        width: 100%;
        margin-bottom: 1rem;
    }

    .chat-container {
        width: 100%;
    }

    /* 让输入框和发送按钮在小屏时自动换行 */
    #chat-form .d-flex.mb-2 {
        flex-wrap: wrap;
    }

    #chat-form .d-flex.mb-2 textarea {
        flex: 1 1 100%;
        min-width: 0;
        margin-bottom: 0.5rem;
    }

    #chat-form .d-flex.mb-2 .d-flex.align-items-center {
        flex: 0 0 auto;
    }

    /* 确保输入框滚动条在移动端正确显示 */
    #chat-input,
    .chat-textarea {
        overflow-y: auto !important;
        scrollbar-width: thin !important;
        scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1) !important;
    }

    #chat-input::-webkit-scrollbar,
    .chat-textarea::-webkit-scrollbar {
        width: 6px !important;
        /* 移动端使用更细的滚动条 */
    }
}

@media (max-width: 576px) {

    .btn-primary,
    .btn-danger {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
        width: 100%;
        /* Ensures the button fills the width */
    }

    .list-group-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .chat-message {
        font-size: 0.875rem;
        padding: 4px;
    }
}

/* Utility */
.hidden {
    display: none !important;
}

.full-width {
    width: auto;
}

.mb-3 {
    margin-bottom: 1rem;
}

#toggle-sidebar-btn {
    margin-right: 10px;
}

/* Utility spacing helpers */
.no-top-margin {
    margin-top: 0 !important;
}

.no-top-padding {
    padding-top: 0 !important;
}

/* Shared spacing rules */
.chat-layout,
#message-container,
.message-container,

/* Unified list item spacing */
li,
ol li,
ul li {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    line-height: 1.3;
}

/* Elements requiring no top margin */
.bot-message h3+p,


/* 标题容器布局 */
.title-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    /* 改为居中对齐 */
    position: relative;
    width: 100%;
    margin-bottom: 0.1rem;
    /* 减少底部间距，从0.3rem改为0.1rem */
    padding: 0 20px;
    /* 左右各留20px边距 */
    min-height: 30px;
    /* 大幅减少高度，从60px改为30px */
}

/* 内部系统标题容器优化 - 减少空白 */
.title-wrapper.internal-system {
    min-height: 15px;
    /* 内部系统进一步减少高度，从20px改为15px */
    margin-bottom: 0.05rem;
    /* 减少底部间距，从0.1rem改为0.05rem */
}

/* 标题居中显示 */
h3.app-title {
    font-family: 'Segoe UI', 'Microsoft YaHei', 'Noto Sans SC', 'PingFang SC', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700 !important;
    margin: 0 !important;
    /* 移除所有外边距 */
    padding: 0.4rem 1rem !important;
    /* 大幅减少内边距，从0.8rem 1.5rem改为0.4rem 1rem */
    font-size: 1.5rem !important;
    /* 减小字体，从1.8rem改为1.5rem */
    line-height: 1.2 !important;
    /* 减小行高，从1.3改为1.2 */
    text-align: center;
    /* 移除绝对定位，改为flex布局中的自然居中 */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.5px;
    z-index: 1;
    /* 确保在背景之上 */
    animation: titleFadeIn 0.6s ease-out;
    /* 减少动画时间，从0.8s改为0.6s */
    flex: 1;
    /* 占据剩余空间，实现居中 */
}

/* 内部系统标题优化 */
.title-wrapper.internal-system h3.app-title {
    padding: 0.2rem 0.6rem !important;
    /* 内部系统大幅减少内边距，从0.3rem 0.8rem改为0.2rem 0.6rem */
    font-size: 1rem !important;
    /* 减小字体，从1.2rem改为1rem */
}

/* 内部系统页面顶部优化 */
.internal-system .container-fluid {
    padding-top: 0.3rem !important;
    /* 减少顶部内边距，从0.5rem改为0.3rem */
}

/* 内部系统聊天布局优化 */
.internal-system .chat-layout {
    margin-top: 0.2rem !important;
    /* 减少顶部外边距，从0.3rem改为0.2rem */
}

/* 内部系统消息容器优化 */
.internal-system #message-container {
    padding-top: 0.1rem !important;
    /* 减少顶部内边距，从0.2rem改为0.1rem */
}

/* 专家服务按钮样式 */
#expert-service-btn {
    position: absolute;
    /* 使用绝对定位固定在右侧 */
    right: 20px;
    /* 距离右边20px */
    top: 50%;
    /* 垂直居中 */
    transform: translateY(-50%);
    /* 精确垂直居中 */
    padding: 6px 12px;
    font-size: 0.9rem;
    height: auto;
    line-height: 1.2;
    flex-shrink: 0;
    /* 防止按钮被压缩 */
    z-index: 2;
    /* 确保在标题之上 */
}

/* 为标题添加装饰性背景 */
h3.app-title::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 100%;
    background: transparent;
    /* 移除背景色 */
    border-radius: 12px;
    z-index: -1;
    box-shadow: none;
    /* 移除阴影 */
}

/* 响应式调整 */
@media (max-width: 768px) {
    .title-wrapper {
        padding: 0 10px;
        min-height: 25px;
        /* 减少移动端高度，从50px改为25px */
    }

    h3.app-title {
        font-size: 1.2rem !important;
        /* 减小移动端字体，从1.4rem改为1.2rem */
        padding: 0.3rem 0.8rem !important;
        /* 减少移动端内边距，从0.6rem 1rem改为0.3rem 0.8rem */
    }

    h3.app-title::before {
        width: 30px;
        /* 减少装饰线宽度，从40px改为30px */
        height: 2px;
    }

    #expert-service-btn {
        padding: 0.3rem 0.6rem;
        /* 减少按钮内边距，从0.4rem 0.8rem改为0.3rem 0.6rem */
        font-size: 0.8rem;
        /* 减小按钮字体，从0.9rem改为0.8rem */
    }

    .title-wrapper.internal-system {
        min-height: 10px;
        /* 减少内部系统移动端高度，从15px改为10px */
    }

    .title-wrapper.internal-system h3.app-title {
        font-size: 0.9rem !important;
        /* 减小内部系统移动端字体，从1rem改为0.9rem */
        padding: 0.15rem 0.5rem !important;
        /* 减少内部系统移动端内边距，从0.2rem 0.6rem改为0.15rem 0.5rem */
    }
}



/* 下拉菜单 */
.dropdown-menu {
    min-width: 120px;
    padding: 0;
    font-size: 0.9rem;
}

.dropdown-submenu {
    position: relative;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
}

/* 工具菜单悬停效果 */
.tool-dropdown .tool-item:hover {
    background-color: #f1f1f1;
}

.list-group-item.active {
    background-color: #a1a4a8;
    color: #343a40;
    border-color: #ddd;
}

/* ==========================
   Toast 样式
========================== */
#toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

#toast-container .toast {
    pointer-events: auto;
}

.toast {
    margin: 0 !important;
}

/* 自定义Toast背景色 - 与响应内容保持一致 */
.toast.bg-info {
    background-color: #66b377 !important;
    border-color: #66b377 !important;
}

.toast.bg-info .toast-body {
    color: #fff !important;
}

/* 确保关闭按钮在绿色背景上可见 */
.toast.bg-info .btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* 确保danger类型的toast有正确的红色背景 */
.toast.bg-danger {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
}

.toast.bg-danger .toast-body {
    color: #fff !important;
}

/* 确保关闭按钮在红色背景上可见 */
.toast.bg-danger .btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ==========================
   Markdown / 聊天消息紧凑样式
========================== */

/* 机器人消息整体样式 */
.bot-message {
    line-height: 1.5;
    font-size: 16px;
    white-space: pre-wrap !important;
    background-color: #66b377;
    color: #fff;
    align-self: flex-start;
    /* 左对齐 */
    margin-right: auto;
    /* 自动右外边距将气泡推到左边 */
    border-top-left-radius: 0;
    /* 调整气泡形状 */
    margin-left: 0;
    text-align: left;
}

/* 紧凑标题 */
.bot-message h1,
.bot-message h2,
.bot-message h3,
.bot-message h4,
.bot-message h5,
.bot-message h6 {
    margin-top: 0.1em;
    margin-bottom: 0.1em;
    padding: 0.1em 0;
}

/* 紧凑标题后段落 */

/* 紧凑列表 */
.bot-message ul,
.bot-message ol {
    padding-left: 1em;
    margin-top: 0.1em;
    margin-bottom: 0.1em;
}

/*─────────────────────────────────────────
  修复列表项中 <p> 换行问题：
  让所有聊天消息里的 li > p 变成 inline，
  点号和文字就会在同一行
─────────────────────────────────────────*/
.message-content li>p,
.chat-message.bot-message li>p,
.chat-message.user-message li>p {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
}


.logout-button {
    border: none;
    background: #5A9EC8;
    color: #ffffff;
    font-size: 0.9rem;
    /* 添加这行来调小字号 */
}

.logout-button:hover {
    background: #f8f9fa;
    color: #333;
}

.bot-message ul li {
    list-style-type: disc !important;
    /* 无序列表使用实心圆点 */
}

.google-scholar-response .google-scholar-result-count {
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
    color: #f6fef8;
}

.google-scholar-results {
    margin: 0;
    padding-left: 1.4rem;
}

.google-scholar-item {
    margin: 0;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.google-scholar-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.google-scholar-field {
    display: block;
    margin: 0;
    line-height: 1.45;
}

.google-scholar-field+.google-scholar-field {
    margin-top: 0;
}

.google-scholar-title a {
    color: #007bff;
    font-weight: 600;
    text-decoration: none;
}

.google-scholar-title a:hover,
.google-scholar-title a:focus {
    text-decoration: underline;
    color: #e6f6eb;
}

.google-scholar-label {
    font-weight: 600;
    margin-right: 0.25rem;
}

.google-scholar-value {
    font-weight: 400;
}

.google-scholar-metrics .google-scholar-value {
    font-size: 0.95em;
}

.google-scholar-abstract .google-scholar-value {
    display: inline;
}

.bot-message ol li {
    list-style-type: decimal !important;
    /* 有序列表使用数字 */
}

/* 列表项间距调整 */
.bot-message ul li,
.bot-message ol li {
    margin-bottom: 0.1em !important;
    /* 列表项间距调整 */
}

/* 段落样式优化 */
.bot-message li p {
    margin-top: 0.1em;
    margin-bottom: 0;
    display: inline-block;
    /* 确保段落内容正确显示 */
}

/* 文本格式化 */
.bot-message em {
    font-style: italic;
}

.bot-message strong {
    font-weight: 600;
}

/* 引用块样式 */
.bot-message blockquote {
    padding: 0 0.2em;
    color: #6a737d;
    border-left: 0.25em solid #dfe2e5;
    margin: 0.1em 0;
}

/* 代码块样式 */
/* 代码块样式 - 优化可见性 */
.bot-message pre {
    background-color: rgba(0, 0, 0, 0.15) !important;
    /* 深色半透明背景 */
    border-radius: 6px;
    padding: 12px;
    overflow: auto;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 85%;
    white-space: pre;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    /* 默认白色字体 */
}

/* 确保行内代码也是白色字体，且背景协调 */
.bot-message code {
    background-color: rgba(0, 0, 0, 0.15) !important;
    color: #ffffff !important;
    /* 强制白色，覆盖默认的红色 */
    border-radius: 3px;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 85%;
    padding: 0.1em 0.3em;
}

/* 语法高亮覆盖 - 针对绿色背景优化 */
.bot-message .hljs-keyword,
.bot-message .hljs-operator,
.bot-message .hljs-selector-tag,
.bot-message .hljs-function {
    color: #ffd700 !important;
    /* 金黄色关键字 */
}

.bot-message .hljs-string,
.bot-message .hljs-attr,
.bot-message .hljs-number {
    color: #ffffff !important;
    /* 白色字符串 */
    font-weight: bold;
}

.bot-message .hljs-comment,
.bot-message .hljs-quote {
    color: #e0e0e0 !important;
    /* 浅灰注释 */
    font-style: italic;
}

.bot-message .hljs-variable,
.bot-message .hljs-template-variable,
.bot-message .hljs-tag,
.bot-message .hljs-name {
    color: #e0f7fa !important;
    /* 浅青色变量 */
}

.bot-message .hljs-built_in,
.bot-message .hljs-title,
.bot-message .hljs-literal {
    color: #ffeb3b !important;
    /* 亮黄内置对象 */
}

/* 表格样式 */
.bot-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.1em 0;
}

.bot-message table th,
.bot-message table td {
    border: 1px solid #dfe2e5;
    padding: 6px 13px;
}

.bot-message table th {
    background-color: #f6f8fa;
    font-weight: 600;
}

/* 确保列表项正确显示 */
.bot-message li {
    margin-bottom: 0;
    display: list-item;
    list-style-position: outside;
    /* 改为 outside，让编号和内容分离 */
    padding-left: 1.5em;
    /* 为编号留出空间 */
    margin-left: 0;
}

.bot-message li strong {
    font-weight: 600;
}


/* 强制段落和标题换行 */
.bot-message h1,
.bot-message h2,
.bot-message h3,
.bot-message h4,
.bot-message h5,
.bot-message h6,
.bot-message p,
.bot-message ul,
.bot-message ol,
.bot-message blockquote,
.bot-message pre {
    width: 100%;
    clear: both;
}

/* 确保水平线正确分隔内容 */
.bot-message hr {
    margin: 0 !important;
}


/* 确保引用块正确显示 */
.bot-message blockquote {
    display: block !important;
    width: 100%;
    clear: both;
}

/* 添加额外的样式来处理特殊情况 */
.bot-message br {
    display: block !important;
    content: "";
    margin-top: 0.1em;
}

/* 确保内容在页面刷新后也能正确显示 */
.chat-message.bot-message p,
.chat-message.bot-message h3,
.chat-message.bot-message hr,
.chat-message.bot-message ul,
.chat-message.bot-message ol,
.chat-message.bot-message li,
.chat-message.bot-message blockquote {
    display: block !important;
    width: 100% !important;
    clear: both !important;
    visibility: visible !important;
}


/* 强制段落显示为块级元素 - 跨浏览器兼容版本 */
.chat-message.bot-message p {
    margin: 2px 0 !important;
    /* 进一步减少段落间距，从8px改为2px */
    padding: 0 !important;
    /* 移除内边距，避免累积 */
    line-height: 1.5 !important;
    /* 统一行高 */
    display: block !important;
    /* 确保是块级元素 */
    word-wrap: break-word;
    /* 确保长文本换行 */
    text-rendering: optimizeLegibility;
    /* 优化文字渲染 */
}

/* 合并Markdown增强样式 */
.markdown-enhanced,
.markdown-content {
    display: block;
    width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: visible;
}

/* Markdown 输出为 HTML 时避免多余空行 */
.chat-message.bot-message .markdown-enhanced,
.chat-message.bot-message .markdown-content,
.chat-message.bot-message .bot-text-content,
.chat-message.bot-message .message-content {
    white-space: normal !important;
}

/* 减小所有标题间距的强力优化 */
.chat-message.bot-message h1,
.chat-message.bot-message h2,
.chat-message.bot-message h4,
.chat-message.bot-message h5,
.chat-message.bot-message h6 {
    margin-top: 0.6em !important;
    /* 增加顶部间距，改善段落分隔 */
    margin-bottom: 0.35em !important;
    /* 增加底部间距 */
    padding-top: 0 !important;
    /* 移除多余内边距 */
    padding-bottom: 0 !important;
    /* 移除多余内边距 */
    line-height: 1.5 !important;
    /* 统一行高 */
}

/* 强制减小标题和段落之间的间距 */
.chat-message.bot-message h1+p,
.chat-message.bot-message h2+p,
.chat-message.bot-message h3+p,
.chat-message.bot-message h4+p,
.chat-message.bot-message h5+p,
.chat-message.bot-message h6+p {
    margin-top: 0.25rem !important;
    /* 增加标题后段落的顶部间距 */
    padding-top: 0 !important;
    /* 移除顶部内边距 */
}

/* 强制减小标题和列表之间的间距 */
.chat-message.bot-message h1+ul,
.chat-message.bot-message h1+ol,
.chat-message.bot-message h2+ul,
.chat-message.bot-message h2+ol,
.chat-message.bot-message h3+ul,
.chat-message.bot-message h3+ol,
.chat-message.bot-message h4+ul,
.chat-message.bot-message h4+ol,
.chat-message.bot-message h5+ul,
.chat-message.bot-message h5+ol,
.chat-message.bot-message h6+ul,
.chat-message.bot-message h6+ol {
    margin-top: 0.25rem !important;
    /* 增加标题后列表的顶部间距 */
    padding-top: 0 !important;
}

/* 强制减小段落和列表之间的间距 */
.chat-message.bot-message p+ul,
.chat-message.bot-message p+ol {
    margin-top: 0.25rem !important;
    /* 增加段落后列表的顶部间距 */
    padding-top: 0 !important;
}

/* 标题内部行距紧凑 */
.chat-message.bot-message h3 strong {
    display: inline !important;
    /* 确保内容紧凑显示 */
    line-height: 1.5 !important;
    /* 减小行高 */
}

/* 移除标题底部边框或减少其占用空间 */
.chat-message.bot-message h3 {
    border-bottom: none !important;
    /* 移除底部边框 */
    /* 或者使用更小的边框 */
    /* border-bottom: 1px solid #eaecef !important; */
    padding-bottom: 0 !important;
    /* 移除底部内边距 */
    margin-bottom: 0.35em !important;
    /* 增加底部外边距 */
}

/* 进一步减小标题大小 */
.chat-message.bot-message .compact-heading {
    font-size: 0.95rem !important;
    /* 再稍微减小字体 */
    opacity: 0.9 !important;
    /* 轻微降低不透明度 */
    color: rgba(255, 255, 255, 0.95) !important;
    /* 轻微降低文字亮度 */
    text-transform: none !important;
    /* 确保不使用全大写 */
    letter-spacing: normal !important;
    /* 正常字母间距 */
}

/* 优化编号与内容的区分 */
.chat-message.bot-message .compact-heading:before {
    content: attr(data-number);
    font-weight: bold;
    margin-right: 0.2em;
    opacity: 0.8;
}

/* 移除原有的编号，由:before伪元素替代 */
.chat-message.bot-message .compact-heading {
    position: relative;
}

.markdown-content p {
    margin-bottom: 0.6rem;
    /* 增加段落的下边距 */
}

/* Markdown 内容内部元素的间距 */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin-top: 0.6rem;
    margin-bottom: 0.35rem;
}

.markdown-content ul,
.markdown-content ol {
    padding-left: 1.2rem;
    margin-bottom: 0.45rem;
}

/* 聊天消息通用样式 */
.chat-message {
    display: block;
    padding: 12px 16px;
    /* 增加内边距，从6px 10px改为12px 16px */
    margin: 3px 0 10px 0;
    border-radius: 10px;
    max-width: 100%;
    word-wrap: break-word;
    position: relative;
    line-height: 1.5;
    overflow: visible;
    white-space: normal;
}

.message-content {
    white-space: pre-wrap;
    /* 保留换行符，又能自动折行 */
    word-break: break-word;
    /* 单词过长时换行 */
    box-sizing: border-box;
    /* padding 计算到宽度里 */
    /* 强制去除可能导致高度问题的样式 */
    min-height: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

.bot-text-content {
    white-space: pre-wrap;
    /* 确保助手文本保留换行符 */
    line-height: 1.6;
    /* 统一行高，提高可读性 */
    word-wrap: break-word;
    /* 确保长单词换行 */
}

/* 助手消息中的粗体内容：为标题留出视觉间距 - 跨浏览器兼容版本 */
.message-content .bot-text-content strong,
.message-content .bot-text-content b {
    display: inline;
    /* 使用 inline 避免跨浏览器渲染差异 */
    margin-right: 0.5em;
    /* 增加右边距，使用相对单位但增加数值 */
    line-height: inherit;
    /* 继承父元素行高，保持一致性 */
    font-weight: 600;
    /* 明确设置字重 */
    vertical-align: baseline;
    /* 确保基线对齐一致 */
}

/* 确保段落中的strong标签（作为标题）有足够的间距 */
.message-content .bot-text-content p>strong:first-child,
.message-content .bot-text-content p>b:first-child {
    display: inline;
    /* 保持 inline，避免换行问题 */
    margin-right: 0.6em;
    /* 增加右边距，确保标题和内容有间距 */
    font-weight: 600;
}

/* 减少包含strong标签作为标题的段落与下一个段落之间的间距（兼容不支持:has的浏览器） */
.message-content .bot-text-content p>strong:first-child~*,
.message-content .bot-text-content p>b:first-child~* {
    display: inline;
}

/* 确保段落有足够的上下间距 - 使用固定像素值提高跨浏览器一致性 */
.message-content .bot-text-content p {
    margin: 8px 0 !important;
    /* 使用固定像素值，确保跨浏览器一致性 */
    padding: 0 !important;
    line-height: 1.6 !important;
    /* 统一行高 */
    display: block !important;
    /* 确保段落是块级元素 */
    word-wrap: break-word !important;
    /* 确保长文本换行 */
    text-rendering: optimizeLegibility;
    /* 优化文字渲染，提高跨浏览器一致性 */
    -webkit-font-smoothing: antialiased;
    /* Mac Safari/Chrome 字体平滑 */
    -moz-osx-font-smoothing: grayscale;
    /* Mac Firefox 字体平滑 */
}

/* 减少包含strong标签作为标题的段落的底边距（通过JavaScript动态添加类名） */
.message-content .bot-text-content p.title-paragraph {
    margin-bottom: 2px !important;
    /* 减少标题段落的底边距 */
}

/* 减少标题段落后紧跟段落的顶部间距 */
.message-content .bot-text-content p.title-paragraph+p {
    margin-top: 2px !important;
    /* 减少标题后段落的顶部间距 */
}

/* 确保strong标签后的内容有明确的视觉间距 */
.message-content .bot-text-content p>strong:first-child+* {
    display: inline;
}

/* 换行符样式 - 跨浏览器兼容 */
.message-content br:not(.pubmed-results .pubmed-item br) {
    display: block !important;
    /* 改为 block，确保换行生效 */
    content: "";
    margin: 4px 0 !important;
    /* 使用固定像素值，确保间距一致 */
    padding: 0;
    line-height: 1.6;
    height: 0;
    /* 避免额外高度 */
    overflow: hidden;
    /* 隐藏溢出内容 */
}

/* 用户消息：右侧显示，蓝色背景 (#5A9EC8) 和白色字体 */
.chat-message.user-message {
    background-color: #5A9EC8;
    color: #fff;
    align-self: flex-end;
    /* 右对齐 */
    text-align: left;
    margin-left: auto;
    /* 自动左外边距将气泡推到右边 */
    margin-right: 0;
    border-top-right-radius: 0;
    /* 可选：调整气泡形状 */
    font-family: "Times New Roman", "SimSun", "宋体", serif;
    /* 英文优先Times New Roman，中文使用宋体 */
    position: relative;
    /* 保证绝对定位生效 */
    padding: 16px;
    /* 恢复正常内边距，因为按钮在外部 */
    width: fit-content;
    /* ⚠️ 关键：宽度根据内容自适应 */
    word-break: break-word;
    /* 防止长单词/网址撑破容器 */
    margin-bottom: 50px;
    /* 为悬停按钮留出空间 */
}

/* 用户消息内容样式 - 确保换行符正确显示 */
.chat-message.user-message .message-content {
    white-space: pre-wrap;
    /* 保留换行符，又能自动折行 */
    word-break: break-word;
    /* 单词过长时换行 */
    line-height: 1.4;
    /* 合适的行高 */
    margin: 0;
    /* 移除默认边距 */
    padding: 0;
    /* 移除默认内边距 */
}

/* 用户消息中的换行符样式 */
.chat-message.user-message .message-content br {
    display: block;
    /* 确保换行符显示为块级元素 */
    content: "";
    /* 清除默认内容 */
    margin-top: 0.2em;
    /* 适当的行间距 */
    line-height: 1.4;
    /* 保持行高一致 */
}

/* 响应消息：左侧显示，绿色背景和白色字体 */
.chat-message.bot-message {
    background-color: #66b377;
    color: #fff;
    align-self: flex-start;
    /* 左对齐 */
    margin-right: auto;
    /* 自动右外边距将气泡推到左边 */
    border-top-left-radius: 0;
    /* 可选：调整气泡形状 */
    padding: 8px 24px;
    /* 统一使用更大的内边距 */
}


/* Markdown表格样式 */
.markdown-table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
    font-size: 0.9em;
    table-layout: fixed;
    word-break: break-word;
    overflow-x: auto;
    display: block;
    max-width: 100%;
}

.markdown-table th,
.markdown-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    vertical-align: top;
    max-width: 300px;
    min-width: 80px;
}

.markdown-table th {
    background-color: #f2f2f2;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

.markdown-table tr:hover {
    background-color: #f1f1f1;
}

/* 响应式表格 */
@media screen and (max-width: 768px) {
    .markdown-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        border: 1px solid #ddd;
        border-radius: 4px;
        margin: 0.5em 0;
    }

    .markdown-table th,
    .markdown-table td {
        white-space: normal;
        word-break: break-word;
        min-width: 60px;
        padding: 6px 8px;
    }

    /* 确保表格在移动端有足够的滚动空间 */
    .markdown-table table {
        min-width: 500px;
    }
}

/* 通用表格响应式支持 */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0.5rem;
}

.table-responsive table {
    min-width: 500px;
    margin: 0;
}

@media screen and (max-width: 768px) {
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 0.25rem;
        margin: 0.5rem 0;
    }

    .table-responsive table {
        font-size: 0.875rem;
    }

    .table-responsive th,
    .table-responsive td {
        padding: 0.25rem 0.375rem;
        word-break: break-word;
        min-width: 60px;
    }
}

/* 宣传语外层容器：可根据需要调整上下间距 */
.my-slogan {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* 具体文字样式：可自行替换字体、大小、颜色、阴影等 */
.slogan-text {
    font-family: 'Georgia', serif;
    /* 这里可改成你喜欢的字体 */
    font-size: 1.4rem;
    /* 调整字体大小 */
    font-weight: bold;
    /* 粗体显示 */
    color: #343a40;
    /* 字体颜色 */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    /* 简单阴影效果 */
    text-align: center;
    /* 确保文本在容器内居中 */
    margin: 0;
    /* 去除段落默认外边距 */
}

/* 医学系统按钮样式 */
.app-login-btn {
    background-color: #4da6ff;
    border-color: #1a75ff;
}

.app-login-btn:hover {
    background-color: #1a75ff;
    border-color: #0066cc;
}

/* 文件上传页面的学科选择按钮样式 */
.subject-group-header button {
    background-color: #f8f9fa;
    border-color: #ddd;
}

.subject-group-header button:hover {
    background-color: #e9ecef;
}

.shared-subjects-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 15px;
    /* 添加底部间距，确保与页面底部保持距离 */
}

/* 为表单底部添加额外的间距 */
#shared-subjects-container {
    margin-bottom: 20px;
    /* 确保整个容器与页面底部有足够距离 */
}

/* 表单提交按钮上方也增加间距 */
form .btn-primary[type="submit"] {
    margin-top: 20px;
}

.admin-upload-container {
    padding-bottom: 100px;
    /* 或根据需要调整具体数值 */
}

/* 添加页脚样式 */
.footer-info {
    text-align: center;
    margin-top: auto;
    /* 使用auto将页脚推到容器底部 */
    padding: 5px 0;
    color: #fff;
    background-color: #343a40;
    width: 100%;
    font-size: 0.7rem;
}

.footer-info img {
    vertical-align: middle;
    margin-right: 5px;
    height: 10px;
}

.footer-info p {
    margin: 5px 0;
}

/* 确保容器占满高度 */
.container.mt-0 {
    padding-top: 0;
    padding-bottom: 0;
    height: auto;
    flex: 1;
}

/* ===== 聊天界面通用样式 ===== */


/* 机器人/系统消息样式 */
.chat-message.bot-message,
.chat-message.ai-message {
    background-color: #66b377;
    margin-left: 0;
    margin-right: auto;
    text-align: left;
}

/* ===== 统一标题、段落、列表的上下间距 - 跨浏览器兼容版本 ===== */
.chat-message h1,
.chat-message h2,
.chat-message h3,
.chat-message h4 {
    margin: 6px 0 !important;
    /* 使用固定像素值，确保跨浏览器一致性 */
    padding: 0 !important;
    line-height: 1.5 !important;
    display: block !important;
    /* 确保标题是块级元素 */
    font-weight: 600 !important;
}

/* 段落间距 - 确保有足够的可读性 */
.chat-message p {
    margin: 8px 0 !important;
    /* 使用固定像素值，确保跨浏览器一致性 */
    padding: 0 !important;
    line-height: 1.6 !important;
    /* 增加行高，提高可读性 */
    display: block !important;
    /* 确保段落是块级元素 */
    word-wrap: break-word !important;
}

.chat-message ul,
.chat-message ol {
    margin: 8px 0 !important;
    /* 使用固定像素值 */
    padding: 0 !important;
    line-height: 1.5 !important;
}

.chat-message ul,
.chat-message ol {
    padding-left: 1.2em !important;
    list-style-position: outside !important;
    /* 改为 outside，让编号和内容分离 */
}

.chat-message li {
    margin: 0 !important;
    padding: 0.05em 0 !important;
    line-height: 1.3 !important;
}

/* 代码块样式 */
.chat-message pre {
    background-color: #66b377;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 5px 0 !important;
    font-size: 0.9em;
    white-space: pre-wrap;
}

.chat-message code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9em;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
}

/* 表格样式 */
.chat-message table {
    margin: 15px 0;
    border-spacing: 2px;
}

.chat-message th,
.chat-message td {
    padding: 8px 12px;
    /* 从6px 8px增加到8px 12px */
}

/* 表格行悬停效果 */
.chat-message tr:hover {
    background-color: rgba(255, 255, 255, 0.1);
    /* 轻微高亮效果 */
}

/* 正在输入指示器 */
.chat-message.current-response:after {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #007bff;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
    margin-left: 5px;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        opacity: 1;
    }
}

/* 在机器人消息气泡中的markdown表格使用更清晰的交替背景 */
.chat-message.bot-message .markdown-table tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05) !important;
    /* 轻微白色透明交替行 */
}

.chat-message.bot-message .markdown-table tr:nth-child(odd) {
    background-color: transparent !important;
    /* 奇数行透明 */
}

.chat-message.bot-message .markdown-table td,
.chat-message.bot-message .markdown-table th {
    background-color: transparent !important;
    /* 透明，避免覆盖行背景 */
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: inherit;
}

.chat-message.bot-message .markdown-table th {
    background-color: rgba(0, 0, 0, 0.3) !important;
    /* 表头更深色 */
    color: white !important;
}

/* 同样处理markdown表格的thead部分 */
.chat-message .markdown-table thead tr th,
.chat-message .markdown-table thead tr td {
    background-color: rgba(0, 0, 0, 0.3) !important;
    color: white !important;
}

/* 修复响应式表格在深色主题下的背景色 */
.chat-message.bot-message .table-responsive {
    background-color: transparent !important;
}

.chat-message.bot-message .table-responsive table {
    background-color: transparent !important;
}

.chat-message.bot-message .table-responsive th,
.chat-message.bot-message .table-responsive td {
    background-color: transparent !important;
    color: inherit !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.chat-message.bot-message .table-responsive tr {
    background-color: transparent !important;
}

.chat-message.bot-message .table-responsive tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.chat-message.bot-message .table-responsive tr:nth-child(odd) {
    background-color: transparent !important;
}

.chat-message.bot-message .table-responsive thead tr th {
    background-color: rgba(0, 0, 0, 0.3) !important;
    color: white !important;
}

/* 减少 Markdown 表格与其他元素之间的间距 */
.chat-message .markdown-table {
    margin: 10px 0;
    /* 减少表格与上下元素的间距 */
}

/* 数学公式样式支持 */
.chat-message .math,
.chat-message .katex-display,
.chat-message .katex {
    background-color: transparent;
    color: inherit;
    max-width: 100%;
    overflow-x: auto;
    padding: 2px 0;
}

/* 行内公式样式 */
.chat-message .math-inline,
.chat-message .katex {
    margin: 0 5px;
    vertical-align: middle;
}

/* 块级公式样式 */
.chat-message .math-block,
.chat-message .katex-display {
    margin: 20px auto !important;
    padding: 10px 0 !important;
    text-align: center !important;
}

/* 确保公式在深色背景上可见 */
.chat-message.user-message .katex,
.chat-message.user-message .MathJax,
.chat-message.bot-message .katex,
.chat-message.bot-message .MathJax {
    color: white !important;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* 确保所有 MathJax 3.x 元素在绿色背景中显示为白色 */
.chat-message.bot-message mjx-container,
.chat-message.bot-message mjx-container *,
.chat-message.bot-message .MathJax,
.chat-message.bot-message .MathJax *,
.chat-message.bot-message .MathJax_Display,
.chat-message.bot-message .MathJax_Display *,
.chat-message.bot-message .MathJax_SVG,
.chat-message.bot-message .MathJax_SVG * {
    color: white !important;
}

/* 确保用户消息中的 MathJax 也是白色 */
.chat-message.user-message mjx-container,
.chat-message.user-message mjx-container *,
.chat-message.user-message .MathJax,
.chat-message.user-message .MathJax *,
.chat-message.user-message .MathJax_Display,
.chat-message.user-message .MathJax_Display *,
.chat-message.user-message .MathJax_SVG,
.chat-message.user-message .MathJax_SVG * {
    color: white !important;
}

/* 公式编号 */
.chat-message .katex-display>.katex {
    text-align: center !important;
}

/* 修复聊天消息中标题和列表的间距问题 */

/* 减小h3标题与紧跟的列表之间的间距 */
.chat-message h3+ul,
.chat-message h3+ol {
    margin-top: 0.1em !important;
    /* 保持很小的标题与列表之间的间距 */
}

/* 调整列表项内部间距 */
.chat-message ul li,
.chat-message ol li {
    margin: 0 !important;
    /* 完全移除列表项之间的垂直间距 */
    padding: 0.02em 0 !important;
    /* 只保留极小的内边距 */
}

/* 最后一个列表项不需要底部边距 */
.chat-message ul li:last-child,
.chat-message ol li:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0.02em !important;
}

/* 为h4标题添加样式规则 */

/* 减小h4标题与紧跟的列表之间的间距 */
.chat-message h4+ul,
.chat-message h4+ol {
    margin-top: 0.1em;
    /* 与h3保持一致的间距 */
}

/* 优化h4标题样式 */
.chat-message h4 {
    margin-top: 0.2em;
    /* 进一步减小标题上间距 */
    margin-bottom: 0.1em;
    /* 进一步减小标题下间距 */
    font-size: 1.05rem;
    /* 稍小于h3的字体 */
}

/* 第一个h4标题不需要过大顶部边距 */
.chat-message h4:first-child {
    margin-top: 0.1em;
}

/* 处理嵌套标题情况 */
.chat-message h3+h4 {
    margin-top: 0.1em;
    /* h3后面跟h4时的间距 */
}

/* 确保样式在所有渲染路径中正确应用 */
.chat-message h3,
.chat-message h4 {
    margin-top: 0.1em !important;
    /* 标题上间距 */
    margin-bottom: 0.1em !important;
    /* 标题下间距 */
}

/* 处理流式渲染特殊情况 */
.chat-message.streaming h3,
.chat-message.streaming h4 {
    transition: margin 0.2s ease;
    /* 添加过渡效果平滑样式变化 */
}

/* 调整段落 p 元素的外边距 */
p {
    margin-top: 0.1rem;
    /* 进一步减小上方间距 */
    margin-bottom: 0.1rem;
    /* 进一步减小下方间距 */
    line-height: 1.4;
    /* 减小行高 */
}

ol {
    margin-top: 0.1em;
    /* 进一步减小顶部边距 */
    margin-bottom: 0.1em;
    /* 进一步减小底部边距 */
    padding-top: 0;
    padding-bottom: 0;
}


ul {
    margin-top: 0.1em;
    /* 进一步减小顶部边距 */
    margin-bottom: 0.1em;
    /* 进一步减小底部边距 */
    padding-top: 0;
    /* 移除顶部内边距 */
    padding-bottom: 0;
    /* 移除底部内边距 */
}

/* 进一步优化 p 和 ol/ul 之间的间距 */
p+ol,
p+ul {
    margin-top: 0.1em !important;
    /* 进一步减小段落后列表的顶部间距 */
}


/* Pubmed文献检索和总结进展结果特殊样式 - 覆盖全局li样式 */
.pubmed-results {
    padding-left: 1.5rem;
}

.pubmed-results .pubmed-item {
    margin-bottom: 20px !important;
    /* 强制保持文献间距 */
    line-height: 1.5 !important;
    /* 恢复正常行高 */
    margin-top: 0 !important;
}

.pubmed-results .pubmed-item:last-child {
    margin-bottom: 10px !important;
    /* 最后一项稍小间距 */
}

/* PubMed摘要总结内容的段落间距修复 */
.chat-message .message-content p[style*="margin-bottom: 16px"] {
    margin-bottom: 16px !important;
    /* 强制覆盖全局样式 */
    margin-top: 0.5rem !important;
    /* 添加上方间距 */
    line-height: 1.6 !important;
    /* 增加行高 */
}

/* 针对PubMed摘要内容的特殊样式 */
.chat-message .message-content:has(p[style*="margin-bottom: 16px"]) p {
    margin-bottom: 16px !important;
    /* 强制设置段落间距 */
    margin-top: 0.5rem !important;
    /* 添加上方间距 */
    line-height: 1.6 !important;
    /* 增加行高 */
}

/* 去掉列表内 P 的额外上下间距 */
.chat-message ul li p {
    margin: 0 !important;
    /* 完全移除列表内段落间距 */
    padding: 0 !important;
    display: inline;
    /* 让段落内联，避免换行 */
    line-height: 1.3;
    /* 减小行高 */
}

/* 让 OL 列表项内的 P 与 bullet 同行 */
.chat-message ol li p {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.3;
    /* 减小行高 */
}

/* 设置列表 marker 颜色，确保在深色背景上可见 */
.chat-message ul li::marker,
.chat-message ol li::marker {
    color: #fff !important;
    /* 使用白色实心圆点 */
    font-size: 1em;
    /* 调整 marker 大小 */
}

/* 对有序列表使用自定义圆点标记 - 已注释，使用默认数字编号 */
/* .chat-message ol li::before {
    content: '•';
    color: #fff;
    display: inline-block;
    width: 1em;
    margin-right: 0.2em;
} */

/* 聊天表格首行（thead 或第一行）背景灰色 */
.chat-message table thead tr th,
.chat-message table thead tr td,
.chat-message table tr:first-child th,
.chat-message table tr:first-child td {
    background-color: #66b377 !important;
    color: #ffffff !important;
}

/* 1. "登录前需选择一个学科领域才能继续"提示框 */
.alert-info {
    margin-top: 0.3rem !important;
    margin-bottom: 0.3rem !important;
    /* 如果还想稍微收紧内边距，可以一并调整： */
    padding-top: 0.3rem !important;
    padding-bottom: 0.3rem !important;
}

/* 2. Tabs 非激活项文字 & 背景置灰 */
#loginModeTab .nav-link:not(.active) {
    color: #6c757d !important;
    /* 灰色文字 */
    background-color: #e9ecef !important;
    /* 浅灰背景 */
}

#loginModeTab .nav-link.active {
    color: #007bff !important;
    /* 保留蓝色 */
    background-color: transparent !important;
}

/* 块级公式在深色气泡里居中 */
.chat-message .MathJax_Display,
.chat-message .katex-display {
    text-align: center !important;
    margin: 1em auto !important;
}

/* ===========================================
   🔥 统一的 MathJax 样式控制
   =========================================== */

/* 基础数学公式容器 */
.math-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

/* 统一的数学公式基础样式 */
.chat-message mjx-container,
.chat-message .MathJax,
.chat-message .MathJax_Display,
.chat-message .MathJax_SVG,
.chat-message .math-inline,
.chat-message .math-block {
    font-size: 1em !important;
    max-width: 100% !important;
    overflow-x: auto;
    font-family: 'STIX Two Math', 'Times New Roman', serif !important;
    color: white !important;
    /* 确保公式文字为白色 */
}

/* 行内公式样式 */
.chat-message mjx-container[display="false"],
.chat-message .math-inline {
    display: inline !important;
    margin: 0 2px;
    vertical-align: baseline;
}

/* 块级公式样式 */
.chat-message mjx-container[display="true"],
.chat-message .MathJax_Display,
.chat-message .math-block {
    display: block !important;
    text-align: center;
    margin: 0.2em auto;
    padding: 0.2em 0;
}

/* SVG 元素控制 */
.chat-message mjx-container svg,
.chat-message .MathJax_SVG svg {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

/* 确保 MathJax SVG 中的所有元素（文本、路径等）都是白色 */
.chat-message.bot-message mjx-container svg,
.chat-message.bot-message mjx-container svg text,
.chat-message.bot-message mjx-container svg path,
.chat-message.bot-message mjx-container svg use,
.chat-message.bot-message .MathJax_SVG svg,
.chat-message.bot-message .MathJax_SVG svg text,
.chat-message.bot-message .MathJax_SVG svg path,
.chat-message.bot-message .MathJax_SVG svg use {
    color: white !important;
    fill: white !important;
    stroke: white !important;
}

/* 确保用户消息中的公式也是白色（如果背景是深色） */
.chat-message.user-message mjx-container svg,
.chat-message.user-message mjx-container svg text,
.chat-message.user-message mjx-container svg path,
.chat-message.user-message mjx-container svg use,
.chat-message.user-message .MathJax_SVG svg,
.chat-message.user-message .MathJax_SVG svg text,
.chat-message.user-message .MathJax_SVG svg path,
.chat-message.user-message .MathJax_SVG svg use {
    color: white !important;
    fill: white !important;
    stroke: white !important;
}

/* End of 统一的 MathJax 样式控制 */


/* 隐藏专家服务按钮（如果需要） */
.expert-service-hidden {
    display: none !important;
}

/* 为标题容器添加动画效果 */
@keyframes titleFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
        /* 减少移动距离，从-20px改为-10px */
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}







/* 翻译提示区域样式优化 */
.chat-message .alert.alert-success.translation-info {
    margin-top: 6px !important;
    margin-bottom: 10px !important;
    padding: 6px 8px !important;
    font-size: 0.85rem;
    line-height: 1.2;
    border-radius: 8px;
    background-color: rgba(76, 175, 80, 0.1) !important;
    border: 1px solid rgba(76, 175, 80, 0.3) !important;
    color: white !important;
    text-align: left !important;
    white-space: normal !important;
}

.chat-message .alert.alert-success .fa-language {
    margin-right: 4px !important;
    color: #4caf50 !important;
}

.chat-message .alert.alert-success.translation-info strong {
    color: white !important;
}

/* 关键词提取信息样式 */
.chat-message .alert.alert-success.keyword-extraction-info {
    margin-top: 6px !important;
    margin-bottom: 10px !important;
    padding: 6px 8px !important;
    font-size: 1rem;
    line-height: 1.4;
    border-radius: 8px;
    background-color: rgba(76, 175, 80, 0.1) !important;
    border: 1px solid rgba(76, 175, 80, 0.3) !important;
    color: white !important;
}

.chat-message .alert.alert-success .fa-lightbulb {
    margin-right: 4px !important;
    color: #4caf50 !important;
}

.chat-message .alert.alert-success.keyword-extraction-info strong {
    color: white !important;
}

/* 关键词提取整体左对齐 */
.chat-message .keyword-extraction-info {
    text-align: left !important;
    white-space: normal !important;
}

.keyword-extraction-text>strong,
.keyword-extraction-text>small {
    display: block;
    margin: 0;
    line-height: 1.4;
    font-size: 1rem;
}

.translation-text>strong {
    display: block;
    margin: 0;
    line-height: 1.3;
}

.dropdown-submenu:hover>.dropdown-menu {
    display: block;
    position: absolute;
    top: 0;
    left: 100%;
    right: auto;
    margin-left: 0.1rem;
    z-index: 9999;
}

/* 覆盖Bootstrap的dropstart样式，强制子菜单在右侧显示 */
.dropstart .dropdown-menu,
.dropstart .dropdown-submenu:hover>.dropdown-menu {
    top: 0 !important;
    left: 100% !important;
    right: auto !important;
    margin-top: 0 !important;
    margin-left: 0.1rem !important;
    margin-right: 0 !important;
    z-index: 9999 !important;
}

/* 文件夹子菜单滚动条样式 */
.dropdown-menu.folder-menu {
    min-width: 220px !important;
    max-width: 320px !important;
    max-height: min(360px, calc(100vh - 96px)) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
}

.dropstart .dropdown-submenu .folder-menu {
    min-width: 220px !important;
    max-width: 320px !important;
}

/* 自定义滚动条样式 */
.dropdown-menu.folder-menu::-webkit-scrollbar {
    width: 6px;
}

.dropdown-menu.folder-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.dropdown-menu.folder-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.dropdown-menu.folder-menu::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Firefox滚动条样式 */
.dropdown-menu.folder-menu {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* 编辑区域样式 */
.edit-textarea {
    width: 100%;
    min-height: auto;
    /* 自适应内容高度 */
    max-height: 400px;
    /* 添加最大高度限制，防止内容过多时文本框过高 */
    height: auto;
    /* 初始高度自适应内容 */
    resize: vertical;
    border: none;
    background: transparent;
    font-size: 1rem;
    /* 与Bootstrap默认字体大小保持一致 */
    line-height: 1.5;
    outline: none;
    font-family: inherit;
    color: inherit;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    /* 当内容超过最大高度时显示滚动条 */
}

.edit-textarea:focus {
    box-shadow: none;
    border: none;
}

.edit-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.edit-buttons .btn {
    padding: 4px 12px;
    font-size: 12px;
}

/* 编辑状态下的用户消息样式 */
.chat-message.user-message:has(.edit-textarea) {
    border: 2px solid #5A9EC8;
    border-radius: 8px;
    background-color: #5A9EC8;
    /* 保持与用户消息气泡相同的蓝色背景 */
    width: 100%;
    padding: 8px;
    color: white;
    /* 确保文字为白色 */
}

/* 编辑状态下的输入框样式 */
.chat-message.user-message:has(.edit-textarea) .edit-textarea {
    color: white !important;
    /* 强制输入框文字为白色 */
    background: transparent !important;
    /* 保持透明背景 */
}

/* 编辑状态下的按钮样式 */
.chat-message.user-message:has(.edit-textarea) .edit-buttons .btn {
    background-color: rgba(255, 255, 255, 0.2);
    /* 半透明白色背景 */
    border: 1px solid rgba(255, 255, 255, 0.3);
    /* 半透明白色边框 */
    color: white;
    /* 白色文字 */
}

.chat-message.user-message:has(.edit-textarea) .edit-buttons .btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    /* 悬停时更亮 */
    border-color: rgba(255, 255, 255, 0.5);
}

.chat-message.user-message:has(.edit-textarea) .edit-buttons .btn-primary {
    background-color: rgba(255, 255, 255, 0.9);
    /* 确定按钮更亮 */
    color: #007bff;
    /* 蓝色文字 */
    border-color: white;
}

.chat-message.user-message:has(.edit-textarea) .edit-buttons .btn-primary:hover {
    background-color: white;
    color: #007bff;
}

/* 编辑和复制按钮容器 */
.action-buttons {
    position: absolute;
    bottom: -40px;
    /* 将按钮移到消息框下方 */
    right: 0;
    /* 右对齐 */
    z-index: 10;
    display: inline-flex;
    /* 同一容器内水平排列 */
    flex-direction: row;
    gap: 8px;
    /* 增加按钮间距 */
    opacity: 0;
    /* 默认隐藏 */
    visibility: hidden;
    /* 默认不可见 */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* 平滑过渡效果 */
    padding: 6px 8px;
    /* 内边距 */
    border-radius: 6px;
    /* 圆角 */
    border: none;
    /* 去掉白色边框 */
    background-color: transparent;
    /* 透明背景更简洁 */
}

/* 用户消息悬停时显示按钮 */
.chat-message.user-message:hover .action-buttons {
    opacity: 1;
    visibility: visible;
}

/* Bot 消息悬停时显示按钮 */
.chat-message.bot-message:hover .action-buttons {
    opacity: 1;
    visibility: visible;
}


/* PubMed结果消息悬停时显示按钮 */
.chat-message.bot-message.pubmed-response:hover .action-buttons {
    opacity: 1;
    visibility: visible;
}

/* PubMed 结果在执行总结时强制显示按钮 */
.chat-message.bot-message.pubmed-response.show-actions .action-buttons {
    opacity: 1;
    visibility: visible;
}

/* 通用编辑/复制按钮样式 */
.btn-action {
    background: #5A9EC8;
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    width: auto;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    line-height: 1;
    font-family: "Segoe UI Symbol", "Apple Color Emoji", sans-serif;
    min-width: auto;
    white-space: nowrap;
    gap: 4px;
}

.chat-message.user-message .btn-copy,
.chat-message.user-message .btn-edit-retry {
    position: static;
    /* 由容器控制布局 */
    bottom: auto;
}

.chat-message.bot-message {
    position: relative;
    margin-bottom: 50px;
    /* 为action buttons留出空间 */
}

.chat-message.bot-message .action-buttons {
    right: auto;
    left: 0;
}

.chat-message.bot-message .btn-copy,
.chat-message.bot-message .btn-share {
    position: static;
    bottom: auto;
}


/* PubMed结果消息的特殊样式 */
.chat-message.bot-message.pubmed-response {
    position: relative;
    margin-bottom: 50px;
    /* 为action buttons留出空间 */
}

.chat-message.bot-message.pubmed-response .action-buttons {
    right: auto;
    left: 0;
}

/* 响应式设计：小屏幕上的按钮调整 */
@media (max-width: 576px) {
    .action-buttons {
        bottom: -35px;
        /* 小屏幕上稍微调整位置 */
        gap: 6px;
        /* 减少按钮间距 */
        padding: 4px 6px;
        /* 减少内边距 */
    }

    .btn-action {
        height: 24px;
        /* 小屏幕上减小高度 */
        font-size: 11px;
        /* 减小字体大小 */
        padding: 3px 6px;
        /* 减少内边距 */
        gap: 3px;
        /* 减少图标和文字间距 */
    }
}



/* 消息容器的布局 */
#message-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    /* 减少内边距，从1rem 1.5rem改为0.5rem 1rem */
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* 减少消息间距，从0.75rem改为0.5rem */
}

/* 消息输入区域优化 */
#message-input-container {
    padding: 0.5rem;
    /* 减少内边距，从1rem改为0.5rem */
    background-color: #fff;
    border-top: 1px solid #dee2e6;
    margin-top: auto;
}

/* 确保消息按正确顺序显示 */
.chat-message {
    margin-bottom: 20px;
    position: relative;
}

/* 用户消息样式 */
.chat-message.user-message {
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    max-width: 80%;
}

/* Bot消息样式 */
.chat-message.bot-message {
    align-self: flex-start;
    margin-left: 0;
    margin-right: auto;
    max-width: 80%;
}

/* 强制确保消息顺序 - 使用CSS Grid布局确保顺序 */
#message-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
    height: 100%;
    background-color: #f8f9fa;
}

/* 确保每个消息都在独立的网格行中 */
.chat-message {
    margin-bottom: 0;
    /* 移除margin，使用grid gap */
    position: relative;
    grid-row: auto;
    /* 让浏览器自动分配行 */
}

/* 用户消息样式 */
.chat-message.user-message {
    justify-self: end;
    max-width: 80%;
}

/* Bot消息样式 */
.chat-message.bot-message {
    justify-self: start;
    max-width: 80%;
}


/* 确保流式响应消息也遵循正确的顺序 */
.chat-message.bot-message.current-response {
    justify-self: start;
    max-width: 80%;
}

/* 兼容性：如果浏览器不支持grid，回退到flexbox */
@supports not (display: grid) {
    #message-container {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .chat-message {
        margin-bottom: 0;
    }

    .chat-message.user-message {
        align-self: flex-end;
    }

    .chat-message.bot-message {
        align-self: flex-start;
    }
}

/* 加载更多按钮样式 */
.load-more-button {
    margin: 10px 0;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
}

.load-more-button button {
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.load-more-button button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.load-more-button button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 确保加载更多按钮在消息容器顶部正确显示 */
#message-container .load-more-button {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 10;
    margin: 0;
    padding: 10px 20px;
    border-bottom: 1px solid #dee2e6;
}

/* 移动设备上的子菜单样式调整 */
@media (max-width: 767.98px) {

    .dropstart .dropdown-menu,
    .dropstart .dropdown-submenu:hover>.dropdown-menu {
        position: fixed !important;
        top: auto !important;
        left: auto !important;
        right: 10px !important;
        bottom: 10px !important;
        max-height: 300px !important;
        overflow-y: auto !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
        border-radius: 8px !important;
        min-width: 200px !important;
        max-width: 280px !important;
    }

    /* 移动设备上的文件夹子菜单滚动条样式 */
    .dropdown-menu.folder-menu {
        max-height: min(420px, calc(100vh - 40px)) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
}

/* ==========================
   内部系统全局优化
========================== */
body.internal-system {
    --internal-top-spacing: 0.2rem;
}

body.internal-system .container-fluid {
    padding-top: 0.5rem !important;
}


body.internal-system .chat-layout {
    margin-top: 0.3rem !important;
}

body.internal-system #message-container {
    padding-top: 0.2rem !important;
}

/* 内部系统标题完全隐藏 */
body.internal-system h3.app-title {
    display: none !important;
}

/* 内部系统标题容器最小化 */
body.internal-system .title-wrapper {
    min-height: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
}

/* ==========================
   全局样式重置
========================== */

/* ==========================
   外部学科系统优化
========================== */
body.academic-system {
    --academic-top-spacing: 0.2rem;
    /* 减少顶部间距，从0.3rem改为0.2rem */
}

body.academic-system .container-fluid {
    padding-top: 0.5rem !important;
    /* 减少顶部内边距，从0.8rem改为0.5rem */
}


body.academic-system .chat-layout {
    margin-top: 0.3rem !important;
    /* 减少顶部外边距，从0.4rem改为0.3rem */
}

body.academic-system #message-container {
    padding-top: 0.2rem !important;
    /* 减少顶部内边距，从0.3rem改为0.2rem */
}

/* 外部系统标题优化 - 保留但减少动画时间 */
body.academic-system h3.app-title {
    animation: titleFadeIn 0.3s ease-out !important;
    /* 减少动画时间，从0.4s改为0.3s */
    padding: 0.4rem 1rem !important;
    /* 减少内边距，从0.6rem 1.2rem改为0.4rem 1rem */
    font-size: 1.4rem !important;
    /* 减小字体，从1.6rem改为1.4rem */
}

/* 外部系统标题容器优化 */
body.academic-system .title-wrapper {
    min-height: 25px !important;
    /* 减少高度，从40px改为25px */
    margin-bottom: 0.1rem !important;
    /* 减少底部间距，从0.2rem改为0.1rem */
}

/* 紧凑标题样式 */
.compact-title {
    padding: 0.3rem 0.8rem !important;
    /* 进一步减少内边距 */
    font-size: 1.3rem !important;
    /* 进一步减小字体 */
    line-height: 1.1 !important;
    /* 进一步减小行高 */
    margin: 0 !important;
    /* 确保无边距 */
}

/* 紧凑标题容器 */

/* 紧凑标题的响应式设计 */
@media (max-width: 768px) {
    .compact-title {
        padding: 0.2rem 0.6rem !important;
        /* 移动端进一步减少内边距 */
        font-size: 1.1rem !important;
        /* 移动端进一步减小字体 */
    }
}