/* ===== 基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #e8927c;
    --primary-light: #f5d0c5;
    --primary-dark: #c4715c;
    --bg: #faf8f6;
    --sidebar-bg: #fff;
    --chat-bg: #faf8f6;
    --message-user: #e8927c;
    --message-assistant: #fff;
    --message-assistant-border: #f0e6e0;
    --text-primary: #333;
    --text-secondary: #888;
    --border: #eee5df;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --radius: 16px;
    --radius-sm: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* ===== 布局 ===== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 2px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.session-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.session-item:hover {
    background: var(--bg);
}

.session-item.active {
    background: var(--primary-light);
}

.session-icon {
    font-size: 16px;
}

.session-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.user-info:hover {
    background: var(--bg);
}

.user-avatar {
    font-size: 22px;
}

.user-name {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ===== 聊天区域 ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    min-width: 0;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(250,248,246,0.9);
    backdrop-filter: blur(10px);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.chat-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--border);
}

/* ===== 消息区域 ===== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

.welcome-content {
    text-align: center;
    max-width: 560px;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.welcome-content h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-content p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 8px;
}

.welcome-sub {
    font-size: 14px !important;
}

.quick-starts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 28px;
}

.quick-btn {
    padding: 12px 20px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.quick-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-1px);
}

/* 消息气泡 */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeInUp 0.3s ease;
}

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

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

.message.user .message-avatar {
    background: var(--primary-light);
}

.message.assistant .message-avatar {
    background: #e8f4e8;
}

.message-content {
    max-width: 80%;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.7;
    word-break: break-word;
}

.message.user .message-bubble {
    background: var(--message-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--message-assistant);
    border: 1px solid var(--message-assistant-border);
    border-bottom-left-radius: 4px;
}

.message-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.emotion-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* 思考中动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 18px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: typingBounce 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 typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== 输入区域 ===== */
.input-area {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 15px;
    line-height: 1.5;
    max-height: 120px;
    min-height: 24px;
    padding: 6px 0;
    outline: none;
    font-family: inherit;
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: #ddd;
    cursor: not-allowed;
}

.send-btn svg {
    width: 16px;
    height: 16px;
}

.input-hint {
    text-align: center;
    font-size: 12px;
    color: #bbb;
    margin-top: 8px;
}

/* ===== 弹窗 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

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

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 20px 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.save-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.save-btn:hover {
    background: var(--primary-dark);
}

/* 用户画像样式 */
.profile-section {
    margin-bottom: 20px;
}

.profile-section h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.memory-item {
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 14px;
}

.memory-item .mem-key {
    font-weight: 600;
    color: var(--primary-dark);
}

.memory-item .mem-value {
    color: var(--text-primary);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 20px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: block;
    }

    .messages-container {
        padding: 16px;
    }

    .message-content {
        max-width: 90%;
    }

    .quick-starts {
        flex-direction: column;
        align-items: center;
    }

    .quick-btn {
        width: 100%;
        max-width: 280px;
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}
