/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

:root {
    --glass-background: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: rgba(0, 0, 0, 0.1);
    --text-color: #f8f8f8;
    --dark-text: #333;
    --accent-color: #4285f4;
    --border-radius: 16px;
    --spacing: 16px;
}

body {
    min-height: 100vh;
    color: var(--text-color);
    overflow: hidden;
}

/* 背景样式 */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    overflow: hidden;
}

.background-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://bing.img.run/1920x1080.php');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -2;
    animation: backgroundFadeIn 1s ease-in-out;
}

.background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

/* 毛玻璃效果 */
.glass-effect {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px var(--glass-shadow);
}

/* 按钮样式 */
.glass-button {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}

.glass-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.glass-button:active {
    transform: translateY(0);
}

/* 帮助按钮样式 */
.help-button {
    margin-right: 10px;
}

/* 自定义滚动条 */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 容器和布局 */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: var(--spacing);
    gap: var(--spacing);
}

/* 顶部栏 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* 主要内容区 */
.content {
    display: flex;
    flex: 1;
    gap: var(--spacing);
    height: calc(100vh - 80px - var(--spacing) * 2);
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    display: flex;
    flex-direction: column;
    width: 280px;
    height: 100%;
    padding: var(--spacing);
    overflow-y: hidden;
    position: relative;
}

.models-section {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px); /* 为清除按钮留出空间 */
}

.models-section h2 {
    background: transparent !important;
    margin-bottom: 8px;
}

/* 左侧栏滚动设置修改 */
.models-container {
    overflow-y: auto;
    margin-top: 10px;
    padding-right: 5px;
    height: calc(100% - 80px); /* 固定高度，减去搜索框和标题的高度 */
}

.model-elements-wrapper {
    padding-bottom: 60px; /* 确保底部有足够空间，不会被按钮遮挡 */
}

.roles-section {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

.roles-container {
    height: auto;
    max-height: 30vh;
    overflow-y: auto;
    margin-top: 10px;
    padding-right: 5px;
}

.sidebar h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    font-weight: 500;
    position: sticky;
    top: 0;
    background: var(--glass-background);
    padding: 5px 0;
    z-index: 1;
}

/* 模型和角色项 */
.model-item, .role-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.model-item:hover, .role-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.model-item.active, .role-item.active {
    background: rgba(255, 255, 255, 0.2);
}

.model-avatar, .role-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.model-info, .role-info {
    flex: 1;
}

.model-name, .role-name {
    font-weight: 500;
    margin-bottom: 3px;
}

.model-description, .role-description {
    font-size: 0.8rem;
    opacity: 0.8;
}

.clear-button {
    width: 100%;
    position: absolute;
    bottom: var(--spacing);
    left: var(--spacing);
    right: var(--spacing);
    width: calc(100% - var(--spacing) * 2);
    z-index: 10;
    margin-top: 10px;
}

/* 提示框样式 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(10px);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    min-width: 250px;
    max-width: 350px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s, transform 0.3s;
    border-left: 4px solid #777;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-left-color: #4CAF50;
}

.toast-error {
    border-left-color: #F44336;
}

.toast-warning {
    border-left-color: #FFC107;
}

.toast-info {
    border-left-color: #2196F3;
}

.toast-icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-icon img {
    width: 20px;
    height: 20px;
}

.toast-message {
    font-size: 14px;
    flex: 1;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .toast {
        top: 10px;
        right: 10px;
        left: 10px;
        width: calc(100% - 20px);
        max-width: none;
    }
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: var(--spacing);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: var(--spacing);
}

.empty-chat-message {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    opacity: 0.7;
}

.empty-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.empty-subtitle {
    font-size: 1rem;
}

.chat-input-area {
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    resize: none;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    max-height: 150px;
    min-height: 48px;
}

#user-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
}

.send-button {
    align-self: flex-end;
}

/* 消息样式 */
.message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in-out;
}

.user-message {
    justify-content: flex-end;
}

.ai-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 80%;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.user-bubble {
    background: rgba(66, 133, 244, 0.2);
    padding: 12px 16px;
    border-radius: 16px 16px 0 16px;
}

.ai-bubble {
    margin-bottom: 4px;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 4px;
}

/* 登录模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 320px;
    padding: 24px;
    text-align: center;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal h2 {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.form-group input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
}

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

@keyframes backgroundFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Markdown格式化 */
.markdown-content {
    line-height: 1.6;
}

.markdown-content h1, .markdown-content h2, .markdown-content h3, 
.markdown-content h4, .markdown-content h5, .markdown-content h6 {
    margin-top: 1em;
    margin-bottom: 0.5em;
}

.markdown-content p {
    margin-bottom: 1em;
}

.markdown-content code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
}

.markdown-content pre {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
}

.markdown-content ul, .markdown-content ol {
    padding-left: 20px;
    margin-bottom: 1em;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1em;
}

.markdown-content th, .markdown-content td {
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px;
    text-align: left;
}

.markdown-content th {
    background: rgba(0, 0, 0, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: calc(var(--spacing) / 2);
    }
    
    .content {
        flex-direction: column;
        height: calc(100vh - 70px - var(--spacing));
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
    }
    
    .chat-area {
        height: 60vh;
    }
    
    .sidebar.collapsed {
        max-height: 50px;
        overflow: hidden;
    }
    
    .collapse-button {
        display: block;
    }
    
    .model-search-section {
        flex-direction: column;
        gap: 8px;
    }
    
    .sort-button {
        width: 100%;
    }
}

/* 取消按钮 */
.cancel-generation {
    background-color: rgba(255, 59, 48, 0.2);
    font-size: 0.8rem;
    padding: 4px 8px;
    margin-left: 8px;
    vertical-align: middle;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: white;
    border-radius: 50%;
    margin: 0 2px;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0.7;
    }
}

/* 模型搜索和排序 */
.model-search-section {
    display: flex;
    margin-bottom: 10px;
    gap: 5px;
}

.search-container {
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    font-size: 0.9rem;
}

.search-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
}

.sort-button {
    padding: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* 思考内容格式 */
.thinking-content {
    background: rgba(70, 70, 70, 0.2);
    padding: 10px;
    border-radius: 8px;
    margin: 8px 0;
    font-size: 0.9em;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

/* 移除等待指示器 */
.message.ai-message.waiting.removed .typing-indicator,
.message.ai-message.waiting.removed .cancel-generation,
.message.ai-message.waiting.error .typing-indicator,
.message.ai-message.waiting.cancelled .typing-indicator {
    display: none;
}

/* 允许用户提问和AI回答的文本可以选中 */
.ai-response, 
.user-message .message-text, 
.ai-message .message-text {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 允许输入框中的文本可以选中 */
textarea, input, #message-input {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 删除账户按钮和退出菜单相关样式，这些样式不再需要了 */
.account-button,
.account-icon,
.logout-menu,
.logout-option {
    display: none;
}

/* 退出登录按钮样式 */
.logout-button {
    position: absolute;
    padding: 8px 12px;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
}

.logout-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 确认对话框样式 */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.dialog-container {
    width: 400px;
    max-width: 90%;
    background-color: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(15px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: dialog-appear 0.3s ease-out;
}

@keyframes dialog-appear {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dialog-header {
    padding: 15px;
    font-size: 18px;
    font-weight: 600;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dialog-content {
    padding: 20px 15px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    line-height: 1.5;
}

.dialog-buttons {
    padding: 10px 15px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.dialog-button {
    padding: 8px 15px;
    margin-left: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    background: none;
    border: none;
    color: white;
}

.dialog-button.cancel-button {
    background-color: rgba(255, 255, 255, 0.1);
}

.dialog-button.confirm-button {
    background-color: #3a7bd5;
}

.dialog-button.cancel-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.dialog-button.confirm-button:hover {
    background-color: #4a8be5;
}

/* 登录警告提示 */
.login-warning {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    padding: 15px 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    min-width: 240px;
    max-width: 300px;
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-left: 4px solid #ff9800;
    pointer-events: auto;
}

.login-warning.show {
    transform: translateY(0);
    opacity: 1;
}

.warning-content {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.warning-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    flex-shrink: 0;
}

.warning-content span {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    line-height: 1.4;
}

.warning-actions {
    display: flex;
    justify-content: flex-end;
}

.warning-actions .login-btn {
    font-size: 13px;
    padding: 6px 12px;
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.warning-actions .login-btn:hover {
    background: rgba(255, 152, 0, 0.25);
    transform: translateY(-1px);
}

.warning-actions .login-btn:active {
    transform: translateY(0);
}

/* 添加API状态指示器样式 */
.api-status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 8px;
    position: relative;
    top: 2px;
    cursor: help;
}

.api-status-indicator.loading {
    background-color: #f39c12;
    animation: pulse 1.5s infinite;
}

.api-status-indicator.success {
    background-color: #2ecc71;
}

.api-status-indicator.error {
    background-color: #e74c3c;
}

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

/* 可能需要调整header-left样式 */
.header-left {
    display: flex;
    align-items: center;
}

/* 添加退出登录按钮样式 */
.logout-button-style {
    background-color: rgba(236, 112, 99, 0.2);
    color: #fff;
    transition: all 0.3s ease;
}

.logout-button-style:hover {
    background-color: rgba(236, 112, 99, 0.3);
} 