/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: #ffffff;
    color: #1f2937;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* 主应用容器 */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 280px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.logo-icon {
    font-size: 20px;
}

.logo-text {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.new-chat-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 8px;
}

.chat-history-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background: #e2e8f0;
}

.chat-history-item.active {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 500;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 12px;
    color: #64748b;
}

/* 主聊天区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
}

/* 聊天头部 */
.chat-header {
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 8px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
    height: auto;
    min-width: auto;
}

.action-btn:hover {
    background: #f3f4f6;
}

/* 模型选择器样式 */
.model-selector {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-selector label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.model-selector select {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.model-selector select:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.model-selector select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 消息样式 */
#chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 200px;
    min-height: 0;
}

#chat-history::-webkit-scrollbar {
    width: 6px;
}

#chat-history::-webkit-scrollbar-track {
    background: #f1f5f9;
}

#chat-history::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#chat-history::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 消息容器 */
.message-container {
    margin-bottom: 24px;
    max-width: 85%;
    animation: fadeInUp 0.3s ease-out;
}

.user-message-container {
    margin-left: auto;
}

.ai-message-container {
    margin-right: auto;
}

/* 消息图片预览 */
.message-image-preview {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-image-preview img {
    width: 100%;
    height: auto;
    object-fit: cover;
    max-height: 300px;
}

.message {
    padding: 16px 20px;
    border-radius: 12px;
    word-wrap: break-word;
    max-width: 100%;
}

@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(10px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
    }
}

.user-message {
    background: #3b82f6;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message {
    background: #f8fafc;
    color: #1f2937;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* 思考过程样式 */
.thinking-container {
    margin-bottom: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.thinking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f1f5f9;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
}

.thinking-header:hover {
    background: #e2e8f0;
}

.thinking-title {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.thinking-title::before {
    content: "🧠";
    font-size: 14px;
}

.toggle-icon {
    font-size: 12px;
    color: #64748b;
    transition: transform 0.2s ease;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.thinking-content {
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.thinking-content.expanded {
    display: block;
}

.thinking-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.thinking-content li {
    margin-bottom: 8px;
}

/* 加载动画 */
.loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: #6b7280;
    border-radius: 50%;
    animation: loading 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 输入区域 */
.input-container {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 20px 24px;
    position: fixed;
    bottom: 0;
    left: 280px;
    right: 0;
    z-index: 99;
    box-sizing: border-box;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    width: 100%;
}

textarea {
    flex: 1;
    min-height: 48px;
    max-height: 200px;
    height: 120px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s ease;
    background: #ffffff;
    color: #1f2937;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea::placeholder {
    color: #9ca3af;
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-bottom: 0;
    flex-shrink: 0;
}

.input-options {
    display: flex;
    gap: 12px;
    align-items: center;
}

.option-btn {
    padding: 8px 16px;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    height: auto;
    min-width: auto;
}

.option-btn:hover {
    background: #e2e8f0;
    color: #475569;
}

/* 数学公式样式 */
.math-inline {
    font-family: 'Cambria Math', 'STIX Two Text', 'Times New Roman', serif !important;
    font-style: italic !important;
    background: #f8fafc !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    border: 1px solid #e2e8f0 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.math-block {
    font-family: 'Cambria Math', 'STIX Two Text', 'Times New Roman', serif !important;
    font-style: italic !important;
    background: #f8fafc !important;
    padding: 16px !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    font-size: 16px !important;
    line-height: 1.6 !important;
    text-align: center !important;
    margin: 16px 0 !important;
    display: block !important;
}

/* 代码块样式 */
pre {
    background: #0f172a !important;
    color: #e2e8f0 !important;
    padding: 16px !important;
    margin: 0 !important;
    overflow-x: auto !important;
    font-family: 'Courier New', monospace !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    border-radius: 4px !important;
}

code {
    background: #f1f5f9 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    border: 1px solid #e2e8f0 !important;
    font-family: 'Courier New', monospace !important;
    font-size: 13px !important;
    color: #374151 !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        width: 100%;
    }
    
    .input-container {
        left: 0;
        padding: 16px;
    }
    
    #chat-history {
        padding: 16px;
        padding-bottom: 220px;
    }
    
    .chat-header {
        padding: 16px;
    }
    
    .input-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .input-actions {
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
    }
    
    .send-btn {
        width: 100%;
    }
    
    textarea {
        height: 100px;
    }
}

/* 移动端菜单按钮 */
.mobile-menu-toggle {
    display: none;
    padding: 8px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    color: #374151;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
        position: absolute;
        top: 16px;
        left: 16px;
        z-index: 1001;
    }
}

/* 侧边栏中的模型选择器 */
.model-selector-full {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
}

.model-selector-full:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.model-selector-full:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 清空对话按钮 */
.clear-chat-btn {
    width: 100%;
    padding: 10px;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-chat-btn:hover {
    background: #e2e8f0;
    color: #475569;
}

/* 输入提示 */
.input-hint {
    text-align: right;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 8px;
}

/* 发送按钮 */
.send-btn {
    padding: 12px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #2563eb;
}

.send-btn:active {
    background: #1d4ed8;
}

/* 遮罩层 */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.overlay.active {
    display: block;
}

/* 图像生成结果样式 */
.image-result {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 16px 0;
}

.generated-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.image-download {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background: #f3f4f6;
    color: #374151;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.image-download:hover {
    background: #e5e7eb;
    color: #1f2937;
}

/* 视频生成结果样式 */
.video-result {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 16px 0;
}

.generated-video {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.video-download {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background: #f3f4f6;
    color: #374151;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.video-download:hover {
    background: #e5e7eb;
    color: #1f2937;
}

/* 初始欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.welcome-message .welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-message .welcome-text {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #475569;
}

.welcome-message .welcome-subtext {
    font-size: 14px;
    color: #94a3b8;
}

/* 自定义提示框样式 */
.custom-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: slideInRight 0.3s ease-out;
    max-width: 320px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.custom-alert .alert-icon {
    font-size: 20px;
    color: #f59e0b;
}

.custom-alert .alert-content {
    flex: 1;
}

.custom-alert .alert-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.custom-alert .alert-message {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

.custom-alert .alert-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.custom-alert .alert-close:hover {
    background: #f3f4f6;
    color: #6b7280;
}

/* 错误提示框 */
.custom-alert.error {
    border-left: 4px solid #ef4444;
}

.custom-alert.error .alert-icon {
    color: #ef4444;
}

/* 成功提示框 */
.custom-alert.success {
    border-left: 4px solid #10b981;
}

.custom-alert.success .alert-icon {
    color: #10b981;
}

/* 警告提示框 */
.custom-alert.warning {
    border-left: 4px solid #f59e0b;
}

.custom-alert.warning .alert-icon {
    color: #f59e0b;
}

/* 信息提示框 */
.custom-alert.info {
    border-left: 4px solid #3b82f6;
}

.custom-alert.info .alert-icon {
    color: #3b82f6;
}