/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background: #ffffff;
    color: #1f1f1f;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* 主应用容器 */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    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: #9ca3af;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 8px;
}

.chat-history-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 2px;
    font-size: 13px;
    color: #4b5563;
    background: transparent;
}

.chat-history-item:hover {
    background: #e5e7eb;
}

.chat-history-item.active {
    background: #e0e7ff;
    color: #3730a3;
    font-weight: 500;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
}

.user-status {
    font-size: 11px;
    color: #6b7280;
}

/* 主聊天区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
}

/* 聊天头部 */
.chat-header {
    padding: 14px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.chat-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.action-btn {
    padding: 8px 14px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.action-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #111827;
}

/* 模型选择器样式 */
.model-selector label {
    font-size: 13px;
    font-weight: 500;
    color: #4b5563;
}

.model-selector select {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #ffffff;
    color: #111827;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;
}

.model-selector select:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.model-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* 消息样式 */
#chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 200px;
    min-height: 0;
    background: #ffffff;
}

#chat-history::-webkit-scrollbar {
    width: 6px;
}

#chat-history::-webkit-scrollbar-track {
    background: transparent;
}

#chat-history::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#chat-history::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 消息容器 */
.message-container {
    margin-bottom: 16px;
    max-width: 75%;
    animation: fadeInUp 0.2s ease-out;
}

@keyframes fadeInUp {
    from { 
        opacity: 0; 
        transform: translateY(8px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
    }
}

.user-message-container {
    margin-left: auto;
}

.ai-message-container {
    margin-right: auto;
}

/* 消息气泡 */
.message {
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    max-width: 100%;
    line-height: 1.6;
    font-size: 14px;
}

.user-message {
    background: #111827;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ai-message {
    background: #f9fafb;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

/* 加载动画 */
.loading-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 8px 0;
}

.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 #e5e7eb;
    padding: 16px 24px;
    position: fixed;
    bottom: 0;
    left: 260px;
    right: 0;
    z-index: 99;
    box-sizing: border-box;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 800px;
    margin: 0 auto;
}

textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s ease;
    background: #ffffff;
    color: #111827;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

textarea::placeholder {
    color: #9ca3af;
}

.input-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

/* 发送按钮 */
.send-btn {
    width: 44px;
    height: 44px;
    background: #111827;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: #000000;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 输入提示 */
.input-hint {
    text-align: right;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 8px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* 初始欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 100px 20px 60px;
    color: #6b7280;
}

.welcome-message .welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-message .welcome-text {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #111827;
}

.welcome-message .welcome-subtext {
    font-size: 14px;
    color: #6b7280;
}

/* 代码块样式 */
.message-content pre {
    background: #1f2937 !important;
    color: #e5e7eb !important;
    padding: 14px !important;
    margin: 10px 0 !important;
    overflow-x: auto !important;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    border-radius: 8px !important;
}

.message-content code {
    background: #f3f4f6 !important;
    padding: 2px 5px !important;
    border-radius: 4px !important;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace !important;
    font-size: 13px !important;
    color: #dc2626 !important;
}

.message-content pre code {
    background: none !important;
    padding: 0 !important;
    color: inherit !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 260px;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        width: 100%;
    }
    
    .input-container {
        left: 0;
        padding: 12px 16px;
    }
    
    #chat-history {
        padding: 16px;
        padding-bottom: 180px;
    }
    
    .chat-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .chat-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .message {
        max-width: 88%;
    }
}

/* 移动端菜单按钮 */
.mobile-menu-toggle {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1001;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
}

/* 错误消息 */
.error-message {
    background: #fef2f2 !important;
    border-color: #fecaca !important;
    color: #dc2626 !important;
}

/* 自定义提示框 */
.custom-alert {
    position: fixed;
    top: 16px;
    right: 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10000;
    animation: slideInRight 0.2s ease-out;
    max-width: 320px;
}

@keyframes slideInRight {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.custom-alert .alert-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.custom-alert.error { border-left: 3px solid #ef4444; }
.custom-alert.error .alert-icon { color: #ef4444; }

.custom-alert.success { border-left: 3px solid #10b981; }
.custom-alert.success .alert-icon { color: #10b981; }

.custom-alert.warning { border-left: 3px solid #f59e0b; }
.custom-alert.warning .alert-icon { color: #f59e0b; }

.custom-alert .alert-content {
    flex: 1;
}

.custom-alert .alert-message {
    font-size: 13px;
    color: #374151;
    line-height: 1.4;
}

.custom-alert .alert-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #9ca3af;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.custom-alert .alert-close:hover {
    background: #f3f4f6;
    color: #4b5563;
}