<template>
	<view class="app-page" :class="themeClass">
		<section-card title="账户概览" subtitle="集中管理本地昵称与主题设置">
			<view class="profile-card surface-strong" @click="go('/pages/mine/profile/index')">
				<view class="avatar-shell">{{ avatarText }}</view>
				<view class="profile-body">
					<text class="profile-name">{{ profileName }}</text>
					<text class="section-subtitle"></text>
				</view>
				<text class="arrow-text">{{right}}</text>
			</view>
			<view class="theme-row">
				<view class="pill-button" :class="{ active: store.state.settings.theme === 'light' }" @click.stop="setTheme('light')">浅色</view>
				<view class="pill-button" :class="{ active: store.state.settings.theme === 'dark' }" @click.stop="setTheme('dark')">深色</view>
			</view>
		</section-card>
		
		<ad-custom unit-id="adunit-74730c6c27c95a37"></ad-custom>
		
		<section-card title="数据管理" subtitle="备份、恢复和清理等高频操作统一收口">
			<view class="menu-list">
				<view class="menu-item" @click="go('/pages/mine/backup/index')">
					<view>
						<text class="menu-title">备份与恢复</text>
					</view>
					<text class="arrow-text">{{right}}</text>
				</view>
				<view class="menu-item" @click="go('/pages/mine/guide/index')">
					<view>
						<text class="menu-title">使用帮助</text>
					</view>
					<text class="arrow-text">{{right}}</text>
				</view>
				<view class="menu-item" @click="go('/pages/mine/about/index')">
					<view>
						<text class="menu-title">关于与隐私</text>
					</view>
					<text class="arrow-text">{{right}}</text>
				</view>
			</view>
		</section-card>
		
	
		
		<app-tab-bar current="mine" />
	</view>
</template>

<script setup>
import { computed,ref } from 'vue'
import SectionCard from '../../components/SectionCard.vue'
import AppTabBar from '../../components/AppTabBar.vue'
import { useAppStore } from '../../utils/store'

const store = useAppStore()
const themeClass = computed(() => (store.state.settings.theme === 'dark' ? 'theme-dark' : ''))
const profileName = computed(() => store.state.settings.profile.nickname || '用户')
const avatarText = computed(() => (store.state.settings.profile.nickname || '用户').slice(0, 1))

const right = ref(">")

function setTheme(theme) {
	store.setTheme(theme)
}

function go(url) {
	uni.navigateTo({ url })
}
</script>

<style lang="scss" scoped>
.profile-card,
.theme-row,
.menu-item {
	display: flex;
	align-items: center;
	gap: 16rpx;
}

.profile-card {
	padding: 24rpx;
	border-radius: 24rpx;
}

.avatar-shell {
	width: 88rpx;
	height: 88rpx;
	border-radius: 50%;
	background: var(--bg-accent);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 34rpx;
	font-weight: 700;
}

.profile-body {
	flex: 1;
}

.profile-name,
.menu-title {
	font-size: 30rpx;
	font-weight: 600;
	color: var(--text-primary);
}

.arrow-text {
	font-size: 32rpx;
	// color: var(--brand);
	
}

.theme-row {
	margin-top: 18rpx;
}

.theme-row .pill-button {
	flex: 1;
}

.menu-list,
.action-grid {
	display: flex;
	flex-direction: column;
	gap: 16rpx;
}

.menu-item {
	justify-content: space-between;
	padding: 22rpx;
	border-radius: 24rpx;
	background: var(--surface-muted);
}
</style>
