* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #10a37f;
    --primary-hover: #0d8a6a;
    --bg-primary: #212121;
    --bg-secondary: #171717;
    --bg-tertiary: #2f2f2f;
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --text-muted: #8e8e8e;
    --border-color: #3f3f3f;
    --user-msg-bg: #2f2f2f;
    --assistant-msg-bg: transparent;
    --code-bg: #1e1e1e;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100%;
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.app-container {
    display: flex;
    min-height: 100vh;
    height: 100%;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-content {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background-color: var(--bg-tertiary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* 聊天区域 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

/* 欢迎消息 */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px;
    text-align: center;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), #1a7f5f);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.welcome-icon svg {
    stroke: white;
}

.welcome-message h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-message > p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* 推广区域 */
.promo-section {
    margin-bottom: 24px;
    text-align: center;
}

.promo-text {
    font-size: 1.1rem;
    color: #f0b90b;
    font-weight: 500;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(240, 185, 11, 0.3);
}

.promo-qq {
    font-size: 0.95rem;
    color: #8bb4f7;
}

/* 操作按钮组 */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.action-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-buy {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-buy:hover {
    border-color: var(--primary-color);
    background-color: rgba(16, 163, 127, 0.1);
}

.btn-query {
    background-color: transparent;
    color: #f0b90b;
    border-color: #f0b90b;
}

.btn-query:hover {
    background-color: rgba(240, 185, 11, 0.1);
}

.btn-official {
    background-color: var(--primary-color);
    color: white;
}

.btn-official:hover {
    background-color: var(--primary-hover);
}

.quick-tips {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 500px;
}

.tip-card {
    padding: 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tip-card:hover {
    background-color: #3a3a3a;
    border-color: var(--primary-color);
}

.tip-icon {
    font-size: 1.4rem;
}

.tip-card span:last-child {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 消息列表 */
.messages {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.message {
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.user-avatar {
    background: linear-gradient(135deg, #5436DA, #7B5EE0);
    color: white;
}

.assistant-avatar {
    background: linear-gradient(135deg, var(--primary-color), #1a7f5f);
    color: white;
}

.message-role {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.message-content {
    padding-left: 44px;
    line-height: 1.7;
    color: var(--text-primary);
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* 用户消息中的图片 */
.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
}

/* Markdown 样式 */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.message-content h1 { font-size: 1.4rem; }
.message-content h2 { font-size: 1.2rem; }
.message-content h3 { font-size: 1.1rem; }

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 4px 0;
}

.message-content code {
    background-color: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background-color: var(--code-bg);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.message-content blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
}

.message-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background-color: var(--bg-tertiary);
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 输入区域 */
.input-container {
    padding: 16px 20px 24px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.image-preview-container {
    margin-bottom: 12px;
}

.image-preview {
    display: inline-block;
    position: relative;
}

.image-preview img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background-color: #ef4444;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.remove-image-btn:hover {
    background-color: #dc2626;
}

.remove-image-btn svg {
    stroke: white;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px 12px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.upload-btn,
.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.upload-btn {
    background-color: transparent;
    color: var(--text-secondary);
}

.upload-btn:hover {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.send-btn {
    background-color: var(--primary-color);
    color: white;
}

.send-btn:hover {
    background-color: var(--primary-hover);
}

.send-btn:disabled {
    background-color: var(--bg-primary);
    color: var(--text-muted);
    cursor: not-allowed;
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    padding: 8px 0;
}

#messageInput::placeholder {
    color: var(--text-muted);
}

#messageInput:focus {
    outline: none;
}

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* 响应式 */
@media (max-width: 768px) {
    html, body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-container {
        min-height: 100vh;
        height: auto;
        flex-direction: column;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        flex: 1;
        min-height: 100vh;
        overflow: visible;
    }

    .chat-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px;
    }

    .welcome-message {
        height: auto;
        min-height: auto;
        padding: 30px 16px;
    }

    .welcome-message h2 {
        font-size: 1.5rem;
    }

    .promo-text {
        font-size: 0.95rem;
    }

    .promo-qq {
        font-size: 0.85rem;
    }

    .action-buttons {
        flex-direction: column;
        padding: 0 20px;
    }

    .action-btn {
        width: 100%;
        text-align: center;
    }

    .messages {
        padding: 0 16px;
    }

    .input-container {
        padding: 12px 16px 20px;
        position: relative;
        background-color: var(--bg-primary);
    }

    .message-content {
        padding-left: 0;
    }

    .message-header {
        margin-bottom: 12px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

/* 图片查看器 */
.image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
}

.image-viewer img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}
