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

:root {
    /* 主色调 */
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    
    /* 渐变色 */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    
    /* 背景色 */
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-glass: rgba(255, 255, 255, 0.05);
    
    /* 文字色 */
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* 边框色 */
    --border-primary: rgba(255, 255, 255, 0.1);
    --border-secondary: rgba(255, 255, 255, 0.05);
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* 圆角 */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* 字体 */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* 应用容器 */
.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* 背景动画 */
.background-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.floating-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.1), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.05), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.08), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.06), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255, 255, 255, 0.04), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: particlesFloat 20s linear infinite;
}

@keyframes particlesFloat {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-200px, -100px); }
}

.gradient-orbs {
    position: absolute;
    width: 100%;
    height: 100%;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.3;
    animation: orbFloat 15s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: var(--gradient-primary);
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 200px;
    height: 200px;
    background: var(--gradient-secondary);
    top: 60%;
    right: 10%;
    animation-delay: 5s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: var(--gradient-accent);
    bottom: 10%;
    left: 50%;
    animation-delay: 10s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* 主界面 */
.main-interface {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    background: rgba(15, 15, 35, 0.8);
}

/* 头部 */
.app-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--gradient-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: logoGlow 3s ease-in-out infinite;
}

.logo-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

@keyframes logoGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(102, 102, 241, 0.3); }
    50% { box-shadow: 0 0 30px rgba(102, 102, 241, 0.6); }
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #10b981;
    animation: statusPulse 2s ease-in-out infinite;
}

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

.status-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    overflow: hidden;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.chat-messages {
    height: 100%;
    overflow-y: auto;
    padding-right: 0.5rem;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--border-secondary);
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    margin-top: 2rem;
    animation: fadeInUp 1s ease-out;
}

.welcome-icon {
    width: 4rem;
    height: 4rem;
    background: var(--gradient-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: white;
    animation: welcomeFloat 3s ease-in-out infinite;
}

.welcome-icon svg {
    width: 2rem;
    height: 2rem;
}

@keyframes welcomeFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-message h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

/* 消息样式 */
.message {
    margin-bottom: 1.5rem;
    animation: messageSlideIn 0.5s ease-out;
}

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

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

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

.message-content {
    max-width: 70%;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-xl);
    position: relative;
    backdrop-filter: blur(10px);
}

.message-user .message-content {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.message-ai .message-content {
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-bottom-left-radius: var(--radius-sm);
}

.message-content p {
    margin: 0;
    line-height: 1.6;
}

.message-content pre {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin: 0.5rem 0;
    overflow-x: auto;
    border: 1px solid var(--border-primary);
}

.message-content code {
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
}

/* 打字机效果 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    border-bottom-left-radius: var(--radius-sm);
    max-width: 70%;
    backdrop-filter: blur(10px);
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.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 typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* 输入区域 */
.input-section {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
}

.input-container {
    max-width: 1200px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    min-height: 1.5rem;
    max-height: 8rem;
    font-family: var(--font-family);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    gap: 0.5rem;
}

.clear-btn,
.send-btn {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.clear-btn {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.send-btn {
    background: var(--gradient-primary);
    color: white;
    transform: scale(1);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

.send-btn svg,
.clear-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.char-count {
    font-family: monospace;
}

.input-hint {
    font-style: italic;
}

/* 配置按钮 */
.config-btn {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    padding: 8px;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 12px;
}

.config-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* 配置弹窗 */
.config-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.config-content {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.config-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.config-body {
    padding: 24px;
}

.config-item {
    margin-bottom: 20px;
    position: relative;
}

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

.config-item input {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.config-item input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
    margin-top: 16px;
}

.toggle-btn:hover {
    background: rgba(139, 92, 246, 0.1);
}

.config-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.save-btn, .test-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn {
    background: var(--primary-color);
    color: white;
}

.save-btn:hover {
    background: #7c3aed;
    transform: translateY(-1px);
}

.test-btn {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.test-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
    transform: translateY(-1px);
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 35, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    position: relative;
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spinnerRotate 1s linear infinite;
}

.spinner-ring:nth-child(1) {
    animation-delay: 0s;
}

.spinner-ring:nth-child(2) {
    animation-delay: 0.3s;
    border-top-color: var(--primary-light);
}

.spinner-ring:nth-child(3) {
    animation-delay: 0.6s;
    border-top-color: var(--primary-dark);
}

@keyframes spinnerRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.125rem;
    color: var(--text-secondary);
    animation: loadingPulse 2s ease-in-out infinite;
}

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

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

/* 响应式设计 */
@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .chat-container {
        padding: 1rem;
    }
    
    .input-section {
        padding: 1rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .welcome-message {
        padding: 2rem 1rem;
    }
    
    .welcome-message h2 {
        font-size: 1.5rem;
    }
    
    .welcome-message p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .input-wrapper {
        padding: 0.75rem;
    }
    
    .input-actions {
        flex-direction: column;
    }
    
    .app-title {
        font-size: 1.25rem;
    }
    
    .orb {
        display: none;
    }
}