/* DeepSeek风格的聊天页面样式 */

:root {
    --chat-bg: #ffffff;
    --chat-sidebar-bg: #f7f7f8;
    --chat-message-user-bg: #19c37d;
    --chat-message-assistant-bg: #f7f7f8;
    --chat-text-primary: #353740;
    --chat-text-secondary: #6e6e80;
    --chat-border: #e5e5e6;
    --chat-input-bg: #ffffff;
    --chat-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 全屏布局 - DeepSeek风格（左右分栏） */
.chat-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    background: var(--chat-bg);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}


/* 左侧边栏 - DeepSeek风格 */
.chat-sidebar {
    width: 280px;
    background: var(--chat-sidebar-bg);
    border-right: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

/* Logo区域 */
.sidebar-logo {
    padding: 20px 16px;
    border-bottom: 1px solid var(--chat-border);
}

.sidebar-logo h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--chat-text-primary);
    margin: 0;
    text-align: center;
}

/* 新对话按钮 */
.new-chat-btn {
    margin: 12px 16px;
    padding: 12px 16px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--chat-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px; /* 减小间距，使布局更紧凑 */
    transition: background-color 0.2s, border-color 0.2s;
}

.new-chat-btn:hover {
    background: var(--chat-message-assistant-bg);
    border-color: var(--chat-text-secondary);
}

.new-chat-btn .btn-icon {
    font-size: 18px;
    font-weight: 600;
}

.new-chat-btn .btn-text {
    font-weight: 500;
}

/* 会话列表容器 */
.chat-sessions-container {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow-y: scroll;
    overflow-x: hidden;
    padding: 8px 0;
    position: relative;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 0.3s ease;
}

/* 滚动条样式在文件末尾统一管理 */

/* 会话列表 */
.sessions-list {
    padding: 0 8px;
    padding-right: 0; /* 不需要额外padding，容器已预留6px空间 */
    margin-right: 0;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

/* 分组标题 */
.session-group-title {
    font-size: 12px;
    font-weight: 400; /* 不加粗，保持正常字重 */
    color: var(--chat-text-secondary);
    padding: 8px 16px 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 分组容器 */
.session-group {
    margin-bottom: 8px;
}

/* 会话项 */
.session-item {
    padding: 4px 16px !important;
    margin: 1px 0 !important;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    box-sizing: border-box !important;
    overflow: visible; /* 允许子元素的负margin和背景显示 */
}

/* 移除item的hover灰色背景，只保留wrapper的绿色背景效果 */
/* .session-item:hover {
    background: rgba(0, 0, 0, 0.02);
} */

/* 鼠标悬停到历史记录上时，消息容器背景和选中时一样 */
/* 使用伪元素创建背景，不改变元素位置和尺寸 */
.session-item:hover .session-question-wrapper::before {
    content: '';
    position: absolute;
    left: -8px;
    right: -8px;
    top: 0;
    bottom: 0;
    background: rgba(25, 195, 125, 0.1);
    border-left: 3px solid var(--chat-message-user-bg);
    border-radius: 4px;
    z-index: 0; /* 在内容下方，但在父元素背景上方 */
    pointer-events: none; /* 不阻挡鼠标事件 */
}

/* 悬停时，如果已经是选中状态，保持选中样式优先级 */
.session-item:hover .session-question-wrapper.active::before {
    background: rgba(25, 195, 125, 0.1);
}

/* 移除item的active样式 - 不再使用，已删除 */

/* 消息容器 */
.session-question-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 8px;
    padding: 2px 0 !important;
    margin: 0 !important;
    transition: all 0.2s ease;
    width: 100%;
    flex-wrap: nowrap;
    flex-direction: row;
    box-sizing: border-box !important;
    position: relative; /* 为伪元素定位 */
    max-width: 100%;
}

/* 消息容器 - 选中样式（只作用于消息部分） */
/* 使用伪元素创建背景，不改变元素位置和尺寸 */
.session-question-wrapper.active::before {
    content: '';
    position: absolute;
    left: -8px;
    right: -8px;
    top: 0;
    bottom: 0;
    background: rgba(25, 195, 125, 0.1);
    border-left: 3px solid var(--chat-message-user-bg);
    border-radius: 4px;
    z-index: 0; /* 在内容下方，但在父元素背景上方 */
    pointer-events: none; /* 不阻挡鼠标事件 */
}

/* 选中时消息文本样式 */
.session-question-wrapper.active .session-question {
    color: var(--chat-message-user-bg);
    font-weight: 500;
    position: relative; /* 确保文本在伪元素上方 */
    z-index: 1;
}

/* 消息文本 - 单行显示 */
.session-item .session-question {
    font-size: 14px !important;
    font-weight: 600 !important; /* 字体加粗 */
    color: var(--chat-text-primary);
    line-height: 2.5 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    word-break: normal;
    box-sizing: border-box !important;
    position: relative; /* 确保文本在伪元素上方 */
    z-index: 1;
}

/* 省略图标 - 默认隐藏，hover时或选中时显示 */
.session-ellipsis-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    flex-grow: 0;
    opacity: 0; /* 默认隐藏 */
    transition: opacity 0.2s;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
    box-sizing: border-box;
    position: relative; /* 确保图标在伪元素上方 */
    z-index: 1;
}

/* 鼠标悬停到历史记录上时显示省略图标 */
.session-item:hover .session-ellipsis-icon {
    opacity: 1; /* hover时显示 */
}

/* 选中历史记录时显示省略图标 */
.session-question-wrapper.active .session-ellipsis-icon {
    opacity: 1; /* 选中时显示 */
}

/* 时间样式（隐藏，不再使用） */
.session-item .session-time {
    display: none;
}

/* 会话操作弹窗 */
.session-popup {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    min-width: 140px; /* 增加弹窗宽度 */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 弹窗删除按钮 */
.session-popup-delete-btn {
    padding: 8px 16px;
    margin: 0 8px; /* 左右留白 */
    background: transparent;
    border: none;
    color: #ff4444;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s, border-radius 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 6px; /* 添加圆角 */
}

/* 删除图标 */
.session-popup-delete-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.session-popup-delete-btn:hover {
    background: rgba(255, 68, 68, 0.1);
    border-radius: 6px; /* hover时保持圆角 */
}

.session-popup-delete-btn:active {
    background: rgba(255, 68, 68, 0.2);
    border-radius: 6px; /* active时保持圆角 */
}

/* 删除确认对话框 - 蒙版背景 */
.delete-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px); /* 背景模糊效果 */
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 删除确认对话框 - 对话框容器 */
.delete-confirm-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    padding: 24px;
    min-width: 400px;
    max-width: 90%;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 对话框标题 */
.delete-confirm-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

/* 对话框提示信息 */
.delete-confirm-message {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* 按钮容器 */
.delete-confirm-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 取消按钮 */
.delete-confirm-cancel-btn {
    padding: 10px 20px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-confirm-cancel-btn:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.delete-confirm-cancel-btn:active {
    background: #eeeeee;
}

/* 删除按钮 */
.delete-confirm-delete-btn {
    padding: 10px 20px;
    background: #ff4444;
    border: 1px solid #ff4444;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-confirm-delete-btn:hover {
    background: #ff3333;
    border-color: #ff3333;
}

.delete-confirm-delete-btn:active {
    background: #ee2222;
    border-color: #ee2222;
}

.sessions-loading,
.sessions-empty {
    padding: 20px;
    text-align: center;
    color: var(--chat-text-secondary);
    font-size: 14px;
}

/* 侧边栏底部 */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--chat-border);
}

.login-status {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-btn {
    padding: 8px 16px;
    background: var(--chat-message-user-bg);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-btn:hover {
    background: #16a86a;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: space-between;
}

/* 用户头像 - 始终显示默认头像 mrtx.png */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0; /* 防止头像被压缩 */
    display: block; /* 确保图片正确显示 */
}

.user-name {
    flex: 1;
    font-size: 14px;
    color: var(--chat-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0; /* 允许文本截断 */
}

.logout-btn {
    padding: 4px 12px;
    background: transparent;
    color: var(--chat-text-primary);
    border: 1px solid var(--chat-border);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0; /* 防止按钮被压缩 */
    white-space: nowrap; /* 防止按钮文字换行 */
}

.logout-btn:hover {
    background: var(--chat-border);
    color: var(--chat-text-primary);
}

/* 右侧主聊天区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--chat-bg);
}

/* 顶部标题栏 - DeepSeek风格 */
.chat-top-bar {
    height: 60px;
    background: var(--chat-bg);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.chat-top-bar h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--chat-text-primary);
    margin: 0;
}

.chat-top-bar .usage-info {
    font-size: 13px;
    color: var(--chat-text-secondary);
    margin: 0;
    position: absolute;
    right: 24px;
}

/* 主聊天区域 */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--chat-bg);
    position: relative;
}

/* 当只有欢迎消息时，整个聊天区域垂直居中 */
.chat-wrapper.has-welcome-only,
.chat-wrapper:has(.welcome-message-only) {
    justify-content: center;
    align-items: center;
}

/* 消息列表容器 - DeepSeek风格：居中布局，最大宽度限制 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: var(--chat-bg);
    scroll-behavior: smooth;
    max-width: 900px; /* 增加宽度 */
    margin: 0 auto;
    width: 100%;
    min-height: 200px; /* 确保有足够的高度显示内容 */
    display: flex;
    flex-direction: column;
}

/* 当只有欢迎消息时，消息列表容器不占用全部空间，允许内容居中 */
.chat-wrapper.has-welcome-only .chat-messages,
.chat-wrapper:has(.welcome-message-only) .chat-messages {
    flex: 0 1 auto;
    overflow: visible;
    padding: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 当只有欢迎消息时，内容居中显示 */
.chat-messages.has-welcome-only,
.chat-messages:has(.welcome-message-only) {
    justify-content: center;
    align-items: center;
}

/* 欢迎消息容器 - 居中显示 */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
    min-height: 0;
}

/* 欢迎标语 - 显示在输入框上方 */
.welcome-slogan {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px; /* 与输入框的间距 */
    padding: 0 20px;
    width: 100%;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-text {
    font-size: 24px;
    font-weight: 400;
    color: var(--chat-text-primary);
    opacity: 0.6; /* 淡化文字 */
    text-align: center;
    line-height: 1.5;
}

/* 有历史记录时隐藏标语 */
.chat-wrapper:not(.has-welcome-only):not(:has(.welcome-message-only)) .welcome-slogan {
    display: none;
}

/* 欢迎消息样式优化 - 已隐藏 */
.welcome-message {
    display: none;
}

/* 欢迎消息图标或装饰 - 已隐藏 */
.welcome-icon {
    display: none;
}

/* 当有消息时，恢复正常布局 */
.chat-messages:not(.has-welcome-only):not(:has(.welcome-message-only)) {
    justify-content: flex-start;
}

/* 消息容器 - DeepSeek风格 */
.message {
    display: flex;
    margin-top: 4px; /* 上方留白较小 */
    margin-bottom: 10px; /* 下方留白减小，保持一致 */
    animation: fadeIn 0.3s ease;
    gap: 12px;
    width: 100%;
    align-items: flex-start;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.message:hover {
    opacity: 0.95;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

/* 消息内容 - DeepSeek风格 */
.message-content {
    max-width: 85%;
    padding: 8px 14px; /* 减小上下内边距 */
    border-radius: 12px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.5; /* 优化行间距 */
    font-size: 15px;
    position: relative; /* 为复制按钮定位 */
    box-shadow: none;
    white-space: pre-wrap; /* 保留换行和空格 */
    min-height: auto;
    /* 确保复制按钮不影响布局 */
    overflow: visible; /* 允许按钮超出消息框显示 */
    margin-bottom: 0; /* 不增加底部间距 */
}

/* 消息内容中的文本容器 */
.message-content > div:first-child {
    min-height: 0;
    display: block;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Markdown内容样式 */
.markdown-content {
    line-height: 0.2; /* 优化行间距 */
    color: inherit;
}

/* 确保markdown-content的最后一个子元素下方不留白 */
.markdown-content > *:last-child {
    margin-bottom: 0 !important;
}

/* Markdown标题 */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 10px 0 4px 0; /* 上方10px，下方4px，减小下方留白 */
    font-weight: 600;
    line-height: 1.3; /* 优化标题行间距 */
    color: inherit;
}

/* 最后一个标题的下方留白更小 */
.markdown-content h1:last-child,
.markdown-content h2:last-child,
.markdown-content h3:last-child,
.markdown-content h4:last-child,
.markdown-content h5:last-child,
.markdown-content h6:last-child {
    margin-bottom: 0; /* 最后一个标题下方不留白 */
}

.markdown-content h1 {
    font-size: 1.75em;
    border-bottom: 2px solid var(--chat-border);
    padding-bottom: 8px;
}

.markdown-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--chat-border);
    padding-bottom: 6px;
}

.markdown-content h3 {
    font-size: 1.25em;
}

.markdown-content h4 {
    font-size: 1.1em;
}

.markdown-content h5 {
    font-size: 1em;
}

.markdown-content h6 {
    font-size: 0.9em;
    color: var(--chat-text-secondary);
}

/* Markdown段落 */
.markdown-content p {
    margin: 4px 0 2px 0; /* 上方4px，下方2px，减小下方留白 */
    line-height: 1.5; /* 优化行间距 */
}

/* 最后一个段落的下方留白更小 */
.markdown-content p:last-child {
    margin-bottom: 0; /* 最后一个段落下方不留白 */
}

/* Markdown列表 */
.markdown-content ul,
.markdown-content ol {
    margin: 4px 0 2px 0; /* 上方4px，下方2px，减小下方留白 */
    padding-left: 24px;
}

/* 最后一个列表的下方留白更小 */
.markdown-content ul:last-child,
.markdown-content ol:last-child {
    margin-bottom: 0; /* 最后一个列表下方不留白 */
}

.markdown-content li {
    margin: 1px 0; /* 减小列表项间距 */
    line-height: 1.5; /* 优化行间距 */
}

.markdown-content li:last-child {
    margin-bottom: 0; /* 最后一个列表项下方不留白 */
}

.markdown-content li > p {
    margin: 2px 0 1px 0; /* 减小段落间距 */
}

.markdown-content li > p:last-child {
    margin-bottom: 0; /* 最后一个段落下方不留白 */
}

/* Markdown代码 */
.markdown-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 0.9em;
}

.message.user .markdown-content code {
    background: rgba(255, 255, 255, 0.2);
}

/* Markdown代码块 */
.markdown-content pre {
    background: #f6f8fa;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    padding: 12px; /* 减小内边距 */
    margin: 6px 0 2px 0; /* 上方6px，下方2px，减小下方留白 */
    overflow-x: auto;
    line-height: 1.5; /* 优化行间距 */
    position: relative; /* 为复制按钮定位 */
}

/* 最后一个代码块的下方留白更小 */
.markdown-content pre:last-child {
    margin-bottom: 0; /* 最后一个代码块下方不留白 */
}

.message.user .markdown-content pre {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.9em;
    color: inherit;
}

/* Markdown引用 */
.markdown-content blockquote {
    border-left: 4px solid var(--chat-message-user-bg);
    padding-left: 16px;
    margin: 6px 0 2px 0; /* 上方6px，下方2px，减小下方留白 */
    color: var(--chat-text-secondary);
    font-style: italic;
    line-height: 1.5; /* 优化行间距 */
}

/* 最后一个引用的下方留白更小 */
.markdown-content blockquote:last-child {
    margin-bottom: 0; /* 最后一个引用下方不留白 */
}

/* Markdown表格 */
.markdown-content table {
    border-collapse: collapse;
    margin: 6px 0 2px 0; /* 上方6px，下方2px，减小下方留白 */
    width: 100%;
}

/* 最后一个表格的下方留白更小 */
.markdown-content table:last-child {
    margin-bottom: 0; /* 最后一个表格下方不留白 */
}

.markdown-content table th,
.markdown-content table td {
    border: 1px solid var(--chat-border);
    padding: 8px 12px;
    text-align: left;
}

.markdown-content table th {
    background: var(--chat-message-assistant-bg);
    font-weight: 600;
}

.message.user .markdown-content table th {
    background: rgba(255, 255, 255, 0.2);
}

/* Markdown链接 */
.markdown-content a {
    color: var(--chat-message-user-bg);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.markdown-content a:hover {
    border-bottom-color: var(--chat-message-user-bg);
}

.message.user .markdown-content a {
    color: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

/* Markdown粗体和斜体 */
.markdown-content strong {
    font-weight: 600;
    color: inherit;
}

.markdown-content em {
    font-style: italic;
}

/* Markdown分隔线 */
.markdown-content hr {
    border: none;
    border-top: 1px solid var(--chat-border);
    margin: 8px 0 2px 0; /* 上方8px，下方2px，减小下方留白 */
}

/* 最后一个分隔线的下方留白更小 */
.markdown-content hr:last-child {
    margin-bottom: 0; /* 最后一个分隔线下方不留白 */
}

/* Markdown图片 */
.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
}

/* 代码高亮样式调整 */
.markdown-content pre.hljs {
    background: #f6f8fa !important;
}

.message.user .markdown-content pre.hljs {
    background: rgba(255, 255, 255, 0.15) !important;
}

/* 代码块复制按钮 */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--chat-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
}

.markdown-content pre:hover .code-copy-btn {
    opacity: 1;
    pointer-events: auto;
}

.code-copy-btn:hover {
    background: rgba(0, 0, 0, 0.15);
    border-color: var(--chat-message-user-bg);
    color: var(--chat-message-user-bg);
}

.code-copy-btn.copied {
    background: var(--chat-message-user-bg);
    border-color: var(--chat-message-user-bg);
    color: white;
}

.message.user .markdown-content pre .code-copy-btn {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
}

.message.user .markdown-content pre .code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
}

.message.user .markdown-content pre .code-copy-btn.copied {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.9);
    color: var(--chat-message-user-bg);
}

/* 消息中的图片 */
.message-content img {
    max-width: 200px; /* 限制图片最大宽度，等比缩小 */
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: block;
    object-fit: contain; /* 保持比例，完整显示图片 */
}

.message-content img:hover {
    transform: scale(1.02);
}

/* 图片消息容器 */
.message-image-container {
    margin: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 6px; /* 减小间距，使布局更紧凑 */
}

.message-image-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    max-width: 200px; /* 限制图片最大宽度 */
    margin: 0 auto; /* 居中显示 */
}

.message-image-item img {
    max-width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    object-fit: contain; /* 保持比例，完整显示图片 */
}

.message.user {
    position: relative; /* 为复制按钮定位 */
    margin-bottom: 50px; /* 增加底部间距，为按钮留出空间 */
}

.message.user .message-content {
    position: relative; /* 为复制按钮定位 */
    background: var(--chat-message-user-bg);
    color: rgba(255, 255, 255, 0.95); /* 使用稍微柔和的白色，减少刺眼感，提高可读性 */
    border-bottom-right-radius: 4px;
    margin-left: auto;
    margin-bottom: 0; /* 不增加底部间距 */
}

.message.assistant .message-content {
    background: var(--chat-message-assistant-bg);
    color: var(--chat-text-primary);
    border-bottom-left-radius: 4px;
}

/* 用户消息复制按钮容器 */
.message.user .message-content .user-message-copy-btn-container {
    position: absolute;
    right: 8px;
    top: calc(100% + 6px);
    z-index: 100;
    margin: 0;
    padding: 0;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 始终显示的复制按钮（最新消息） */
.user-message-copy-btn-container.always-visible {
    opacity: 1;
    pointer-events: auto !important;
}

/* hover时显示的复制按钮（历史消息） */
.user-message-copy-btn-container.hover-only {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* hover时显示复制按钮 */
.user-message-copy-btn-container.hover-only.show-on-hover {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

/* 鼠标离开后延迟淡出 */
.user-message-copy-btn-container.hover-only.fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* 确保按钮容器和按钮都可以接收鼠标事件 */
.user-message-copy-btn-container,
.user-message-copy-btn-container * {
    pointer-events: auto;
}

.user-message-copy-btn-container .copy-tip {
    pointer-events: none;
}

.user-message-copy-btn-container .user-message-copy-btn {
    cursor: pointer;
}

/* 复制按钮样式 */
.user-message-copy-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
    box-shadow: none;
    position: relative;
    margin: 0;
    pointer-events: auto;
    z-index: 12;
}

.user-message-copy-btn:hover {
    opacity: 0.9;
}

.user-message-copy-btn:active {
    opacity: 0.7;
}

/* 复制图标 */
.user-message-copy-icon {
    width: 18px;
    height: 18px;
    display: block;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    min-width: 18px;
    min-height: 18px;
    flex-shrink: 0;
    background-image: url('/statics/images/fuzhi.png');
    transition: background-image 0.1s ease;
}

/* hover状态图标 */
.user-message-copy-icon[data-icon="hover"] {
    background-image: url('/statics/images/fuzhi2.png');
}

/* 默认状态图标 */
.user-message-copy-icon[data-icon="default"] {
    background-image: url('/statics/images/fuzhi.png');
}

/* 复制提示框 - 显示在按钮左边 */
.copy-tip {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(4px) scale(0.95);
    transition: all 0.2s ease;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 15;
    position: relative;
}

/* 显示状态 */
.copy-tip.show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

/* 已复制状态 */
.copy-tip.copied {
    background: rgba(76, 175, 80, 0.95);
    color: white;
    box-shadow: 0 2px 12px rgba(76, 175, 80, 0.3);
}


/* 消息时间 - 已隐藏 */
.message-time {
    display: none !important;
}

/* 输入区域 - 固定在底部 */
.chat-input-area {
    padding: 12px 24px 20px;
    background: var(--chat-bg);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

/* 当只有欢迎消息时，输入框也居中显示，不固定在底部 */
.chat-wrapper.has-welcome-only .chat-input-area,
.chat-wrapper:has(.welcome-message-only) .chat-input-area {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 24px !important;
    border-top: none !important;
    flex-shrink: 0 !important;
    margin-top: auto !important;
    margin-bottom: auto !important;
    width: 100% !important;
    max-width: 900px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.chat-wrapper.has-welcome-only .input-wrapper,
.chat-wrapper:has(.welcome-message-only) .input-wrapper {
    max-width: 900px !important; /* 使用!important确保宽度不被覆盖 */
    width: 100% !important;
    min-height: 64px;
    padding: 16px 20px;
    border-radius: 28px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--chat-border);
    flex-direction: column !important; /* 确保垂直布局 */
}

.chat-wrapper.has-welcome-only .input-wrapper:focus-within,
.chat-wrapper:has(.welcome-message-only) .input-wrapper:focus-within {
    border-color: var(--chat-message-user-bg);
    box-shadow: 0 4px 16px rgba(25, 195, 125, 0.15);
}

.chat-wrapper.has-welcome-only .chat-input,
.chat-wrapper:has(.welcome-message-only) .chat-input {
    font-size: 16px;
    min-height: 32px;
    padding: 8px 0;
    line-height: 1.5;
}

.chat-wrapper.has-welcome-only .send-button,
.chat-wrapper:has(.welcome-message-only) .send-button {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.chat-wrapper.has-welcome-only .input-disclaimer,
.chat-wrapper:has(.welcome-message-only) .input-disclaimer {
    margin-top: 16px;
    font-size: 13px;
}

/* 输入框行容器（包含上传按钮、输入框和发送按钮） */
.input-row {
    display: flex;
    align-items: center; /* 居中对齐，确保文字和图标在同一水平线 */
    gap: 6px;
    width: 100%;
    flex-shrink: 0;
}

/* 图片预览列表（左上角） */
.image-preview-list {
    display: none !important; /* 默认隐藏，有图片时通过JS显示为flex */
    flex-wrap: wrap;
    gap: 6px; /* 减小间距，使布局更紧凑 */
    padding: 0;
    width: 100%;
    align-items: flex-start;
    min-height: 0;
    order: -1; /* 确保在输入框之前显示 */
}

.image-preview-list[style*="flex"] {
    display: flex !important; /* 当JS设置display:flex时强制显示 */
}

.image-preview-item {
    position: relative;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--chat-border);
    background: var(--chat-message-assistant-bg);
    cursor: pointer;
    transition: transform 0.2s ease;
    box-sizing: border-box;
}

.image-preview-item:hover {
    transform: scale(1.02);
    border-color: var(--chat-message-user-bg);
}

.image-preview-item img {
    display: block;
    width: 60px;
    height: 60px;
    object-fit: cover; /* 覆盖模式，保持比例并填充 */
    border-radius: 6px;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    line-height: 0;
    transition: background 0.2s ease;
    z-index: 10;
    box-sizing: border-box;
    font-family: Arial, sans-serif; /* 使用更标准的字体，确保字符渲染一致 */
}

.image-preview-item .remove-btn:hover {
    background: rgba(255, 0, 0, 0.85);
}

.image-preview-item .remove-btn::before {
    content: '×';
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transform: translateY(-0.5px); /* 微调向上移动，使叉号视觉上完全居中 */
}

/* 输入框下方提示文字 */
.input-disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--chat-text-secondary);
    margin-top: 8px;
    opacity: 0.7;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.input-wrapper {
    max-width: 900px; /* 增加宽度，与消息区域一致 */
    margin: 0 auto;
    display: flex;
    flex-direction: column; /* 垂直布局：图片预览在上，输入框在下 */
    gap: 6px; /* 减小间距，使布局更紧凑 */
    background: var(--chat-input-bg);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    padding: 8px 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-height: 56px; /* 默认最小高度（只有输入框时） */
}

/* 注意：当只有欢迎消息时，输入框的样式已在上面（第394行）统一定义，这里不再重复 */

.input-wrapper:focus-within {
    border-color: var(--chat-message-user-bg);
    box-shadow: 0 0 0 3px rgba(25, 195, 125, 0.1), 0 4px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.input-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center; /* 确保容器内元素垂直居中 */
    width: 100%;
    min-height: 40px; /* 默认高度（只有输入框时） */
}

/* 图片上传按钮 */
.image-upload-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--chat-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    padding: 0;
}

.image-upload-btn:hover {
    background: var(--chat-message-assistant-bg);
    color: var(--chat-text-primary);
}

.image-upload-btn:active {
    transform: scale(0.95);
}

.image-upload-btn svg {
    width: 20px;
    height: 20px;
}

.chat-input {
    flex: 1;
    width: 100%;
    min-height: 24px;
    max-height: 200px;
    padding: 8px 0; /* 添加上下内边距，确保文字垂直居中 */
    border: none;
    background: transparent;
    font-size: 15px;
    resize: none;
    font-family: inherit;
    color: var(--chat-text-primary);
    line-height: 1.5; /* 调整行高，与按钮高度匹配 */
    overflow-y: auto;
    vertical-align: middle; /* 垂直居中对齐 */
}

/* 居中模式下的输入框样式 */
.chat-wrapper.has-welcome-only .chat-input::placeholder,
.chat-wrapper:has(.welcome-message-only) .chat-input::placeholder {
    color: var(--chat-text-secondary);
    opacity: 0.6; /* 淡化提示文字 */
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: var(--chat-text-secondary);
    opacity: 0.6; /* 淡化提示文字 */
}

/* 发送按钮 - 带纸飞机图标 */
.send-button {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--chat-message-user-bg);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 2px 4px rgba(25, 195, 125, 0.2);
}

/* 纸飞机图标样式 */
.send-button svg {
    width: 18px;
    height: 18px;
    stroke: white;
    display: block;
}

.send-button:hover:not(:disabled) {
    background: #16a86a;
    transform: scale(1.08);
    box-shadow: 0 4px 8px rgba(25, 195, 125, 0.3);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
    box-shadow: 0 1px 2px rgba(25, 195, 125, 0.2);
}

.send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--chat-text-secondary);
}


/* 使用次数提示（移到顶部栏） */
.usage-info {
    font-size: 14px;
    color: var(--chat-text-secondary);
}

/* 加载指示器 */
.loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px; /* 减小间距，使布局更紧凑 */
    padding: 12px 16px;
    background: var(--chat-message-assistant-bg);
    border-radius: 12px;
    color: var(--chat-text-secondary);
    font-size: 15px;
    min-height: 24px;
    animation: fadeIn 0.3s ease;
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--chat-text-secondary);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-4px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(4px);
    }
}

/* 滚动条样式 - 隐藏滚动条 */
.chat-messages::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
    width: 0;
}

.chat-messages {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 移动端隐藏侧边栏或使用抽屉式 */
    .chat-sidebar {
        position: absolute;
        left: -280px;
        z-index: 100;
        transition: left 0.3s;
    }
    
    .chat-sidebar.open {
        left: 0;
    }
    
    .chat-main {
        width: 100%;
    }
    
    .chat-top-bar {
        padding: 0 16px;
        height: 56px;
    }
    
    .chat-top-bar h1 {
        font-size: 16px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 14px;
    }
    
    .chat-input-area {
        padding: 12px 16px;
    }
    
    .input-wrapper {
        padding: 6px 10px;
    }
    
    /* 移动端也保持居中模式下的宽度 */
    .chat-wrapper.has-welcome-only .input-wrapper,
    .chat-wrapper:has(.welcome-message-only) .input-wrapper {
        max-width: 900px !important;
        width: 100% !important;
    }
    
    .chat-input {
        font-size: 14px;
    }
}


/* 使用次数已用完提示 */
.usage-limit-tip {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    margin: 20px auto;
    max-width: 600px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2);
}

.usage-limit-tip .tip-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.usage-limit-tip .tip-content {
    flex: 1;
}

.usage-limit-tip .tip-title {
    font-size: 16px;
    font-weight: 600;
    color: #856404;
    margin-bottom: 8px;
}

.usage-limit-tip .tip-message {
    font-size: 14px;
    color: #856404;
    line-height: 1.6;
}

/* Toast提示样式 */
.chat-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    max-width: 90%;
    text-align: center;
}

.chat-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.chat-toast-info {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #90caf9;
}

.chat-toast-success {
    background: #e8f5e9;
    color: #388e3c;
    border: 1px solid #81c784;
}

.chat-toast-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.chat-toast-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef5350;
}

/* ============================================
   修复滚动条圆角问题 - 放在CSS文件最后
   ============================================ */
.chat-sessions-container {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.chat-sessions-container.scrollbar-visible {
    scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

.chat-sessions-container.scrollbar-visible.scrollbar-thumb-hover {
    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

/* Webkit浏览器：确保圆角生效 */
/* 关键原理：圆角值不能超过滚动条宽度的一半，否则会被裁剪 */
.chat-sessions-container::-webkit-scrollbar {
    width: 8px; /* 增加宽度到8px，让圆角更明显 */
    background: transparent;
}

.chat-sessions-container::-webkit-scrollbar-track {
    background: transparent;
    margin: 2px 0; /* 上下留空，让滑块看起来更圆润 */
}

/* 关键：thumb圆角，圆角值 = 宽度的一半（4px）才能完整显示 */
.chat-sessions-container::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px !important; /* 圆角 = 宽度的一半，确保完整显示 */
    min-height: 60px; /* 确保有足够高度显示圆角 */
    transition: background 0.3s ease;
}

.chat-sessions-container.scrollbar-visible::-webkit-scrollbar-thumb {
    background: rgba(120, 120, 120, 0.4);
    border-radius: 4px !important;
}

.chat-sessions-container.scrollbar-visible.scrollbar-thumb-hover::-webkit-scrollbar-thumb {
    background: rgba(90, 90, 90, 0.5);
    border-radius: 4px !important;
}

/* thumb自身的hover */
.chat-sessions-container::-webkit-scrollbar-thumb:hover {
    background: rgba(60, 60, 60, 0.6) !important;
    border-radius: 4px !important;
}
