/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f0f23;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: #1a1a2e;
    border-left: 1px solid #2a2a3e;
    border-right: 1px solid #2a2a3e;
}

/* Header */
.chat-header {
    background: #16213e;
    border-bottom: 1px solid #2a2a3e;
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.chat-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #0ea5e9;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: #0284c7;
    transform: translateY(-1px);
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.messages-container {
    max-width: 100%;
    margin: 0 auto;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.welcome-message h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

/* Message Styles */
.message {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease-out;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.message-content {
    flex: 1;
    max-width: calc(100% - 48px);
}

.message-bubble {
    padding: 0.875rem 1.125rem;
    border-radius: 1rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: #0ea5e9;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-bubble {
    background: #2a2a3e;
    color: #ffffff;
    border: 1px solid #3a3a4e;
    border-bottom-left-radius: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.25rem;
    text-align: right;
}

.message.assistant .message-time {
    text-align: left;
}

/* Input Area */
.chat-footer {
    background: #16213e;
    border-top: 1px solid #2a2a3e;
    padding: 1rem 1.5rem;
}

.input-container {
    max-width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: #2a2a3e;
    border: 1px solid #3a3a4e;
    border-radius: 1rem;
    padding: 0.75rem;
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: #0ea5e9;
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    font-family: inherit;
}

#messageInput::placeholder {
    color: #64748b;
}

.send-button {
    background: #0ea5e9;
    border: none;
    border-radius: 0.5rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: #0284c7;
    transform: translateY(-1px);
}

.send-button:disabled {
    background: #374151;
    cursor: not-allowed;
    opacity: 0.5;
}

.input-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.char-count {
    font-size: 0.75rem;
    color: #64748b;
}

/* Loading Indicator */
.loading-indicator {
    display: none;
    padding: 1rem 0;
}

.loading-dots {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: #0ea5e9;
    border-radius: 50%;
    animation: bounce 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; }

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Scrollbar Styling */
.chat-main::-webkit-scrollbar {
    width: 6px;
}

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

.chat-main::-webkit-scrollbar-thumb {
    background: #3a3a4e;
    border-radius: 3px;
}

.chat-main::-webkit-scrollbar-thumb:hover {
    background: #4a4a5e;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        border-left: none;
        border-right: none;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .chat-footer {
        padding: 1rem;
    }
    
    .chat-main {
        padding: 0.5rem;
    }
    
    .message {
        margin-bottom: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .new-chat-btn {
        justify-content: center;
    }
}

/* Markdown样式 */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
    margin: 0.75rem 0 0.5rem 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-bubble h1 { font-size: 1.5rem; }
.message-bubble h2 { font-size: 1.3rem; }
.message-bubble h3 { font-size: 1.1rem; }

.message-bubble p {
    margin: 0.5rem 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-bubble li {
    margin: 0.25rem 0;
}

.message-bubble blockquote {
    border-left: 3px solid #0ea5e9;
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: #94a3b8;
    font-style: italic;
}

.message-bubble a {
    color: #0ea5e9;
    text-decoration: none;
}

.message-bubble a:hover {
    text-decoration: underline;
}

.message-bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
}

.message-bubble th,
.message-bubble td {
    border: 1px solid #3a3a4e;
    padding: 0.5rem;
    text-align: left;
}

.message-bubble th {
    background: #2a2a3e;
    font-weight: 600;
}

.message-bubble hr {
    border: none;
    border-top: 1px solid #3a3a4e;
    margin: 1rem 0;
}

/* 代码块样式 */
.message-bubble pre {
    background: #1e1e2e;
    border: 1px solid #3a3a4e;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 0.75rem 0;
    overflow-x: auto;
    position: relative;
}

.message-bubble pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    display: block;
}

/* 行内代码样式 */
.message-bubble code {
    background: #2a2a3e;
    color: #f472b6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.875rem;
}

.message-bubble pre code {
    color: inherit;
}

/* 代码高亮优化 */
.message-bubble .hljs {
    background: transparent;
    padding: 0;
}

/* 用户消息中的代码样式 */
.message.user .message-bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.message.user .message-bubble pre {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

/* 复制代码按钮 */
.copy-code-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: #374151;
    color: #9ca3af;
    border: 1px solid #4b5563;
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
}

.message-bubble pre:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background: #4b5563;
    color: #ffffff;
    border-color: #6b7280;
}

.copy-code-btn.copied {
    background: #059669;
    color: #ffffff;
    border-color: #10b981;
}

.copy-code-btn svg {
    width: 14px;
    height: 14px;
}

.copy-code-btn span {
    font-weight: 500;
}