:root {
    --bg-gradient: linear-gradient(135deg, rgba(230, 243, 255, 0.8) 0%, rgba(255, 249, 230, 0.8) 100%);
    --container-bg: rgba(255, 255, 255, 0.5);
    --header-bg: linear-gradient(90deg, rgba(74, 144, 226, 0.9) 0%, rgba(92, 169, 251, 0.9) 100%);
    --text-color: #333333;
    --input-bg: rgba(255, 255, 255, 0.8);
    --button-color: #4A90E2;
    --user-message-bg: rgba(227, 242, 253, 0.7);
    --ai-message-bg: rgba(255, 248, 225, 0.7);
    --sidebar-bg: rgba(255, 255, 255, 0.5);
    --sidebar-hover: rgba(74, 144, 226, 0.1);
    --sidebar-active: rgba(74, 144, 226, 0.2);
}

.dark-theme {
    --bg-color: #1a1a1a;
    --container-bg: #2c2c2c;
    --header-bg: #3a3a3a;
    --text-color: #ffffff;
    --input-bg: #3a3a3a;
    --button-color: #4a90e2;
    --user-message-bg: #2c5282;
    --ai-message-bg: #4a2c5a;
    --sidebar-bg: #252525;
    --sidebar-hover: #333333;
    --sidebar-active: #3a3a3a;
}

body {
    font-family: 'Roboto', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg-gradient);
    color: var(--text-color);
    transition: background-color 0.3s ease;
    min-height: 100vh;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.app-container {
    display: flex;
    max-width: 1200px;
    margin: 20px auto;
    height: 90vh;
    background-color: var(--container-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.sidebar {
    width: 250px;
    min-width: 250px; /* 添加这行，确保侧边栏不会被挤压 */
    background-color: var(--sidebar-bg);
    border-radius: 12px;
    margin: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.sidebar-header h2 {
    margin: 0 0 10px 0;
    font-size: 16px; /* 减小字体大小 */
}

.new-chat-btn {
    width: 100%;
    padding: 8px; /* 减小padding */
    background-color: var(--button-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-size: 14px; /* 减小字体大小 */
}

.new-chat-btn:hover {
    background-color: #3a7bc8;
}

.chat-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.chat-list-item {
    padding: 12px 15px; /* 减小padding */
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px; /* 减小字体大小 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-name {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-item:hover {
    background-color: var(--sidebar-hover);
}

.chat-list-item.active {
    background-color: var(--sidebar-active);
}

.chat-actions {
    display: none;
}

.chat-list-item:hover .chat-actions {
    display: block;
}

.chat-actions button {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 5px;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.chat-actions button:hover {
    opacity: 1;
}

.chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--container-bg);
    border-radius: 12px;
    margin: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* 添加这一行 */
}

.chat-header {
    background: var(--header-bg);
    color: white;
    padding: 10px 20px; /* 增加头部的内边距 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px; /* 添加这一行 */
    border-top-right-radius: 12px; /* 添加这一行 */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.theme-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 18px; /* 减小字体大小 */
    cursor: pointer;
    margin-left: 15px; /* 增加与标题的间距 */
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
}

.message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
    max-width: 80%; /* 限制消息最大宽度 */
    transition: none;
}

.message-content {
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word; /* 允许长单词换行 */
    overflow-wrap: break-word; /* 允许长单词换行 */
    background-color: var(--container-bg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.user-message {
    flex-direction: row-reverse;
    margin-left: auto;
}

.user-message .message-content {
    background-color: var(--user-message-bg);
    color: var(--text-color);
    margin-left: 10px;
}

.ai-message .message-content {
    background-color: var(--ai-message-bg);
    color: var(--text-color);
    margin-right: 10px;
}

.avatar {
    width: 36px; /* 减小头像大小 */
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px; /* 减小图标大小 */
    color: white;
}

.icon-avatar {
    background-color: var(--button-color);
}

.user-message .icon-avatar {
    background-color: #4CAF50;
}

.ai-message .icon-avatar {
    background-color: #2196F3;
}

.message-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.message-name {
    font-size: 11px; /* 减小字体大小 */
    margin-top: 3px;
    color: var(--text-color);
}

.chat-input {
    display: flex;
    padding: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

#userInput {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid var(--input-bg);
    border-radius: 24px;
    resize: none;
    font-size: 14px;
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
}

#userInput:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--button-color);
}

.send-button {
    background-color: var(--button-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    margin-left: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
}

.send-button:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.send-button i {
    font-size: 18px;
}

.loading-message .message-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
}

.loading-animation {
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-animation div {
    width: 8px;
    height: 8px;
    margin: 0 4px;
    background-color: var(--text-color);
    border-radius: 50%;
    animation: loading 1s infinite ease-in-out;
}

.loading-animation div:nth-child(1) {
    animation-delay: 0.2s;
}

.loading-animation div:nth-child(2) {
    animation-delay: 0.4s;
}

.loading-animation div:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes loading {
    0%, 100% {
        transform: scale(0.5);
        opacity: 0.5;
    }
    50% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .sidebar, .chat-container {
        width: auto;
        margin: 5px;
        border-radius: 8px;
    }

    .sidebar {
        height: auto;
        max-height: 30vh;
    }

    .chat-container {
        flex-grow: 1;
    }
}

/* 修改这些样式 */

.chat-list-item .edit-icon,
.chat-header .edit-icon {
    margin-right: 5px;
    color: var(--text-color);
    opacity: 0.7; /* 将透明度设置为固定值 */
    transition: opacity 0.3s ease;
    cursor: pointer;
}

/* 删除或注释掉这些样式 */
/*
.chat-list-item:hover .edit-icon,
.chat-header:hover .edit-icon {
    opacity: 0.7;
}
*/

.chat-list-item .edit-icon:hover,
.chat-header .edit-icon:hover {
    opacity: 1;
}

.chat-header .edit-icon {
    color: white;
}

/* 添加一些微妙的动画效果 */
@keyframes gradientAnimation {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

body {
    background-size: 200% 200%;
    animation: gradientAnimation 15s ease infinite;
}

/* 为按钮添加一些悬停效果 */
.new-chat-btn:hover,
.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
}

/* 如果你想保留一些基本样式但去掉悬停效果，可以这样修改 */
.message {
    transition: none;
}

.message:hover {
    transform: none;
    box-shadow: none;
}

/* 在现有的 CSS 中添加或修改以下样式 */

.chat-list-item .chat-name,
.chat-header .chat-title {
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    outline: none;
    border: none;
}

.chat-list-item .chat-name:focus,
.chat-header .chat-title:focus {
    background-color: rgba(74, 144, 226, 0.1);
}

.chat-list-item .chat-name {
    display: inline-block;
    max-width: calc(100% - 30px); /* 为删除按钮留出空间 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header .chat-title {
    display: inline-block;
    max-width: calc(100% - 100px); /* 增加最大宽度，为主题切换按钮和编辑图标留出更多空间 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: white;
    font-size: 20px; /* 可以根据需要调整字体大小 */
    padding: 5px 10px; /* 增加一些内边距 */
}

/* 移除之前的编辑图标相关样式 */
.chat-list-item .edit-icon,
.chat-header .edit-icon {
    display: none;
}

/* 在文件末尾添加或修改以下样式 */

.chat-list-item .edit-icon,
.chat-header .edit-icon {
    display: inline-block;
    margin-right: 5px;
    color: var(--text-color);
    opacity: 0.7;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.chat-list-item .edit-icon:hover,
.chat-header .edit-icon:hover {
    opacity: 1;
}

.chat-header .edit-icon {
    color: white;
}

.chat-list-item .chat-name,
.chat-header .chat-title {
    display: inline-block;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    outline: none;
    border: none;
}

.chat-list-item .chat-name:focus,
.chat-header .chat-title:focus {
    background-color: rgba(74, 144, 226, 0.1);
}

.chat-list-item .chat-name {
    max-width: calc(100% - 60px); /* 为编辑和删除按钮留出空间 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header .chat-title {
    max-width: calc(100% - 70px); /* 为编辑图标和主题切换按钮留出空间 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: white;
}