<?php
/**
 * APP下载页面 - Modern模板风格
 * 独立页面，无需登录
 */
if (!defined('IN_CRONLITE')) {
    require_once __DIR__ . '/../../../MPHX/common.php';
}

// 获取当前域名
$domain = $_SERVER['HTTP_HOST'];
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
$baseUrl = $protocol . '://' . $domain;
$apkUrl = $baseUrl . '/app/app.apk';

// 检查APK文件是否存在
$apkPath = __DIR__ . '/../../../app/app.apk';
$apkExists = file_exists($apkPath);

// 页面标题
$pageTitle = 'APP下载';
$siteName = $conf['name'] ?? '虚拟空间';
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title><?php echo $pageTitle; ?> - <?php echo $siteName; ?></title>
    
    <!-- 引入模板样式 -->
    <link rel="stylesheet" href="/static/css/all.min.css">
    <link rel="stylesheet" href="/templates/modern/assets/css/style.css?v=<?php echo time(); ?>">
    
    <style>
        /* APP下载页面专用样式 - Modern风格 */
        .app-download-page {
            min-height: 100vh;
            background: linear-gradient(135deg, #1a1d29 0%, #0f1419 100%);
            padding: 40px 20px;
            position: relative;
            overflow: hidden;
        }
        
        /* 背景装饰 */
        .app-download-page::before {
            content: '';
            position: absolute;
            width: 600px;
            height: 600px;
            background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, transparent 70%);
            top: -200px;
            right: -200px;
            pointer-events: none;
        }
        
        .app-download-page::after {
            content: '';
            position: absolute;
            width: 400px;
            height: 400px;
            background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
            bottom: -100px;
            left: -100px;
            pointer-events: none;
        }
        
        .download-container {
            max-width: 480px;
            margin: 0 auto;
            position: relative;
            z-index: 1;
        }
        
        .download-card {
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 24px;
            padding: 45px 35px;
            backdrop-filter: blur(20px);
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            text-align: center;
        }
        
        .app-header {
            margin-bottom: 35px;
        }
        
        .app-icon-wrapper {
            width: 90px;
            height: 90px;
            background: linear-gradient(135deg, #10b981 0%, #059669 100%);
            border-radius: 22px;
            margin: 0 auto 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 15px 35px rgba(16, 185, 129, 0.3);
            position: relative;
            overflow: hidden;
        }
        
        .app-icon-wrapper::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: linear-gradient(
                45deg,
                transparent 30%,
                rgba(255, 255, 255, 0.15) 50%,
                transparent 70%
            );
            animation: shine 3s infinite;
        }
        
        @keyframes shine {
            0% { transform: translateX(-100%) rotate(45deg); }
            100% { transform: translateX(100%) rotate(45deg); }
        }
        
        .app-icon-wrapper i {
            font-size: 42px;
            color: white;
            position: relative;
            z-index: 1;
        }
        
        .app-title {
            font-size: 26px;
            font-weight: 700;
            color: #fff;
            margin-bottom: 10px;
        }
        
        .app-meta {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 20px;
            color: rgba(255, 255, 255, 0.5);
            font-size: 14px;
        }
        
        .app-meta span {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        
        .qr-container {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 16px;
            padding: 30px;
            margin-bottom: 30px;
        }
        
        .qr-label {
            font-size: 14px;
            color: rgba(255, 255, 255, 0.7);
            margin-bottom: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        
        #qrcode {
            display: inline-block;
            padding: 12px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        }
        
        .qr-hint {
            font-size: 12px;
            color: rgba(255, 255, 255, 0.4);
            margin-top: 15px;
        }
        
        .download-section {
            margin-bottom: 25px;
        }
        
        .download-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            padding: 18px 30px;
            background: linear-gradient(135deg, #10b981 0%, #059669 100%);
            color: white;
            text-decoration: none;
            border-radius: 12px;
            font-size: 17px;
            font-weight: 600;
            transition: all 0.3s ease;
            box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3);
            border: none;
            cursor: pointer;
        }
        
        .download-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 15px 40px rgba(16, 185, 129, 0.4);
            color: white;
            text-decoration: none;
        }
        
        .download-btn i {
            font-size: 20px;
        }
        
        .features {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        
        .feature-item {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            font-size: 13px;
            color: rgba(255, 255, 255, 0.5);
        }
        
        .feature-item i {
            color: #10b981;
            font-size: 14px;
        }
        
        /* 返回按钮 */
        .back-link {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            color: rgba(255, 255, 255, 0.6);
            text-decoration: none;
            margin-bottom: 25px;
            font-size: 14px;
            transition: all 0.3s;
        }
        
        .back-link:hover {
            color: white;
            text-decoration: none;
        }
        
        /* 页脚 */
        .page-footer {
            text-align: center;
            margin-top: 35px;
            color: rgba(255, 255, 255, 0.4);
            font-size: 13px;
        }
        
        /* 响应式 */
        @media (max-width: 480px) {
            .app-download-page {
                padding: 25px 15px;
            }
            
            .download-card {
                padding: 35px 25px;
            }
            
            .app-icon-wrapper {
                width: 75px;
                height: 75px;
            }
            
            .app-icon-wrapper i {
                font-size: 35px;
            }
            
            .app-title {
                font-size: 22px;
            }
            
            .qr-container {
                padding: 25px 20px;
            }
        }
    </style>
</head>
<body>
    <div class="app-download-page">
        <div class="download-container">
            <!-- 返回链接 -->
            <a href="/" class="back-link">
                <i class="fas fa-arrow-left"></i> 返回首页
            </a>
            
            <div class="download-card">
                <!-- APP头部信息 -->
                <div class="app-header">
                    <div class="app-icon-wrapper">
                        <i class="fas fa-mobile-alt"></i>
                    </div>
                    <h1 class="app-title"><?php echo $siteName; ?> APP</h1>
                    <div class="app-meta">
                        <span><i class="fas fa-code-branch"></i> V1.1.0</span>
                        <span><i class="fab fa-android"></i> Android</span>
                    </div>
                </div>
                
                <!-- 二维码区域 -->
                <div class="qr-container">
                    <div class="qr-label">
                        <i class="fas fa-qrcode"></i>
                        <span>扫码下载</span>
                    </div>
                    <div id="qrcode"></div>
                    <p class="qr-hint">使用手机浏览器扫描二维码</p>
                </div>
                
                <!-- 下载按钮 -->
                <div class="download-section">
                    <?php if ($apkExists): ?>
                    <a href="<?php echo $apkUrl; ?>" class="download-btn">
                        <i class="fas fa-download"></i>
                        <span>立即下载</span>
                    </a>
                    <?php else: ?>
                    <div class="download-btn" style="background: #666; cursor: not-allowed; opacity: 0.7;">
                        <i class="fas fa-clock"></i>
                        <span>即将上线</span>
                    </div>
                    <?php endif; ?>
                </div>
                
                <!-- 特性说明 -->
                <div class="features">
                    <div class="feature-item">
                        <i class="fas fa-check-circle"></i>
                        <span>支持 Android 5.0 及以上系统</span>
                    </div>
                    <div class="feature-item">
                        <i class="fas fa-shield-alt"></i>
                        <span>安全无毒，放心使用</span>
                    </div>
                    <div class="feature-item">
                        <i class="fas fa-sync-alt"></i>
                        <span>持续更新，功能完善</span>
                    </div>
                </div>
            </div>
            
            <!-- 页脚 -->
            <div class="page-footer">
                <p>&copy; <?php echo date('Y'); ?> <?php echo $siteName; ?> - All Rights Reserved</p>
            </div>
        </div>
    </div>
    
    <!-- QRCode.js -->
    <script src="https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"></script>
    <script>
        // 生成二维码
        document.addEventListener('DOMContentLoaded', function() {
            new QRCode(document.getElementById('qrcode'), {
                text: '<?php echo $apkUrl; ?>',
                width: 160,
                height: 160,
                colorDark: '#1a1d29',
                colorLight: '#ffffff',
                correctLevel: QRCode.CorrectLevel.M
            });
        });
    </script>
</body>
</html>
