/* 基础样式 - 全局设置 */
:root {
    --primary-color: #6e48aa; /* 主色调 - 紫色 */
    --secondary-color: #9d50bb; /* 辅色调 - 浅紫色 */
    --text-color: #333; /* 主要文字颜色 */
    --text-light: #666; /* 次要文字颜色 */
    --text-lighter: #888; /* 更浅的文字颜色 */
    --bg-color: #f5f5f5; /* 背景色 */
    --bg-light: #f9f9f9; /* 浅背景色 */
    --border-color: #e0e0e0; /* 边框颜色 */
    --white: #fff; /* 白色 */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
}

/* 应用容器 - 主布局 */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏样式 - 导航菜单 */
.sidebar {
    width: 280px;
    background-color: var(--white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

    .sidebar-header h3 {
        margin: 0;
        color: var(--primary-color);
        font-weight: 600;
    }

.sidebar-menu {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
}

/* 主内容区域 */
.main-content {
    margin-left: 280px;
    flex: 1;
}

/* 登录/注册页面样式 */
.auth-container {
    display: flex;
    min-height: 100vh;
}

.auth-card {
    max-width: 450px;
    margin: 50px auto;
    padding: 30px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

    .auth-card h2 {
        text-align: center;
        margin-bottom: 25px;
        color: var(--primary-color);
    }

    .auth-card i {
        margin-right: 8px;
    }

.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
}

/* 表单样式 - 通用 */
.form-group {
    margin-bottom: 20px;
}

.form-control {
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: border-color 0.3s;
}

    .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.2rem rgba(110, 72, 170, 0.25);
    }

.text-danger {
    font-size: 0.85rem;
    margin-top: 5px;
    display: block;
}

/* 按钮样式 - 通用 */
.btn {
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
}

.btn-primary {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: var(--white);
}

    .btn-primary:hover {
        opacity: 0.9;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(110, 72, 170, 0.3);
    }

.btn-secondary {
    background: var(--white);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

    .btn-secondary:hover {
        background: #f9f9f9;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

.btn i {
    margin-right: 8px;
}

/* 新建聊天按钮 - 侧边栏 */
.new-chat-btn {
    margin: 10px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: var(--white);
    border-radius: 8px;
    padding: 10px 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(100% - 20px);
    transition: all 0.3s;
    border: none;
}

    .new-chat-btn:hover {
        opacity: 0.9;
        transform: translateY(-1px);
    }

    .new-chat-btn i {
        margin-right: 8px;
    }

/* 会话列表 - 侧边栏 */
.conversation-list {
    margin-top: 5px;
}

.conversation-section {
    margin-top: 15px;
}

.section-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-lighter);
    margin: 10px 15px;
    letter-spacing: 0.5px;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    color: var(--text-light);
    border-radius: 6px;
    margin: 2px 10px;
    position: relative;
}

    .conversation-item:hover {
        background-color: #f5f5f5;
    }

    .conversation-item.active {
        background-color: #f0e6ff;
        color: var(--primary-color);
    }

    .conversation-item i {
        margin-right: 10px;
        color: var(--primary-color);
    }

    .conversation-item.active i {
        color: var(--primary-color);
    }

.conv-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.conv-actions {
    display: none;
    position: absolute;
    right: 10px;
    background-color: var(--white);
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.conversation-item:hover .conv-actions {
    display: flex;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    font-size: 0.9rem;
}

    .btn-icon:hover {
        background-color: #f0f0f0;
        color: var(--text-color);
    }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-lighter);
}

    .empty-state i {
        font-size: 2rem;
        margin-bottom: 10px;
    }

    .empty-state p {
        margin: 0;
    }

/* 用户菜单 - 侧边栏底部 */
.user-menu {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    color: var(--text-light);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 500;
    font-size: 0.9rem;
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-lighter);
}

.user-menu-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-light);
    margin-bottom: 5px;
}

    .user-menu-item:hover {
        background-color: #f5f5f5;
        color: var(--text-color);
    }

    .user-menu-item i {
        margin-right: 10px;
        width: 20px;
        text-align: center;
    }

/* 聊天区域 - 主界面 */
.chat-area {
    margin-left: 280px;
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-light);
}

/* 聊天头部 - 标题栏 */
.chat-header {
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.conversation-title {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-color);
}

/* 消息容器 - 聊天内容区 */
.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-light);
}

.message {
    display: flex;
    margin-bottom: 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.message-avatar {
    margin-right: 15px;
}

.ai-avatar {
    background-color: var(--primary-color);
    color: var(--white);
}

.user-avatar {
    background-color: var(--border-color);
}

.message-content {
    flex: 1;
}

.message-text {
    padding: 12px 16px;
    border-radius: 8px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-lighter);
    margin-top: 5px;
    margin-left: 5px;
}

.user-message {
    justify-content: flex-end;
}

    .user-message .message-text {
        background-color: var(--primary-color);
        color: var(--white);
        border-top-right-radius: 0;
    }

.ai-message {
    justify-content: flex-start;
}

    .ai-message .message-text {
        background-color: var(--white);
        color: var(--text-color);
        border: 1px solid var(--border-color);
        border-top-left-radius: 0;
    }

/* 输入区域 - 消息发送区 */
.input-area {
    padding: 15px 15%;
    border-top: 1px solid var(--border-color);
    background-color: var(--white);
    display: flex;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 15px;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    min-height: 120px;
    max-height: 400px;
    outline: none;
    transition: border-color 0.3s;
}

    #message-input:focus {
        border-color: var(--primary-color);
    }

.send-btn {
    margin-left: 10px;
    padding: 12px 15px;
    border-radius: 8px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: var(--white);
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}

    .send-btn:hover {
        opacity: 0.9;
        transform: translateY(-1px);
    }

/* 欢迎屏幕 - 空状态 */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.welcome-content {
    max-width: 600px;
}

.welcome-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-screen h1 {
    color: var(--text-color);
    margin-bottom: 15px;
}

.welcome-screen p {
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

/* 首页样式 - 营销页面 */
.welcome-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px;
}

.welcome-header {
    text-align: center;
    margin-bottom: 40px;
}

    .welcome-header h1 {
        color: var(--text-color);
        font-size: 2.5rem;
        margin-bottom: 15px;
    }

    .welcome-header .subtitle {
        color: var(--text-light);
        font-size: 1.2rem;
        margin-bottom: 30px;
    }

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 50px;
}

.feature-card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s, box-shadow 0.3s;
}

    .feature-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    }

.feature-icon {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.feature-card h3 {
    color: var(--text-color);
    margin-bottom: 15px;
}

.feature-card p {
    color: var(--text-light);
    line-height: 1.6;
}

.cta-section {
    text-align: center;
    padding: 40px 0;
}

    .cta-section h2 {
        color: var(--text-color);
        margin-bottom: 25px;
    }

.cta-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}


/* MarkDown信息样式，以及消息复制按钮相关 */
.message-text pre {
    background-color: #f8f8f8;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    position: relative;
    border: 1px solid #e1e1e1;
    margin: 10px 0;
}

    .message-text pre code {
        background-color: transparent;
        padding: 0;
        border-radius: 0;
        font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
        font-size: 0.9em;
        line-height: 1.5;
        display: block;
    }

.message-text code:not(pre code) {
    background-color: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

.message-text blockquote {
    border-left: 3px solid #ddd;
    padding-left: 10px;
    margin-left: 0;
    color: #666;
}

.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

.message-text table,
.message-text th,
.message-text td {
    border: 1px solid #ddd;
}

.message-text th,
.message-text td {
    padding: 8px;
    text-align: left;
}

.message-text img {
    max-width: 100%;
    height: auto;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f0f0f0;
    padding: 5px 10px;
    border-radius: 5px 5px 0 0;
    margin-bottom: -5px;
    font-size: 0.8em;
    color: #555;
}

.copy-btn {
    background-color: #e1e1e1;
    border: none;
    border-radius: 3px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background-color 0.2s;
}

    .copy-btn:hover {
        background-color: #d1d1d1;
    }

    .copy-btn.copied {
        background-color: #4CAF50;
        color: white;
    }

.message-copy-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-copy-btn {
    opacity: 1;
}


/* 打字指示器样式 */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    background-color: #f0f0f0;
    border-radius: 18px;
}

    .typing-indicator span {
        display: inline-block;
        width: 8px;
        height: 8px;
        margin: 0 2px;
        background-color: #666;
        border-radius: 50%;
        opacity: 0.4;
        animation: typing-dots 1.4s infinite both;
    }

        .typing-indicator span:nth-child(1) {
            animation-delay: 0s;
        }

        .typing-indicator span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-indicator span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typing-dots {
    0%, 20% {
        opacity: 0.4;
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        transform: translateY(-4px);
    }

    100% {
        opacity: 0.4;
        transform: translateY(0);
    }
}

/* 错误消息样式 */
.error {
    color: #d32f2f;
    background-color: #ffebee;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 8px;
    font-size: 0.9em;
}

/* 响应式设计 - 移动设备适配 */
@media (max-width: 768px) {
    /* 侧边栏调整为顶部导航 */
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    /* 主内容区取消左边距 */
    .main-content, .chat-area {
        margin-left: 0;
    }

    /* 会话列表改为横向滚动 */
    .conversation-list {
        display: flex;
        overflow-x: auto;
        padding-bottom: 10px;
    }

    .conversation-item {
        min-width: 200px;
    }

    /* 消息宽度调整为100% */
    .message {
        max-width: 100%;
    }

    /* 输入区域减少左右边距 */
    .input-area {
        padding: 15px 5%;
    }

    /* 行动按钮改为垂直排列 */
    .cta-buttons {
        flex-direction: column;
        gap: 10px;
    }
}

/* 平板设备适配 */
@media (min-width: 769px) and (max-width: 1024px) {
    /* 侧边栏宽度缩小 */
    .sidebar {
        width: 240px;
    }

    /* 主内容区调整左边距 */
    .main-content, .chat-area {
        margin-left: 240px;
    }

    /* 输入区域调整边距 */
    .input-area {
        padding: 15px 10%;
    }
}
