<?php
ob_start();
require_once 'config.php';

$announcement = getEncryptAnnouncement();
$packages = getEncryptPackages();
$price = !empty($packages) ? $packages[0]['price'] : 3.00;
$user = getEncryptUser();
$has_permission = $user ? hasEncryptPermission($user) : false;
$announcement_enabled = getSiteConfig('encrypt_announcement_enabled') == '1';
?>
<?php include 'header.php'; ?>

<div class="encrypt-container">
    <!-- 页面头部 -->
    <div class="encrypt-hero">
        <h1>
            <img src="https://api.iconify.design/mdi:shield-lock.svg?color=%23667eea" width="48" height="48" style="margin-right: 12px;" alt="">
            PHP文件加密工具
        </h1>
        <p>保护您的源代码，防止泄露与盗用</p>
    </div>
    
    <!-- 公告区域 -->
    <?php if ($announcement_enabled && !empty($announcement)): ?>
        <div class="announcement-box">
            <img src="https://api.iconify.design/mdi:bullhorn.svg?color=%23f59e0b" width="20" height="20" style="margin-right: 10px;" alt="">
            <div class="announcement-content"><?php echo $announcement; ?></div>
        </div>
    <?php endif; ?>
    
    <!-- 特性卡片 -->
    <div class="features-grid">
        <div class="feature-card">
            <div class="feature-icon">
                <img src="https://api.iconify.design/mdi:code-braces.svg?color=%23667eea" width="40" height="40" alt="">
            </div>
            <h3>代码混淆</h3>
            <p>变量名随机化，增加阅读难度</p>
        </div>
        <div class="feature-card">
            <div class="feature-icon">
                <img src="https://api.iconify.design/mdi:archive.svg?color=%23667eea" width="40" height="40" alt="">
            </div>
            <h3>Gzip压缩</h3>
            <p>减小文件体积，提升加载速度</p>
        </div>
        <div class="feature-card">
            <div class="feature-icon">
                <img src="https://api.iconify.design/mdi:flash.svg?color=%23667eea" width="40" height="40" alt="">
            </div>
            <h3>高性能</h3>
            <p>加密后性能损失极小</p>
        </div>
        <div class="feature-card">
            <div class="feature-icon">
                <img src="https://api.iconify.design/mdi:shield-check.svg?color=%23667eea" width="40" height="40" alt="">
            </div>
            <h3>安全保护</h3>
            <p>防止源码泄露</p>
        </div>
    </div>
    
    <?php if ($has_permission): ?>
        <div class="action-section">
            <a href="/encrypt/encrypt.php" class="btn-encrypt">
                <img src="https://api.iconify.design/mdi:shield-lock.svg?color=white" width="24" height="24" alt="">
                立即加密文件
            </a>
        </div>
    <?php else: ?>
        <div class="price-card">
            <div class="price-icon">
                <img src="https://api.iconify.design/mdi:crown.svg?color=%23fbbf24" width="36" height="36" alt="">
            </div>
            <h2>加密服务</h2>
            <div class="price-value">¥<?php echo number_format($price, 2); ?></div>
            <p class="price-desc">永久有效，不限次数</p>
            <p class="price-note">
                <img src="https://api.iconify.design/mdi:information.svg?color=%236b7280" width="16" height="16" alt="">
                管理员和代理商免费使用
            </p>
            <a href="/encrypt/buy.php" class="btn-buy">
                <img src="https://api.iconify.design/mdi:cart.svg?color=white" width="20" height="20" alt="">
                立即购买
            </a>
        </div>
    <?php endif; ?>
</div>

<style>
/* 基础变量 */
:root {
    --primary-color: #667eea;
    --primary-hover: #5a67d8;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
}
[data-theme="light"] {
    --primary-color: #667eea;
    --primary-hover: #5a67d8;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

/* 深色主题变量 */
[data-theme="dark"] {
    --primary-color: #7b8cf5;
    --primary-hover: #8f9ef7;
    --danger-color: #f87171;
    --success-color: #34d399;
    --warning-color: #fbbf24;
    --bg-primary: #1f2937;
    --bg-secondary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #4b5563;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.encrypt-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 20px;
    background: var(--bg-primary);
}

/* 页面头部 */
.encrypt-hero {
    text-align: center;
    margin-bottom: 50px;
}
.encrypt-hero h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
[data-theme="dark"] .encrypt-hero h1 {
    background: linear-gradient(135deg, #7b8cf5, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
}
.encrypt-hero p {
    color: var(--text-secondary);
    font-size: 18px;
}

/* 公告区域 */
.announcement-box {
    display: flex;
    align-items: flex-start;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 18px 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 48px;
    border-left: 5px solid #f59e0b;
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .announcement-box {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.1));
}
.announcement-content {
    flex: 1;
    color: #92400e;
    line-height: 1.7;
}
[data-theme="dark"] .announcement-content {
    color: #fbbf24;
}
.announcement-content a {
    color: #d97706;
    text-decoration: underline;
}
[data-theme="dark"] .announcement-content a {
    color: #f59e0b;
}

/* 特性卡片 */
.features-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
    margin-bottom: 48px;
}
.feature-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}
.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}
.feature-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(102, 126, 234, 0.05) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
[data-theme="dark"] .feature-icon {
    background: linear-gradient(135deg, rgba(123, 140, 245, 0.15) 0%, rgba(123, 140, 245, 0.08) 100%);
}
.feature-card h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.feature-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* 立即加密按钮 */
.action-section {
    text-align: center;
}
.btn-encrypt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 48px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
[data-theme="dark"] .btn-encrypt {
    background: linear-gradient(135deg, #7b8cf5, #a78bfa);
}
.btn-encrypt:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

/* 价格卡片 */
.price-card {
    max-width: 420px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 28px;
    padding: 40px 32px;
    text-align: center;
    border: 2px solid var(--primary-color);
    box-shadow: var(--shadow-lg);
}
.price-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #fbbf24, #d97706);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.price-card h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}
.price-value {
    font-size: 56px;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 8px;
}
.price-desc {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 16px;
}
.price-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}
.btn-buy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 36px;
    background: var(--primary-color);
    color: white;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s;
    width: 100%;
}
.btn-buy:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* 响应式 */
@media (max-width: 1024px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 768px) {
    .encrypt-hero h1 {
        font-size: 32px;
        flex-wrap: wrap;
    }
    .features-grid {
        grid-template-columns: 1fr;
    }
    .price-card {
        padding: 32px 24px;
    }
    .price-value {
        font-size: 44px;
    }
}
.encrypt-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* 页面头部 */
.encrypt-hero {
    text-align: center;
    margin-bottom: 50px;
}
.encrypt-hero h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.encrypt-hero p {
    color: var(--text-secondary);
    font-size: 18px;
}

/* 公告区域 */
.announcement-box {
    display: flex;
    align-items: flex-start;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 18px 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 48px;
    border-left: 5px solid #f59e0b;
    box-shadow: var(--shadow-sm);
}
.announcement-content {
    flex: 1;
    color: #92400e;
    line-height: 1.7;
}
.announcement-content a {
    color: #d97706;
    text-decoration: underline;
}

/* 特性卡片 */
.features-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
    margin-bottom: 48px;
}
.feature-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}
.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}
.feature-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(102, 126, 234, 0.05) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feature-card h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.feature-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* 立即加密按钮 */
.action-section {
    text-align: center;
}
.btn-encrypt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 48px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
.btn-encrypt:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

/* 价格卡片 */
.price-card {
    max-width: 420px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 28px;
    padding: 40px 32px;
    text-align: center;
    border: 2px solid var(--primary-color);
    box-shadow: var(--shadow-lg);
}
.price-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #fbbf24, #d97706);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.price-card h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}
.price-value {
    font-size: 56px;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 8px;
}
.price-desc {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 16px;
}
.price-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}
.btn-buy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 36px;
    background: var(--primary-color);
    color: white;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s;
    width: 100%;
}
.btn-buy:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* 响应式 */
@media (max-width: 1024px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 768px) {
    .encrypt-hero h1 {
        font-size: 32px;
        flex-wrap: wrap;
    }
    .features-grid {
        grid-template-columns: 1fr;
    }
    .price-card {
        padding: 32px 24px;
    }
    .price-value {
        font-size: 44px;
    }
}
</style>

<?php include 'footer.php'; ?>