/* ===== AI聊天页面样式 ===== */
:root {
    --chat-bg: #0f0f0f;
    --message-bg-ai: rgba(74, 0, 224, 0.1);
    --message-bg-user: var(--gradient-accent);
    --input-bg: rgba(255, 255, 255, 0.05);
    --border-light: rgba(255, 255, 255, 0.1);
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--chat-bg);
    backdrop-filter: blur(10px);
}

/* 聊天头部 */
.chat-header {
    background: rgba(10, 10, 10, 0.9);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 0;
    backdrop-filter: blur(20px);
}

.chat-header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ai-avatar {
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.ai-info h3 {
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.ai-info p {
    color: var(--text-gray);
    font-size: 0.9rem;
}

.header-actions {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-gray);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: var(--accent-color);
    color: white;
    transform: translateY(-2px);
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    animation: fadeIn 0.5s ease;
}

.message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: var(--gradient-accent);
}

.message-content {
    max-width: 70%;
}

.message-bubble {
    background: var(--message-bg-ai);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 1.2rem;
    margin-bottom: 0.5rem;
}

.user-message .message-bubble {
    background: var(--message-bg-user);
    border: none;
    color: white;
}
/* ===================== 代码块样式修复 ===================== */

/* 基础代码块容器 - 限制宽度并启用滚动 */
.message-bubble pre {
  max-width: 100%;
  overflow-x: auto;          /* 水平滚动 */
  overflow-y: hidden;        /* 防止垂直滚动干扰 */
  background: rgba(0, 0, 0, 0.3);  /* 暗色背景，与主题融合 */
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;            /* 上下间距 */
  position: relative;
}

/* 代码块内部文本样式 */
.message-bubble pre code {
  display: block;            /* 确保是块级元素 */
  font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;          /* 稍微缩小，避免换行过多 */
  line-height: 1.5;
  white-space: pre;          /* 保留格式 */
  overflow-x: auto;          /* 内部也需要滚动支持 */
  min-width: 0;              /* 防止 flex 容器膨胀 */
}

/* 行内代码样式 */
.message-bubble :not(pre) > code {
  background: rgba(0, 198, 255, 0.15);  /* 半透明青色背景 */
  color: var(--accent-color);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: 'Fira Code', monospace;
  font-size: 0.9em;
  white-space: normal;       /* 允许换行 */
  word-break: break-word;    /* 长单词断开 */
}

/* 移动端优化 */
@media (max-width: 768px) {
  .message-bubble pre {
    padding: 0.8rem;
    margin: 0.8rem 0;
    border-radius: 6px;
  }

  .message-bubble pre code {
    font-size: 0.85em;       /* 移动端更小字体 */
    line-height: 1.4;
  }

  /* 确保在窄屏幕上不会溢出 */
  .message-bubble {
    overflow: hidden;        /* 防止任何内容溢出 */
  }
}

/* 可选：添加滚动条美化（WebKit内核） */
.message-bubble pre::-webkit-scrollbar {
  height: 3px;
}

.message-bubble pre::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.message-bubble pre::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 3px;
}
.chat-messages .message-bubble ol,
.chat-messages .message-bubble ul {
    list-style: none !important;
    padding-left: 0;
}

.message-bubble p {
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

.message-bubble ul {
    margin: 0.8rem 0;
    padding-left: 2rem; /* 从 1.5rem 增加到 2rem */
}

.message-bubble li {
    margin-bottom: 0.5rem;
    margin-left: 1.4em;
    padding-left: 0.5rem; /* 增加文字与项目符号的间距 */
    color: var(--text-gray);
    position: relative; /* 添加相对定位 */
}

/* 为列表项添加自定义项目符号，更清晰 */
.message-bubble li::before {
    content: "•";
    color: var(--accent-color);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1.5em; /* 调整符号位置 */
}

.user-message .message-bubble li {
    color: rgba(255, 255, 255, 0.9);
}

.user-message .message-bubble li::before {
    color: #ffffff;
}

.message-time {
    font-size: 0.8rem;
    color: var(--text-gray);
    text-align: right;
}

/* 输入区域 */
.chat-input-container {
    background: rgba(10, 10, 10, 0.9);
    border-top: 1px solid var(--border-light);
    padding: 1.5rem 0;
    backdrop-filter: blur(20px);
}

.input-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 0 20px;
}

.chat-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border-light);
    border-radius: 25px;
    padding: 0.8rem 1.5rem;
    color: var(--text-light);
    font-size: 1rem;
    resize: none;
    max-height: 120px;
    transition: all 0.3s ease;
    scrollbar-width: none;  /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(0, 198, 255, 0.2);
}

.chat-input::-webkit-scrollbar {
    width: 0;           /* Chrome, Safari, Edge */
    display: none;      /* 额外保险 */
}

.btn-send {
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 198, 255, 0.3);
}

.input-actions {
    max-width: 1200px;
    margin: 1rem auto 0;
    padding: 0 20px;
    display: flex;
    gap: 1rem;
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    color: var(--text-gray);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-action:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* 快速指令面板 */
.quick-commands {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.command-category h4 {
    color: var(--accent-color);
    margin-bottom: 0.2rem;
    font-size: 1.1rem;
}

.command-btn {
    display: inline-block;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    margin: 0.25rem;
    color: var(--text-gray);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.command-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

/* 加载动画 */
.loading-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 10, 10, 0.95);
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    display: none;
    z-index: 1000;
}

.loading-animation.active {
    display: block;
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dot {
    width: 10px;
    height: 10px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (min-width: 769px) {
    .chat-container {
        padding: 0 !important;
    }
}
/* ===== 移动端适配（768px以下）===== */
@media (max-width: 768px) {
    /* 1. 顶部标题栏：大幅压缩高度 */
    .chat-header {
        position: sticky; /* 固定在顶部 */
        top: 0;
        z-index: 100;
        padding-top: 0 !important; /* 覆盖内联样式 */
        padding-bottom: 0.5rem !important;
    }

    .chat-header-content {
        padding: 0 10px;
        gap: 0.5rem;
    }

    .ai-avatar {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    .ai-info h3 {
        font-size: 1rem; /* 缩小标题 */
        margin-bottom: 0.1rem;
    }

    .ai-info p {
        font-size: 0.75rem;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    /* 2. 底部输入区：折叠提示词，仅保留核心功能 */
    .chat-input-container {
        padding: 0.8rem 0;
    }

    .input-wrapper {
        padding: 0 10px;
    }

    .chat-input {
        font-size: 0.95rem;
        padding: 0.6rem 1rem;
    }

    .btn-send {
        width: 42px;
        height: 42px;
    }

    /* 3. 快速指令：默认隐藏，可横向滑动展开 */
    .input-actions {
        padding: 0 10px;
        margin: 0.5rem auto 0;
        flex-wrap: nowrap; /* 不换行 */
        overflow-x: auto; /* 横向滚动 */
        -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
        gap: 0.5rem;
        scrollbar-width: none; /* Firefox隐藏滚动条 */
    }

    .input-actions::-webkit-scrollbar {
        display: none; /* Chrome/Safari隐藏滚动条 */
    }

    .command-btn {
        flex-shrink: 0; /* 禁止收缩 */
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        margin: 0;
    }

    /* 4. 消息区域：撑满剩余空间 */
    .chat-messages {
        padding: 1rem 0;
        flex: 1; /* 占满所有剩余空间 */
        min-height: 0; /* 修复flex布局在移动端的bug */
    }

    .message-content {
        max-width: 80%; /* 稍微放宽消息宽度 */
    }

    .message-bubble {
        padding: 0.8rem;
        font-size: 0.9rem;
    }

    /* 5. 整体容器：强制全屏，禁止溢出 */
    .chat-container {
        height: 100vh; /* 使用视口高度 */
        height: -webkit-fill-available; /* iOS Safari适配 */
        display: flex;
        flex-direction: column;
    }

    .input-actions {
        /*display: none !important; !* 完全隐藏 *!*/
    }


    /* 强制标题栏高度更小 */
    #header .navbar {
        padding: 0.5rem 0 !important;
    }

    /* 聊天容器弹性高度 */
    .chat-container {
        height: auto !important; /* 允许内容撑开 */
        min-height: 100vh; /* 至少一屏高 */
    }

    /* 消息区域最大化 */
    .chat-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.message-bubble {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* 在文件末尾添加或修改 */
.message-bubble a {
    color: var(--accent-color); /* 使用主题高亮色 */
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.message-bubble a:hover {
    color: #ffffff; /* 悬停时更亮 */
    text-shadow: 0 0 8px var(--accent-color);
}

.message-bubble li > p:first-child {
    display: inline-block;  /* 关键：改为行内块级 */
    margin: 0;              /* 移除默认外边距 */
    vertical-align: top;    /* 垂直对齐 */
}

/* 或者更彻底的方案：统一 li 内所有 p 标签的样式 */
.message-bubble li p {
    margin: 0.5rem 0;       /* 减小上下边距 */
    display: inline;        /* 直接设为行内元素 */
}

/* 用户消息中的链接（白色背景） */
.user-message .message-bubble a {
    color: #00f3ff; /* 更亮的青色 */
}

.user-message .message-bubble a:hover {
    color: #ffffff;
}

footer {
/*    display: none;*/
    margin: 0;
}

/* 思考过程容器 */
.thinking-bubble {
    background: rgba(0, 198, 255, 0.05); /* 改为青色基调，更明显 */
    border: 1px solid rgba(0, 198, 255, 0.3); /* 实线边框，更清晰 */
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-style: italic;
    color: var(--text-gray);
    font-size: 0.9em;
    transition: all 0.3s ease;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: inset 0 0 15px rgba(0, 198, 255, 0.1); /* 内发光效果 */
}

.thinking-bubble.collapsed {
    max-height: 50px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid rgba(0, 198, 255, 0.4);
    transition: all 0.4s ease;
    border-radius: 12px !important; /* 强制保留圆角 */
    background: rgba(0, 198, 255, 0.08); /* 折叠时更深背景 */
}

/* 增强折叠后的提示条 */
.thinking-bubble.collapsed::after {
    content: "展开深度思考过程";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent 10%, rgba(0, 198, 255, 0.15));
    padding: 12px 10px 8px; /* 增加上下内边距 */
    font-size: 0.85em;
    text-align: center;
    cursor: pointer;
    color: var(--accent-color);
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

/* 折叠时悬停效果 */
.thinking-bubble.collapsed:hover {
    border-color: var(--accent-color);
    background: rgba(0, 198, 255, 0.05);
}

.thinking-bubble.collapsed:hover::after {
    background: linear-gradient(transparent 10%, rgba(0, 198, 255, 0.25));
    color: #ffffff;
    text-shadow: 0 0 8px var(--accent-color);
}

/* 添加一个永久性的展开图标 */
.thinking-bubble.collapsed::before {
    content: "▼";
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    color: var(--accent-color);
    opacity: 0.6;
    z-index: 1;
}

/* 思考区域头部 */
.thinking-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 0.8rem;
    font-size: 0.95em;
}

.thinking-header i {
    color: var(--accent-color);
    transition: all 0.3s ease;
}

/* 新增：通过JS控制的脉冲动画类 */
.thinking-header i.pulsing {
    animation: pulse 1.2s infinite;
}

/* 思考内容 */
.thinking-content {
    line-height: 1.6;
    color: #ccc;
}

/* 自动折叠状态 */
.thinking-bubble.collapsed {
    max-height: 40px;
    overflow: hidden;
    position: relative;
}

.thinking-bubble.collapsed::after {
    content: "思考过程已折叠（点击展开）";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    padding: 10px;
    font-size: 0.8em;
    text-align: center;
    cursor: pointer;
}

/* 答案区域高亮 */
.answer-bubble {
    background: var(--message-bg-ai);
    border: 1px solid var(--border-light);
    border-radius: 15px;
    padding: 1.2rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 15px rgba(0, 198, 255, 0.1);
}

/* 脉冲动画 */
@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .thinking-bubble {
        font-size: 0.8em;
        padding: 0.8rem;
        max-height: 200px;
    }

    .thinking-header {
        font-size: 0.85em;
    }

        .thinking-bubble {
        font-size: 0.85em;
        padding: 0.8rem;
        max-height: 200px;
        border-radius: 10px; /* 稍小圆角 */
    }

    .thinking-bubble.collapsed {
        max-height: 42px; /* 适配移动端 */
        border-radius: 10px !important;
    }

    .thinking-bubble.collapsed::before {
        font-size: 1rem; /* 缩小箭头图标 */
    }
}


/* 思考区域的链接样式（更低调） */
.thinking-bubble a {
    color: rgba(0, 198, 255, 0.7); /* 半透明青色 */
    text-decoration: none; /* 无下划线 */
    border-bottom: 1px dotted rgba(0, 198, 255, 0.5); /* 点状下划线 */
    transition: all 0.3s ease;
}

.thinking-bubble a:hover {
    color: var(--accent-color);
    border-bottom-style: solid;
}

/* 思考区域的列表样式 */
.thinking-bubble ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem; /* 比正式结果缩进更小 */
    list-style-type: none; /* 无符号列表 */
}

.thinking-bubble li {
    margin-bottom: 0.3rem;
    padding-left: 0.5rem;
    color: rgba(204, 204, 204, 0.8); /* 更淡的文字 */
    font-size: 0.95em; /* 更小字体 */
    position: relative;
}

/* 思考区域列表前添加自定义符号（更简约） */
.thinking-bubble li::before {
    content: "—"; /* 破折号 */
    color: rgba(0, 198, 255, 0.5);
    font-weight: normal;
    display: inline-block;
    width: 1em;
    margin-left: -1.5em;
}

/* 正式结果区域的样式（保持不变，但显式声明确保优先级） */
.answer-bubble a {
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.answer-bubble a:hover {
    color: #ffffff;
    text-shadow: 0 0 8px var(--accent-color);
}

.answer-bubble ul {
    margin: 0.8rem 0;
    padding-left: 2rem;
    list-style-type: disc;
}

.answer-bubble li {
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
    color: var(--text-gray);
    position: relative;
}

.answer-bubble li::before {
    content: "•"; /* 圆点符号 */
    color: var(--accent-color);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1.5em;
}

.answer-loading {
    background: rgba(74, 0, 224, 0.05); /* 比思考区域更淡 */
    border: 1px dashed rgba(74, 0, 224, 0.3);
    border-radius: 15px;
    padding: 2rem 1.2rem;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--text-gray);
}

.answer-loading .loading-text {
    margin-top: 1rem;
    font-size: 0.9em;
    font-style: italic;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .answer-loading {
        padding: 1.5rem 0.8rem;
    }
}

/* ===================== 美化 HR 分割线 ===================== */
.answer-bubble hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    margin: 2rem 0;
    position: relative;
}

/* 中心发光点效果（可选） */
.answer-bubble hr::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-color);
}

/* ===================== 美化 TABLE 表格 ===================== */
.answer-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden; /* 确保圆角生效 */
}

/* 表头样式 */
.answer-bubble th {
    background: linear-gradient(180deg, rgba(0, 198, 255, 0.15), rgba(0, 198, 255, 0.05));
    color: var(--accent-color);
    font-weight: 600;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--accent-color);
}

/* 单元格样式 */
.answer-bubble td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-gray);
}

/* 最后一行无边框 */
.answer-bubble tr:last-child td {
    border-bottom: none;
}

/* 鼠标悬停高亮 */
.answer-bubble tbody tr:hover {
    background: rgba(0, 198, 255, 0.05);
    transition: background 0.3s ease;
}

/* ===================== 响应式处理 ===================== */
@media (max-width: 768px) {
    .answer-bubble table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 0.9em;
    }

    .answer-bubble th,
    .answer-bubble td {
        padding: 8px 12px;
    }
}

