/* ===== 全局样式 ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #475569;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    /* 星座颜色 */
    --aries: #ff6b6b;
    --taurus: #4ecdc4;
    --gemini: #ffd93d;
    --cancer: #c8d6e5;
    --leo: #ff9f43;
    --virgo: #a0e7e5;
    --libra: #ffb3ba;
    --scorpio: #8b5cf6;
    --sagittarius: #06d6a0;
    --capricorn: #64748b;
    --aquarius: #38bdf8;
    --pisces: #a78bfa;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-dark);
    position: relative;
}

/* ===== 通用组件 ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-block {
    width: 100%;
}

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

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

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

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 8px;
}

/* ===== 页面头部 ===== */
.page-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-dark);
    z-index: 100;
}

.page-header .back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.page-header .title {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 600;
}

/* ===== 登录页面 ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 40px 24px;
}

.login-page .logo {
    text-align: center;
    margin-bottom: 48px;
}

.login-page .logo h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-page .logo p {
    color: var(--text-secondary);
    margin-top: 8px;
}

.login-page .form {
    flex: 1;
}

.login-page .switch-mode {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
}

.login-page .switch-mode a {
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
}

/* ===== 性别选择页面 ===== */
.gender-page {
    min-height: 100vh;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.gender-page h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.gender-page p {
    color: var(--text-secondary);
    margin-bottom: 48px;
}

.gender-options {
    display: flex;
    gap: 24px;
    margin-bottom: 48px;
}

.gender-option {
    width: 140px;
    height: 180px;
    background: var(--bg-card);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.gender-option:hover {
    transform: translateY(-4px);
}

.gender-option.selected {
    border-color: var(--primary);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.gender-option .icon {
    font-size: 4rem;
    margin-bottom: 12px;
}

.gender-option .label {
    font-weight: 600;
}

.gender-option.male .icon { color: #38bdf8; }
.gender-option.female .icon { color: #f472b6; }

/* ===== 智能体选择页面 ===== */
.agents-page {
    padding-bottom: 80px;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 20px;
}

.agent-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.agent-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.agent-card.active {
    border-color: var(--primary);
}

.agent-card .avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.agent-card .name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.agent-card .zodiac {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.agent-card .mbti {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 2px 6px;
    background: var(--bg-input);
    border-radius: 4px;
    display: inline-block;
}

/* 星座颜色 */
.zodiac-aries { background: linear-gradient(135deg, var(--aries), #ff8e8e); }
.zodiac-taurus { background: linear-gradient(135deg, var(--taurus), #7eddd6); }
.zodiac-gemini { background: linear-gradient(135deg, var(--gemini), #ffe066); }
.zodiac-cancer { background: linear-gradient(135deg, var(--cancer), #dce4eb); }
.zodiac-leo { background: linear-gradient(135deg, var(--leo), #ffb86c); }
.zodiac-virgo { background: linear-gradient(135deg, var(--virgo), #b8f0ec); }
.zodiac-libra { background: linear-gradient(135deg, var(--libra), #ffccd1); }
.zodiac-scorpio { background: linear-gradient(135deg, var(--scorpio), #a78bfa); }
.zodiac-sagittarius { background: linear-gradient(135deg, var(--sagittarius), #34e5b1); }
.zodiac-capricorn { background: linear-gradient(135deg, var(--capricorn), #8899a6); }
.zodiac-aquarius { background: linear-gradient(135deg, var(--aquarius), #60c9f8); }
.zodiac-pisces { background: linear-gradient(135deg, var(--pisces), #c4b5fd); }

/* ===== 聊天页面 ===== */
.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-dark);
}

.chat-header .back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
}

.chat-header .agent-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header .agent-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.chat-header .agent-name {
    font-weight: 600;
}

.chat-header .agent-zodiac {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.chat-header .menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 80%;
    display: flex;
    gap: 8px;
}

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

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

.message .content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
}

.message.user .content {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-bottom-right-radius: 4px;
}

.message.assistant .content {
    background: var(--bg-card);
    border-bottom-left-radius: 4px;
}

.message .emotion {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
    display: flex;
    gap: 12px;
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 1rem;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.chat-input-area .send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.chat-input-area .send-btn:hover {
    transform: scale(1.05);
}

.chat-input-area .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== 记忆页面（碎片/日记）===== */
.memory-page {
    padding: 20px;
    padding-bottom: 80px;
}

.memory-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.memory-tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    background: var(--bg-input);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.memory-tab.active {
    background: var(--bg-card);
    border-color: var(--primary);
}

.memory-item {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}

.memory-item .date {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.memory-item .content {
    line-height: 1.6;
}

.memory-item .weight {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--primary);
}

.memory-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

/* ===== 个人中心 ===== */
.profile-page {
    padding: 20px;
}

.profile-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    margin-bottom: 24px;
}

.profile-card .avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.profile-card .nickname {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-card .email {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.profile-menu {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
}

.profile-menu-item {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

.profile-menu-item:last-child {
    border-bottom: none;
}

.profile-menu-item:hover {
    background: var(--bg-input);
}

.profile-menu-item .icon {
    margin-right: 12px;
}

.profile-menu-item .label {
    flex: 1;
}

.profile-menu-item .arrow {
    color: var(--text-muted);
}

.profile-menu-item.danger {
    color: var(--error);
}

/* ===== 底部导航 ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item .icon {
    font-size: 1.5rem;
}

.nav-item .label {
    font-size: 0.75rem;
}

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.modal {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    max-width: 360px;
    width: 100%;
}

.modal h3 {
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions .btn {
    flex: 1;
}

/* ===== 动画 ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

/* ===== 响应式 ===== */
@media (max-width: 360px) {
    .agents-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
