* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --accent-color: #06b6d4;
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a3e;
    --bg-tertiary: #2d2d5f;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border-color: #374151;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow: rgba(0, 0, 0, 0.3);
    --glow: rgba(99, 102, 241, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* 背景动画 */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
    opacity: 0.6;
    animation: float 6s ease-in-out infinite;
}

.particle:nth-child(1) {
    top: 20%;
    left: 20%;
    animation-delay: 0s;
    animation-duration: 8s;
}

.particle:nth-child(2) {
    top: 60%;
    left: 80%;
    animation-delay: 2s;
    animation-duration: 6s;
}

.particle:nth-child(3) {
    top: 80%;
    left: 30%;
    animation-delay: 4s;
    animation-duration: 10s;
}

.particle:nth-child(4) {
    top: 40%;
    left: 70%;
    animation-delay: 1s;
    animation-duration: 7s;
}

.particle:nth-child(5) {
    top: 10%;
    left: 60%;
    animation-delay: 3s;
    animation-duration: 9s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0.6; }
    25% { transform: translateY(-20px) rotate(90deg); opacity: 1; }
    50% { transform: translateY(-40px) rotate(180deg); opacity: 0.8; }
    75% { transform: translateY(-20px) rotate(270deg); opacity: 1; }
}

/* 头部样式 */
.header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(26, 26, 62, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo i {
    color: var(--primary-color);
    font-size: 2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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

/* 消息样式 */
.message-wrapper {
    display: flex;
    margin-bottom: 1.5rem;
    animation: slideIn 0.3s ease-out;
}

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

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

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin: 0 0.75rem;
    flex-shrink: 0;
}

.user-avatar {
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    color: white;
    order: 2;
}

.bot-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.message {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.user-message .message {
    align-items: flex-end;
}

.bot-message .message {
    align-items: flex-start;
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    margin-bottom: 0.25rem;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 4px 12px var(--shadow);
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-bottom-right-radius: 0.5rem;
}

.bot-message .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

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

/* 打字机光标效果 */
.typewriter-cursor::after {
    content: '|';
    font-weight: 100;
    color: var(--primary-color);
    animation: blink-cursor 1s infinite;
}

@keyframes blink-cursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 打字机效果的消息内容 */
.typing-message .message-content p {
    position: relative;
}

.typing-message .message-content p::after {
    content: '|';
    font-weight: 100;
    color: var(--primary-color);
    animation: blink-cursor 1s infinite;
    margin-left: 2px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0 0.5rem;
}

/* 打字效果 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border-radius: 1.25rem;
    border-bottom-left-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 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 typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* 输入区域 */
.input-container {
    padding: 1.5rem 2rem 2rem;
    border-top: 1px solid var(--border-color);
    background: rgba(26, 26, 62, 0.8);
    backdrop-filter: blur(10px);
}

.input-wrapper {
    position: relative;
}

.input-box {
    display: flex;
    align-items: flex-end;
    background: var(--bg-tertiary);
    border-radius: 1.5rem;
    border: 2px solid var(--border-color);
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
}

.input-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--glow);
}

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

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

.send-button {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 0.75rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

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

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

.char-count {
    color: var(--text-muted);
}

.tip {
    color: var(--text-muted);
}

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

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

.loading-spinner {
    text-align: center;
    color: var(--text-primary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* 提示消息 */
.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px var(--shadow);
    display: none;
    align-items: center;
    gap: 0.75rem;
    z-index: 1001;
    backdrop-filter: blur(10px);
    animation: toastSlide 0.3s ease-out;
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.show {
    display: flex;
}

.toast.success {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
}

.toast.error {
    border-color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

.toast.warning {
    border-color: var(--warning-color);
    background: rgba(245, 158, 11, 0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        height: 100vh;
    }

    .header {
        padding: 1rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .logo i {
        font-size: 1.5rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .input-container {
        padding: 1rem;
    }

    .message {
        max-width: 85%;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        margin: 0 0.5rem;
    }

    .toast {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        margin: 0;
    }
}

@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .message {
        max-width: 90%;
    }

    .input-footer {
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }
}
