<?php
/**
 * HuSNS - 移动端数据管理页面
 */
$userId = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : null;
if (!$userId) {
    $this->assign('showLoginModal', true);
}

$currentPage = 'privacy-data';
$pageType = 'privacy';
$bodyClass = 'privacy-page data-page';
$headerTitle = '数据管理';

$pageCssFiles = [$this->themeUrl() . '/app/css/privacy.css'];
$pageJsFiles = [$this->themeUrl() . '/app/js/privacy-data.js'];

$this->assign('pageCssFiles', $pageCssFiles);
$this->assign('pageJsFiles', $pageJsFiles);

$this->setLayout('app');
?>

<div class="privacy-content">
    <!-- 数据概览 -->
    <div class="data-overview">
        <div class="data-section-title">数据概览</div>
        <div class="data-stats">
            <div class="data-stat-item">
                <div class="stat-value" id="statPosts">--</div>
                <div class="stat-label">我的动态</div>
            </div>
            <div class="data-stat-item">
                <div class="stat-value" id="statComments">--</div>
                <div class="stat-label">评论数</div>
            </div>
            <div class="data-stat-item">
                <div class="stat-value" id="statFavorites">--</div>
                <div class="stat-label">收藏数</div>
            </div>
            <div class="data-stat-item">
                <div class="stat-value" id="statLikes">--</div>
                <div class="stat-label">获赞数</div>
            </div>
        </div>
    </div>
    
    <!-- 数据导出 -->
    <div class="privacy-section">
        <div class="privacy-section-title">数据导出</div>
        
        <div class="export-options">
            <div class="export-option">
                <div class="export-info">
                    <div class="export-icon">📄</div>
                    <div class="export-detail">
                        <div class="export-name">导出全部数据</div>
                        <div class="export-desc">包含动态、评论、收藏、点赞等所有个人数据</div>
                    </div>
                </div>
                <button class="export-btn" id="exportAllBtn">导出</button>
            </div>
            
            <div class="export-option">
                <div class="export-info">
                    <div class="export-icon">📝</div>
                    <div class="export-detail">
                        <div class="export-name">导出动态数据</div>
                        <div class="export-desc">仅导出您发布的动态内容</div>
                    </div>
                </div>
                <button class="export-btn" id="exportPostsBtn">导出</button>
            </div>
            
            <div class="export-option">
                <div class="export-info">
                    <div class="export-icon">💬</div>
                    <div class="export-detail">
                        <div class="export-name">导出评论数据</div>
                        <div class="export-desc">仅导出您发表的评论内容</div>
                    </div>
                </div>
                <button class="export-btn" id="exportCommentsBtn">导出</button>
            </div>
        </div>
        
        <div class="export-tip">
            <div class="tip-icon">💡</div>
            <div class="tip-text">数据将以JSON格式导出，包含您的所有公开和私密内容</div>
        </div>
    </div>
    
    <!-- 清除数据 -->
    <div class="privacy-section">
        <div class="privacy-section-title">清除数据</div>
        
        <div class="clear-options">
            <div class="clear-option">
                <div class="clear-info">
                    <div class="clear-icon">🗑️</div>
                    <div class="clear-detail">
                        <div class="clear-name">清除缓存数据</div>
                        <div class="clear-desc">清除本地缓存的图片、视频等临时文件</div>
                    </div>
                </div>
                <button class="clear-btn" id="clearCacheBtn">清除</button>
            </div>
            
            <div class="clear-option">
                <div class="clear-info">
                    <div class="clear-icon">📖</div>
                    <div class="clear-detail">
                        <div class="clear-name">清除浏览记录</div>
                        <div class="clear-desc">清除您的浏览历史记录</div>
                    </div>
                </div>
                <button class="clear-btn" id="clearHistoryBtn">清除</button>
            </div>
        </div>
    </div>
    
    <!-- 账号删除 -->
    <div class="privacy-section danger-section">
        <div class="privacy-section-title">账号删除</div>
        
        <div class="delete-warning">
            <div class="warning-icon">⚠️</div>
            <div class="warning-content">
                <div class="warning-title">删除账号</div>
                <div class="warning-text">此操作将永久删除您的账号及所有相关数据，且无法恢复。请谨慎操作。</div>
            </div>
        </div>
        
        <button class="delete-btn" id="deleteAccountBtn">删除我的账号</button>
    </div>
</div>