<view class="container">
  <!-- 登录与账号 -->
  <view class="card">
    <view class="flex items-center justify-between" wx:if="{{loggedIn}}">
      <view class="flex items-center gap-2">
        <image src="{{userInfo.avatar}}" class="avatar" mode="aspectFill" wx:if="{{userInfo.avatar}}"/>
        <view class="avatar avatar-placeholder" wx:else>
          <text>客</text>
        </view>
        <view>
          <text class="text-base font-medium">{{userInfo.nickname || '微信用户'}}</text>
          <text class="text-xs text-muted block">已登录，生辰档案云端同步</text>
        </view>
      </view>
      <view class="btn-ghost text-muted" bindtap="logout">退出</view>
    </view>
    <block wx:else>
      <view class="flex items-center gap-2 mb-2">
        <view class="avatar avatar-placeholder">
          <text>客</text>
        </view>
        <view>
          <text class="text-base font-medium">未登录</text>
          <text class="text-xs text-muted block">绑定的生辰仅保存在本机，登录后才生效</text>
        </view>
      </view>
      <view class="btn-primary text-center" bindtap="login">{{logging ? '登录中…' : '微信登录'}}</view>
      <view class="text-xs text-muted text-center mt-2">登录后可将生辰档案同步到云端，换设备不丢失</view>
    </block>
  </view>

  <!-- 我的数据 -->
  <view class="card">
    <view class="section-title">我的数据</view>
    <view class="menu-item" bindtap="navTo" data-url="/pages/birth-profiles/birth-profiles">
      <text class="menu-label">生辰管理</text>
      <view class="menu-right">
        <text class="menu-count">{{profileCount}}/{{maxFree}}</text>
        <text class="menu-arrow">›</text>
      </view>
    </view>
    <view class="menu-item" bindtap="navTo" data-url="/pages/bookmarks/bookmarks">
      <text class="menu-label">我的收藏</text>
      <view class="menu-right">
        <text class="menu-count" wx:if="{{bookmarkCount > 0}}">{{bookmarkCount}}</text>
        <text class="menu-arrow">›</text>
      </view>
    </view>
    <view class="menu-item" bindtap="navTo" data-url="/pages/preferences/preferences">
      <text class="menu-label">设置</text>
      <text class="menu-arrow">›</text>
    </view>
  </view>

  <!-- 功能 -->
  <view class="card">
    <view class="section-title">功能</view>
    <view class="menu-item" bindtap="navTo" data-url="/pages/fortune/fortune">
      <text class="menu-label">每日运势</text>
      <text class="menu-arrow">›</text>
    </view>
    <view class="menu-item" bindtap="navTo" data-url="/pages/divination/divination">
      <text class="menu-label">占卜</text>
      <text class="menu-arrow">›</text>
    </view>
    <view class="menu-item" bindtap="navTo" data-url="/pages/solar-terms/solar-terms">
      <text class="menu-label">二十四节气</text>
      <text class="menu-arrow">›</text>
    </view>
    <view class="menu-item" bindtap="navTo" data-url="/pages/calendar/calendar">
      <text class="menu-label">月历视图</text>
      <text class="menu-arrow">›</text>
    </view>
  </view>

  <!-- 关于 -->
  <view class="card">
    <view class="section-title">关于</view>
    <view class="text-sm text-muted">
      <text>老黄历小程序 v{{version}}</text>
      <text class="block mt-1" wx:if="{{buildNumber !== '0'}}">构建 #{{buildNumber}} ({{commitSha}})</text>
      <text class="block mt-1">提供农历、黄历、八字、许愿等功能</text>
    </view>
  </view>
</view>
