/* 在文件顶部或合适位置添加全局链接样式 */
#swtool-ai-chatbot-container a {
    text-decoration: underline !important;
}

#swtool-ai-chatbot-container a {
    text-decoration: underline !important;
}
#swtool-ai-chatbot-container {
    position: fixed;
    bottom: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#swtool-ai-chatbot-messages .ai-message, 
#swtool-ai-chatbot-messages .user-message {
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

/* 右键菜单样式优化 */
#swtool-chat-context-menu {
    min-width: 180px;
    background: #fff;
    box-shadow: 0 3px 6px rgba(0,0,0,0.16);
    border-radius: 6px;
    overflow: hidden;
    z-index: 100000 !important;
}

.menu-item {
    padding: 10px 16px;
    font-size: 14px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
}

.menu-item:hover {
    background: #f8f9fa;
}


/* 修改切换按钮样式 */

#swtool-ai-chatbot-toggle {
    background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%); /* 金色渐变 */
    color: #333; /* 文字颜色改为深色 */
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 5px 5px 0 0;
    text-align: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    display: block;
    line-height: 1.5;
}


/* 移除重复标题的样式 */
#swtool-ai-chatbot-toggle span {
    display: none;
}

/* 确保头部标题唯一 */
#swtool-ai-chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    /* 防止标题换行 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

#swtool-ai-chatbot-toggle:hover {
    background: linear-gradient(135deg, #ffb700 0%, #ff9500 100%); /* 更深的金色渐变 */
}

#swtool-ai-chatbot-window {
    display: none;
    width: 450px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px 5px 0 0;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    flex-direction: column;
    max-height: 70vh;    
    bottom: 20px; /* 新增：距离底部20px */
}

#swtool-ai-chatbot-header {
    background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%); /* 金色渐变 */
    color: #333; /* 文字颜色改为深色 */
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 5px 5px 0 0;
}


/* 修改输入区域样式，添加will-change优化 */
#swtool-ai-chatbot-input {
    display: flex;
    border-top: 1px solid #ddd;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 0 0 5px 5px;
    position: sticky;
    bottom: 10px !important;
    align-items: flex-end;
    /* 添加以下优化属性 */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 优化文本区域 */
#swtool-ai-chatbot-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    padding: 12px;
    resize: none;
    border-radius: 20px;
    min-height: 40px;
    max-height: 120px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 0;
    /* 添加以下优化属性 */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    /* 新增样式支持附件缩略图 */
    overflow-x: auto; /* 允许水平滚动 */
    white-space: nowrap; /* 防止内容换行 */
    padding-right: 40px; /* 为滚动条留出空间 */
}

/* 优化发送按钮 */
#swtool-ai-chatbot-input button {
    background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%); /* 金色渐变 */
    color: #333; /* 文字颜色改为深色 */
    border: none;
    padding: 0 15px;
    margin-left: 10px;
    cursor: pointer;
    border-radius: 20px;
    transition: background 0.3s;
    height: 40px;
    min-width: 60px;
}

#swtool-ai-chatbot-input textarea:focus {
    outline: none;
    border-color: var(--swtool-chat-color, #0073aa);
}


#swtool-ai-chatbot-input button:hover {
    background: linear-gradient(135deg, #ffb700 0%, #ff9500 100%); /* 更深的金色渐变 */
}

#swtool-ai-chatbot-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 消息样式 */

.welcome {
    text-align: center;
    font-style: italic;
    color: #666;
}

.loading {
    position: relative;
    color: #666;
}

.loading:after {
    content: '...';
    position: absolute;
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.error {
    color: #d63638;
    background: #f8ebea;
}


#swtool-ai-chatbot-header {
    background: var(--swtool-chat-color, #0073aa);
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 5px 5px 0 0;
    position: sticky;
    top: 0;
    z-index: 1;
}

#swtool-ai-chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    /* 确保只有一个标题 */
    flex: 1;
    text-align: center;
}


/* 输入区域优化 */
#swtool-ai-chatbot-input {
    display: flex;
    border-top: 1px solid #ddd;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 0 0 5px 5px;
    position: sticky;
    bottom: 0;
    /* 移动端键盘优化 */
    align-items: flex-end;
}

#swtool-ai-chatbot-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    padding: 12px;
    resize: none;
    border-radius: 20px;
    min-height: 40px;
    max-height: 120px;
    font-family: inherit;
    font-size: 14px;
    /* 移动端优化 */
    line-height: 1.4;
    margin-bottom: 0;
}

#swtool-ai-chatbot-input button {
    background: var(--swtool-chat-color, #0073aa);
    color: white;
    border: none;
    padding: 0 15px;
    margin-left: 10px;
    cursor: pointer;
    border-radius: 20px;
    transition: background 0.3s;
    height: 40px;
    min-width: 60px;
}
/* 消息样式优化 */


.user-message a {
    color: #a8d8ff !important;
    text-decoration: underline !important;
}

/* 修改超链接样式 - 更醒目的蓝色和下划线 */
.ai-message a {
    color: #0066cc !important;
    text-decoration: underline !important;
    font-weight: bold;
}

.user-message a {
    color: #a8d8ff !important;
    text-decoration: underline !important;
    font-weight: bold;
}

/* ... existing code ... */

/* 添加打字机效果样式 */
.ai-message.typing {
    position: relative;
    overflow: hidden;
}

.ai-message.typing::after {
    content: '|';
    animation: blink 1s infinite;
    position: absolute;
    right: 10px;
    bottom: 10px;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* 确保消息容器有正确的布局 */
.ai-message {
    display: inline-block;
    position: relative;
    transition: all 0.3s ease;
}

/* 优化消息内容的显示 */
.ai-message > * {
    display: inline;
}

/* ... existing code ... */
/* 保留原有的消息链接样式，但增加特异性 */
#swtool-ai-chatbot-container .ai-message a,
#swtool-ai-chatbot-container .user-message a {
    text-decoration: underline !important;
    font-weight: bold;
}

#swtool-ai-chatbot-container .ai-message a {
    color: #0066cc !important;
}

#swtool-ai-chatbot-container .user-message a {
    color: #a8d8ff !important;
}

.swtool-user-chatbot-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.swtool-chatbot-form {
    margin-bottom: 30px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 4px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.swtool-chatbot-list {
    width: 100%;
    border-collapse: collapse;
}

.swtool-chatbot-list th,
.swtool-chatbot-list td {
    padding: 10px;
    border: 1px solid #ddd;
}

.swtool-chatbot-list a {
    margin: 0 5px;
}
.chatbot-card {
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #ffffff;
    margin-bottom: 20px;
}

.chatbot-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.card-header {
    padding: 20px;
    background: linear-gradient(135deg, #ffd700 0%, #b22222 100%);;
    border-bottom: 1px solid #e0e0e0;
}

.card-header h3 {
    margin: 0;
    font-size: 1.25em;
    font-weight: 700;
    color: #333;
    letter-spacing: 0.02em;
}

.card-body {
    padding: 20px;
    background: #ffffff;
}

.description {
    min-height: 100px;
    margin-bottom: 20px;
    color: #666;
    line-height: 1.7;
    font-size: 1em;
    font-family: 'Inter', sans-serif;
}

.card-actions {
    text-align: center;
    padding: 16px 0;
}

.use-btn {
    display: inline-block;
    padding: 10px 30px;
    background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%); /* 金色渐变 */
    color: #333; /* 文字颜色改为深色 */
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1em;
    border: none;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.use-btn:hover {
    background: linear-gradient(135deg, #ffb700 0%, #ff9500 100%); /* 更深的金色渐变 */
    color: #333;
    transform: translateY(-3px);
}

/* 移动端优化 */
@media (max-width: 768px) {
    .chatbot-card {
        border-radius: 12px;
    }
    
    .card-header {
        padding: 16px;
    }
    
    
    .card-body {
        padding: 16px;
    }    

    
    .use-btn {
        padding: 8px 24px;
        font-size: 0.95em;
    }
}    


.search-box {
    margin-bottom: 30px;
    text-align: center;
}

.search-form {
    max-width: 500px;
    margin: 0 auto;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding-right: 40px; /* 为按钮留出空间 */
}

.search-input-wrapper input {
    padding: 10px 15px;
    width: 100%;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    background: transparent;
    transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
    border-color: #0073aa;
}

.search-button {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.search-button:hover {
    color: #0073aa;
}

.search-button svg {
    width: 20px;
    height: 20px;
}

#swtool-voice-btn svg {
    fill: none !important;
    stroke: #81bdd4 !important; /* 保持可见的蓝色 */
    stroke-width: 2 !important;
}
.ai-message.context {
    background-color: #f5f5f5;
    border-left: 4px solid #0073aa;
    padding: 10px;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #666;
}

.ai-message.context strong {
    color: #333;
    display: block;
    margin-bottom: 5px;
}
.swtool-chatbot-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    margin-right: 8px;
    vertical-align: middle;
    object-fit: cover;
}

.swtool-chatbot-title {
    display: flex;
    align-items: center;
}

/* 卡片样式 */
.swtool-chatbot-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}


/* 调整卡片布局 */
.chatbot-card {
    text-align: center;
    padding: 20px;
}

.card-header {
    margin-bottom: 15px;
}

/* 调整描述文字样式 */
.description {
    margin: 15px 0;
    font-size: 18px;
    color: #666;
}

.chatbot-card-content {
    padding: 20px;
}

.chatbot-card-content h3 {
    margin: 0 0 10px;
    font-size: 2.2em;
}

.chatbot-card-content p {
    margin: 0 0 15px;
    color: #666;
}

.chatbot-card-button {
    display: inline-block;
    padding: 8px 16px;
    background: var(--swtool-chat-color, #0073aa);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.chatbot-card-button:hover {
    background: var(--swtool-chat-color-dark, #006494);
}

/* ... existing code ... */

.chatbot-card-image {
    text-align: center;
    /* 添加更强的样式限制 */
    width: 160px !important;
    height: 160px !important;
    margin: 15px auto !important;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.chatbot-card-image img {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 2px solid #fff !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    display: block !important;
    max-width: 100% !important;
    max-height: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
}

/* 化学方程式样式 */
/* 化学式样式 */
.chemical-equation {
    font-family: "KaTeX_Main", "Times New Roman", serif;
    font-size: 1.2em;
    padding: 0.8em;
    margin: 1em 0;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
    white-space: nowrap;
    overflow-x: auto;
}

.reaction-arrow {
    padding: 0 0.5em;
    font-family: "KaTeX_AMS";
}
.reaction-condition {
    font-size: 0.7em;
    vertical-align: super;
    color: #666;
    padding-left: 0.5em;
}
/* 化学式上下标优化 */
sub, sup {
    font-size: 0.75em;
    line-height: 1;
    vertical-align: baseline;
    position: relative;
}

sub {
    bottom: -0.25em;
}

sup {
    top: -0.5em;
}


/* 添加消息容器样式 */
#swtool-ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    transition: scroll-top 0.3s ease;
}

/* 添加滚动条样式 */
#swtool-ai-chatbot-window::-webkit-scrollbar {
    width: 8px;
}

#swtool-ai-chatbot-window::-webkit-scrollbar-track {
    background: #f5f5f5;
}

#swtool-ai-chatbot-window::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

/* 调整段落间距 */
.message-content p {
    margin: 1em 0;
    line-height: 1.6;
}
/* 侧边栏右键菜单兼容性 */
#swtool-ai-chatbot-container:not(.fullscreen) #swtool-chat-context-menu {
    z-index: 100001 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
/* 确保公式不会覆盖文本 */
.message-content {
    user-select: text;
    -webkit-user-select: text;
    white-space: pre-wrap;
    word-break: break-word;
}
/* 标题样式 */
/* 修改后的标题样式 - 添加 :not(pre) 选择器 */
.message-content > :not(pre) h1,
.message-content > :not(pre) h2,
.message-content > :not(pre) h3,
.message-content > :not(pre) h4,
.message-content > :not(pre) h5,
.message-content > :not(pre) h6 {
    margin: 1.2em 0 0.8em;
    font-weight: 600;
    line-height: 1.1;
}

.message-content h1 { font-size: 1.8em; }
.message-content h2 { font-size: 1.5em; }
.message-content h3 { font-size: 1.3em; }
.message-content h4 { font-size: 1.1em; }
.message-content h5 { font-size: 1em; }
.message-content h6 { font-size: 0.9em; }

/* 列表样式 */
.message-content ul, 
.message-content ol {
    margin: 0.8em 0;
    padding-left: 2em;
}

.message-content li {
    margin: 0.4em 0;
}

/* 代码块样式 */
.message-content pre {
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 1em;
    overflow-x: auto;
    margin: 1em 0;
    font-size: 0.9em;
}

.message-content code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background-color: transparent; /* 改为透明背景 */
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

/* 链接样式 */
.message-content a {
    color: #0066cc;
    text-decoration: underline;
    word-break: break-word;
}

.message-content a:hover {
    color: #004499;
}

/* 表格样式 */
.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    font-size: 0.95em;
}

.message-content th, 
.message-content td {
    border: 1px solid #ddd;
    padding: 0.6em 1em;
    text-align: left;
}

.message-content th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* 引用样式 */
.message-content blockquote {
    border-left: 4px solid #ddd;
    margin: 1em 0;
    padding: 0.5em 1em;
    color: #666;
    background-color: #f8f9fa;
}
/* 在chatbot.css中添加以下样式 */
/* 语音按钮和输入框布局 */
#swtool-ai-chatbot-input {
    position: relative !important;
    padding-right: 100px !important;
}

#swtool-ai-chatbot-input textarea {
    width: calc(100% - 100px) !important;
    padding-right: 80px !important;
    box-sizing: border-box;
}



#swtool-ai-chatbot-input button {
    right: 10px !important;
    z-index: 2 !important;
}

/* 语音反馈样式 */
#swtool-voice-feedback {
    background: #0073aa !important;
    color: white !important;
    padding: 12px 24px !important;
    border-radius: 24px !important;
    font-size: 14px !important;
    box-shadow: 0 4px 12px rgba(0,115,170,0.3) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 120px !important;
}

#swtool-voice-feedback:before {
    content: '' !important;
    display: inline-block !important;
    width: 8px !important;
    height: 8px !important;
    background: #fff !important;
    border-radius: 50% !important;
    margin-right: 8px !important;
    animation: voice-animation 1.5s infinite !important;
}

@keyframes voice-animation {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* 移除原有的绝对定位样式，改用弹性布局 */
#swtool-voice-btn,
#swtool-upload-image-btn,
#swtool-upload-attachment-btn,
#swtool-share-btn,
#swtool-think-btn {
    position: absolute !important;
    top: 100% !important; /* 放在输入框下方 */
    margin-top: 10px !important; /* 与输入框的间距 */
    transform: none !important;
    z-index: 100 !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    width: 30px !important;
    height: 30px !important;
    opacity: 1;
    transition: opacity 0.2s ease;
    box-shadow: none !important; /* 去掉阴影 */
}
#swtool-think-btn {
    left: 10px !important; /* 最右侧 */
}
#swtool-upload-image-btn {
    left: 70px !important; /* 中间 */
}
#swtool-upload-attachment-btn {
    left: 130px !important; /* 最右侧 */
}
#swtool-share-btn {
    left: 190px !important; /* 最右侧 */
}
#swtool-voice-btn {
    left: 250px !important; /* 最右侧 */
}

/* 鼠标悬停效果 */
#swtool-voice-btn:hover,
#swtool-upload-image-btn:hover,
#swtool-upload-attachment-btn:hover,
#swtool-share-btn:hover,
#swtool-think-btn:hover {
    opacity: 1;
}


/* 移动端样式 */
@media (max-width: 768px) {
    #swtool-voice-btn,
    #swtool-upload-image-btn,
    #swtool-upload-attachment-btn,
    #swtool-share-btn,
    #swtool-think-btn {
        width: 24px !important;
        height: 24px !important;
    }
    
    #swtool-upload-image-btn {
        left: 60px !important;
    }
    #swtool-upload-attachment-btn {
        left: 110px !important;
    }
    #swtool-share-btn {
        left: 160px !important;
    }
    #swtool-voice-btn {
        left:220px !important;
    }

}

.ai-message.welcome {
    padding: 15px;
    margin-bottom: 80px; /* 增加底部外边距 */
    background: #f5f5f5;
    border-radius: 8px;
    position: relative;
    z-index: 1;
}

/* 确保按钮在欢迎消息下方 */
#swtool-ai-chatbot-input {
    position: relative;
    z-index: 2;
    margin-top: 10px;
    margin-bottom: 40px; /* 增加底部外边距 */
}


/* 发送按钮位置 */
#swtool-ai-chatbot-input button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1; /* 确保语音按钮在上层 */
}

/* 基础容器样式 */
#swtool-ai-chatbot-container {
    position: fixed;
    bottom: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px; /* 基础字体大小 */
    line-height: 1.5; /* 舒适的行高 */
    color: #333; /* 主文字颜色 */
}
#swtool-ai-chatbot-container.right {
    right: 0px;
}

#swtool-ai-chatbot-container.left {
    left: 0px;
}
/* 修改移动端窗口样式 */
@media (max-width: 767px) {
    #swtool-ai-chatbot-window {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 61.8vh !important;
        height: 61.8vh !important;
    }

    #swtool-ai-chatbot-header {
        border-radius: 0 !important;
    }

    #swtool-ai-chatbot-input {
        border-radius: 0 !important;
    }
}

/* 桌面端样式保持不变 */
/* 移动端优化 */
@media (max-width: 768px) {
    #swtool-ai-chatbot-container {
        font-size: 15px; /* 移动端稍大 */
    }
    
    .message-content {
        font-size: 16px;
    }
    
    .katex {
        font-size: 1em !important;
    }
}
/* 响应式调整 */
@media (max-width: 480px) {
    .user-message,
    .ai-message {
        max-width: 90%;
        font-size: 14px;
    }
}
/* 修改PC端默认展开样式 */

@media (min-width: 768px) {
    /* 全屏版样式保持不变 */
    #swtool-ai-chatbot-container.fullscreen #swtool-ai-chatbot-toggle {
        display: none;
    }
    
    #swtool-ai-chatbot-container.fullscreen #swtool-ai-chatbot-window {
        display: flex !important;
        bottom: 20px;
        right: 20px;
    }

    /* 侧边栏版本样式 */
    #swtool-ai-chatbot-container:not(.fullscreen) {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }
    
    #swtool-ai-chatbot-container:not(.fullscreen) #swtool-ai-chatbot-toggle {
        display: flex !important;
        position: relative;
        order: 1;
        width: 100%;
        border-radius: 5px 5px 0 0;
        margin-bottom: 0; /* 移除负margin */
        z-index: 2; /* 确保按钮在窗口上方 */
    }
    
    #swtool-ai-chatbot-container:not(.fullscreen) #swtool-ai-chatbot-window {
        display: none;
        order: 2;
        position: relative;
        margin-top: -1px; /* 改为在窗口上使用负margin */
        z-index: 1; /* 窗口在按钮下方 */
    }
    
    /* 当窗口显示时的样式 */
    #swtool-ai-chatbot-container:not(.fullscreen).expanded {
        top: 20px;
        bottom: auto;
    }
    
    #swtool-ai-chatbot-container:not(.fullscreen).expanded #swtool-ai-chatbot-window {
        display: flex !important;
    }
}
/* 移除重复标题 */
#swtool-ai-chatbot-toggle span:not(:first-child) {
    display: none;
}

#swtool-ai-chatbot-toggle:hover {
    background: var(--swtool-chat-color-dark, #006494);
}

#swtool-ai-chatbot-window {
    display: none;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px 5px 0 0;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    flex-direction: column;
    /* 移动端高度优化 */
    height: 70vh;
    max-height: 70vh;
    width: 100%;
}

@media (min-width: 768px) {
    #swtool-ai-chatbot-window {
        width: 350px;
    }
}
#swtool-ai-chatbot-window {
    display: none;
    width: 350px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px 5px 0 0;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    flex-direction: column;
    max-height: 70vh;
    /* 修改以下滚动相关属性 */
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column-reverse; /* 使新消息出现在底部 */
}

/* 添加缩略图样式 */
/* 添加缩略图样式 */
#swtool-file-thumbnails {
    position: absolute;
    left: 80px; /* 放在输入框左侧 */
    bottom: 10px; /* 与输入框底部对齐 */
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 1;
    max-width: 120px; /* 限制最大宽度 */
    overflow: hidden;
}

#swtool-file-thumbnails img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid #ddd;
    background: #fff;
    padding: 2px;
}

#swtool-file-thumbnails div {
    display: none; /* 隐藏多余信息 */
}

/* 消息样式优化 */
/* 消息气泡样式优化 */
.user-message {
    background: var(--swtool-chat-color, #0073aa);
    color: white !important;
    padding: 10px 15px;
    border-radius: 18px 18px 0 18px;
    margin: 8px 0 8px auto;
    max-width: 85%;
    font-size: 15px;
    line-height: 1.5;
}
/* 增加特异性来确保样式生效 */
/* 增加更具体的选择器 */
#swtool-ai-chatbot-container .user-message,
#swtool-ai-chatbot-container .user-message * {
    color: white !important;
}

/* 确保所有子元素都继承颜色 */
#swtool-ai-chatbot-container .user-message *:not(a) {
    color: inherit !important;
}

/* 修复 SVG 显示 */
svg[display="block"] {
    margin: 12px 0;
}
/* 段落样式 */
.chat-paragraph {
    margin: 0.8em 0;
    line-height: 1.6;
    color: #333;
}

/* 数学公式容器 */
.math-block {
    overflow-x: auto;
    padding: 12px 0;
    margin: 1em 0;
}

/* 化学式样式 */
sub, sup {
    font-size: 0.8em;
    line-height: 1;
}

sub {
    vertical-align: sub;
}

sup {
    vertical-align: super;
}

/* 化学符号 */
.chemical-symbol {
    font-family: "Times New Roman", serif;
    font-style: italic;
}
/* LaTeX公式样式 */
.latex-inline {
    display: inline-block;
    font-family: "Times New Roman", serif;
    font-style: italic;
    background-color: #f5f5f5;
    padding: 0 4px;
    border-radius: 3px;
    max-width: 100%; /* 新增：防止内联公式溢出 */
    overflow-x: auto; /* 新增：允许横向滚动 */
}

.latex-block {
    display: block;
    font-family: "Times New Roman", serif;
    font-style: italic;
    background-color: #f5f5f5;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
    text-align: center;
    overflow-x: auto;
    max-width: 100%; /* 新增：确保块级公式不溢出 */
    box-sizing: border-box; /* 新增：包含padding在宽度计算内 */
}

/* 添加公式样式 */
.katex-formula {
    display: inline-block;
    padding: 2px 4px;
    margin: 0 2px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    line-height: 1.5;
    vertical-align: middle;
}
/* 数学公式样式 */
/* 在chatbot.css中添加 */
.katex {
    font: normal 1.21em KaTeX_Main;
    white-space: nowrap;
}

.katex-display {
    overflow: auto hidden;
    padding: 1em 0;
}

.mjx-container {
    overflow: visible !important;
}
.katex-display > .katex {
    white-space: normal;
    display: inline-block;
    width: 100%;
    text-align: center;
}
.katex-error { 
    color: red;
    word-break: break-word; /* 新增：错误信息自动换行 */
}

.mjx-chtml {
    outline: 0 !important;
}

/* 移动端特定样式 */
/* 移动端优化 */
@media (max-width: 768px) {
    .katex {
        font-size: 1em !important;
    }
    
    .chemical-equation {
        font-size: 1em;
        padding: 0.5em;
    }
    
    .katex-display {
        padding: 0.5em 0;
    }
}



/* 错误提示 */
.katex-error {
    background: #fff0f0;
    border: 1px solid #ffd6d6;
    padding: 2px 4px;
    border-radius: 3px;
    color: #c00;
}

/* 正式回答样式 */
.message-content > *:not(.think-container) {
    font-size: 15px; /* 比基础稍大 */
    line-height:1.6; /* 更宽松的行距 */
    overflow-x: auto;
    word-wrap: break-word;
}

/* AI消息保持黑色 */
.ai-message .message-content > *:not(.think-container) {
    color: #333;
}

/* 用户消息保持白色 */
.user-message .message-content > *:not(.think-container) {
    color: #fff;
}
/* 全屏模式消息颜色修正 */
#swtool-ai-chatbot-container.fullscreen .user-message {
    color: #fff !important;
}

.think-container {
    transition: background-color 0.3s ease;
    opacity: 0.8 !important;
    background: #f8f9fa; /* 灰色背景 */
    border-left: 3px solid rgba(0, 0, 0, 0.1);
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}

/* 思考内容标题 */
.think-header {
    padding: 6px 12px;
    font-size: 0.85em;
    color: #666; /* 深灰色 */
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: transparent;
}

/* 思考正文内容 */
.think-content {
    padding: 8px 12px;
    font-style: italic; /* 斜体 */
    color: #333; /* 深色 */
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 0.9em;
    background: transparent;
    margin: 0;
    transition: opacity 0.3s ease;
    opacity: 0.8 !important;
}

.external-link {
    color: #007bff;
    text-decoration: underline;
    transition: opacity 0.3s;
}
.external-link:hover {
    opacity: 0.8;
}
/* 强制代码块样式 */
.code-block-container {
    all: initial !important; /* 重置容器样式 */
    display: block !important;
    margin: 1em 0 !important;
}

.code-block-container pre,
.code-block-container code {
    all: initial !important;
    display: block !important;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    color: #333 !important;
    white-space: pre !important;
    background: #f5f5f5 !important;
    padding: 12px !important;
    border-radius: 4px !important;
    overflow-x: auto !important;
    margin: 0 !important;
}

/* 防止任何继承样式影响 */
.code-block-container * {
    all: unset !important;
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
}

/* 化学公式样式 */
/* 化学公式样式 */
.katex .mord.text {
    font-family: "Times New Roman", serif;
    font-style: italic;
}

.katex .mrel {
    padding: 0 0.2em;
}

/* 反应箭头特别处理 */
.katex .mrel.rightarrow {
    transform: scale(1.5);
}

