:root {
    --primary-color: #4E6EF2; /* 主色调：豆包蓝 */
    --light-primary: #E8EEFF; /* 浅色主色 */
    --bg-color: #F7F8FA; /* 背景色 */
    --text-color: #333333; /* 文本色 */
    --light-text: #86909C; /* 次要文本色 */
    --border-color: #E5E6EB; /* 边框色 */
    --user-bg: #4E6EF2; /* 用户消息背景 */
    --user-text: #FFFFFF; /* 用户消息文本 */
    --ai-bg: #FFFFFF; /* AI消息背景 */
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.05); /* 阴影 */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

body {

}
#app {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background-color: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    overflow: hidden;
    z-index: 10;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    width: 32px;
    height: 32px;
    background-color: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.app-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.new-chat {
    margin: 16px;
    padding: 12px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.new-chat:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: rgba(78, 110, 242, 0.05);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.history-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.history-item:hover {
    background-color: var(--light-primary);
}

.history-item.active {
    background-color: var(--light-primary);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.history-icon {
    width: 24px;
    height: 24px;
    background-color: var(--light-primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 主聊天区 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
}

.chat-title {
    font-size: 16px;
    font-weight: 500;
}

.header-tools {
    display: flex;
    gap: 16px;
}

.tool-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.tool-btn:hover {
    background-color: var(--light-primary);
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 800px;
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}
.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
}

/* 确保图片消息容器不添加额外内边距影响布局 */
.message.ai .message-content img,
.message.user .message-content img {
    display: block;
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.avatar.user {
    background-color: #69b1ff;
}

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    max-width: calc(100% - 52px);
}

.message.ai .message-content {
    background-color: var(--ai-bg);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

.message.user .message-content {
    background-color: var(--user-bg);
    color: var(--user-text);
    border-top-right-radius: 4px;
}

/* 输入区 */
.input-area {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background-color: white;
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.text-input {
    width: 100%;
    min-height: 56px;
    max-height: 200px;
    padding: 16px 16px 16px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    resize: none;
    outline: none;
    font-size: 14px;
    line-height: 1.6;
    transition: border-color 0.2s;
}

.text-input:focus {
    border-color: var(--primary-color);
}

.send-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.send-btn:hover {
    background-color: #3a5bd8;
}

.input-tools {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--light-text);
}

.tool-icons {
    display: flex;
    gap: 16px;
}

.tool-icon {
    cursor: pointer;
    transition: color 0.2s;
}

.tool-icon:hover {
    color: var(--primary-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        position: absolute;
        height: 100%;
    }

    .sidebar.show {
        width: 260px;
    }

    .chat-header {
        padding: 16px 12px;
    }

    .menu-toggle {
        display: block !important;
    }

    .chat-messages {
        padding: 16px;
    }

    /* 移动端遮罩层 */
    .sidebar-backdrop {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.3);
        z-index: 5;
        display: none;
    }

    .sidebar-backdrop.show {
        display: block;
    }
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--light-text);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}