/* 全局样式 */
:root {
    --primary-color: #2b5c84;
    --secondary-color: #f0f7ff;
    --text-color: #333;
    --ai-message-bg: #f8f9fa;
    --user-message-bg: #e3f2fd;
    --border-radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --sidebar-width: 280px;
    --header-height: 60px;
    --footer-height: 100px;
    --message-max-width: 80%;
}

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: var(--text-color);
    overflow: hidden;
}

/* 应用容器 */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background-color: #f5f5f5;
    position: relative;
}

/* 侧边栏样式 */
.sidebar {
    background: #fff;
    width: var(--sidebar-width);
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    padding: 20px;  /* 添加内边距 */
    overflow-y: auto; /* 允许滚动 */
}

/* 修改侧边栏切换按钮样式 */
.sidebar-toggle {
    display: none; /* 默认隐藏 */
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    padding: 8px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.new-chat-btn:hover {
    opacity: 0.9;
}

.chat-list {
    padding: 10px;
}

.chat-item {
    padding: 12px 15px;
    margin: 4px 0;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.chat-item:hover {
    background-color: var(--secondary-color);
    transform: translateX(5px);
}

.chat-item.active {
    background-color: var(--secondary-color);
    font-weight: 500;
}

.chat-item i {
    color: var(--primary-color);
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    margin: 20px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    min-width: 0; /* 防止flex子项溢出 */
}

/* 聊天历史记录区域 */
#chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

/* 消息样式 */
.message {
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    max-width: var(--message-max-width);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-message {
    margin-left: auto;
    background-color: var(--user-message-bg);
    border-bottom-right-radius: 4px;
}

.ai-message {
    margin-right: auto;
    background-color: var(--ai-message-bg);
    border-bottom-left-radius: 4px;
}

.message-header {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.message-icon {
    margin-right: 8px;
}

.message-icon i {
    font-size: 1.2em;
}

.fa-user {
    color: var(--primary-color);
}

.fa-robot {
    color: #2196f3;
}

.message-label {
    font-weight: 500;
    color: var(--text-color);
}

.message-content {
    font-size: 14px;
    line-height: 1.6;
}

.message-time {
    font-size: 0.8em;
    color: #666;
    text-align: right;
    padding: 0 15px 8px;
}

/* 输入区域 */
.input-container {
    position: relative;
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

#user-input {
    min-height: 44px;
    max-height: 200px;
    padding: 12px 15px;
    font-size: 15px;
    line-height: 1.5;
    border-radius: 22px;
    border: 2px solid #e0e0e0;
    background-color: #fff;
    transition: all 0.3s ease;
}

#user-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(43, 92, 132, 0.1);
}

/* 按钮样式 */
.button-container {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

button {
    height: 40px;
    padding: 0 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

button i {
    font-size: 16px;
}

#send-btn {
    background-color: var(--primary-color);
    color: white;
}

#export-btn {
    background-color: #4caf50;
    color: white;
}

#clear-btn {
    background-color: #f44336;
    color: white;
}

#settings-btn {
    background-color: #607d8b;
    color: white;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* 代码块样式 */
.code-block {
    margin: 10px 0;
    padding: 15px;
    background-color: #2d2d2d;
    border-radius: 8px;
    color: #fff;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
}

.inline-code {
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Consolas', monospace;
}

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

/* 加载状态样式 */
.loading {
    display: inline-block;
    margin: 10px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* 禁用状态的按钮样式 */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 响应式布局 */
@media (max-width: 768px) {
    :root {
        --message-max-width: 90%;
    }

    .app-container {
        flex-direction: column;
    }

    /* 显示侧边栏切换按钮 */
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 调整聊天容器的边距，避免被按钮遮挡 */
    .chat-container {
        margin: 10px;
        margin-top: 60px; /* 为顶部按钮留出空间 */
        height: calc(100vh - 70px);
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        width: 85%;
        max-width: 320px;
        background: #fff;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
        padding-top: 70px; /* 增加顶部空间，避免被按钮遮挡 */
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .new-chat-btn {
        position: fixed; /* 固定定位 */
        top: 10px;  /* 距离顶部10px */
        left: 60px; /* 位于菜单按钮右侧 */
        right: 10px; /* 距离右侧10px */
        z-index: 1001; /* 确保在最上层 */
        margin: 0;
        height: 40px;
        max-width: calc(100% - 80px); /* 适应屏幕宽度 */
    }

    /* 遮罩层样式 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        backdrop-filter: blur(2px); /* 添加模糊效果 */
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* 小屏幕设备进一步优化 */
@media (max-width: 480px) {
    :root {
        --message-max-width: 95%;
    }

    .message {
        padding: 10px;
    }

    .message-header {
        padding: 6px 10px;
    }

    .message-content {
        font-size: 15px;
    }

    .input-container {
        padding: 10px;
    }

    .button-container {
        gap: 6px;
    }

    button {
        padding: 0 12px;
        height: 36px;
    }

    /* 在小屏幕上隐藏按钮文字，只显示图标 */
    button span {
        display: none;
    }

    button i {
        margin: 0;
    }

    .new-chat-btn {
        font-size: 13px; /* 减小字体大小 */
        padding: 8px; /* 减小内边距 */
    }

    .new-chat-btn i {
        margin-right: 4px; /* 减小图标和文字的间距 */
    }

    .sidebar {
        width: 90%; /* 增加侧边栏宽度 */
    }
}

/* 暗色模式进一步优化 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #4a9eff;
        --secondary-color: #1a2634;
        --text-color: #e0e0e0;
        --ai-message-bg: #2a2a2a;
        --user-message-bg: #1e3a5f;
    }

    body {
        background-color: #1a1a1a;
    }

    .sidebar, .chat-container {
        background-color: #242424;
    }

    .input-container {
        background-color: #242424;
        border-top-color: #333;
    }

    #user-input {
        background-color: #333;
        color: #fff;
        border-color: #444;
    }

    #user-input:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
    }

    .code-block {
        background-color: #1a1a1a;
        border: 1px solid #333;
    }

    .message {
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 暗色模式滚动条 */
@media (prefers-color-scheme: dark) {
    ::-webkit-scrollbar-thumb {
        background: #666;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: #888;
    }
}

/* 打字机效果样式 */
.typing {
    white-space: pre-wrap;
    word-break: break-word;
    visibility: hidden;
}

.typing::after {
    content: '▋';
    animation: blink 1s infinite;
    font-weight: bold;
    visibility: visible;
}

.typing span {
    visibility: visible;
    opacity: 0;
    animation: fadeIn 0.0001s forwards;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

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

/* 设置弹窗样式 */
.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.settings-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.settings-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-color);
}

.close-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    font-size: 20px;
}

.settings-item {
    margin-bottom: 20px;
}

.settings-item label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
}

.settings-item input,
.settings-item select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: all 0.3s ease;
}

.settings-item input:focus,
.settings-item select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(43, 92, 132, 0.1);
}

.settings-footer {
    margin-top: 20px;
    text-align: right;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .settings-content {
        background-color: #242424;
    }

    .settings-header {
        border-bottom-color: #333;
    }

    .settings-item input,
    .settings-item select {
        background-color: #333;
        border-color: #444;
        color: #fff;
    }

    .close-btn {
        color: #999;
    }
} 