<div class="header">
    <h1>App Version</h1>
</div>
<?php if (session()->getFlashdata('message')): ?>
    <p style="color: var(--primary); margin-bottom: 1rem;"><?= esc(session()->getFlashdata('message')) ?></p>
<?php endif ?>
<div style="background: var(--surface); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 560px;">
    <form method="post" action="<?= base_url('admin/app-version/save') ?>">
        <input type="hidden" name="<?= csrf_token() ?>" value="<?= csrf_hash() ?>">
        <p>
            <label style="font-weight: 600;">Minimum app version</label><br>
            <input type="text" name="app_min_version" value="<?= esc($app_min_version) ?>" placeholder="e.g. 4.0.5" style="width:100%;">
            <small style="color: var(--text-light); display: block; margin-top: 0.25rem;">Semantic version (major.minor.patch). Apps below this version are blocked until updated. Leave empty to allow all versions.</small>
        </p>
        <p style="margin-top: 1rem;">
            <label style="font-weight: 600;">Google Play URL</label><br>
            <input type="url" name="app_store_url_google" value="<?= esc($app_store_url_google) ?>" placeholder="https://play.google.com/store/apps/..." style="width:100%;">
            <small style="color: var(--text-light); display: block; margin-top: 0.25rem;">Leave empty to hide this option in the app.</small>
        </p>
        <p style="margin-top: 1rem;">
            <label style="font-weight: 600;">App Store URL (Apple)</label><br>
            <input type="url" name="app_store_url_apple" value="<?= esc($app_store_url_apple) ?>" placeholder="https://apps.apple.com/..." style="width:100%;">
            <small style="color: var(--text-light); display: block; margin-top: 0.25rem;">Leave empty to hide this option in the app.</small>
        </p>
        <p style="margin-top: 1rem;">
            <label style="font-weight: 600;">Huawei AppGallery URL</label><br>
            <input type="url" name="app_store_url_huawei" value="<?= esc($app_store_url_huawei) ?>" placeholder="https://appgallery.huawei.com/..." style="width:100%;">
            <small style="color: var(--text-light); display: block; margin-top: 0.25rem;">Leave empty to hide this option in the app.</small>
        </p>
        <p style="margin-top: 1rem;">
            <label style="font-weight: 600;">Direct APK download URL</label><br>
            <input type="url" name="app_direct_apk_url" value="<?= esc($app_direct_apk_url) ?>" placeholder="https://..." style="width:100%;">
            <small style="color: var(--text-light); display: block; margin-top: 0.25rem;">Direct link to APK file. Leave empty to hide this option in the app.</small>
        </p>
        <button type="submit" class="btn btn-primary" style="margin-top: 1rem;">Save</button>
    </form>
</div>
