<?php
use function App\Core\{e, logo_asset, url};

$zpanelLogo = logo_asset('zpanel');
?>
<div class="panel zpanel finance-page" data-zpanel-financial-settings data-csrf="<?= e($csrfToken ?? '') ?>">
    <?php require BASE_PATH . '/app/Views/zpanel/_sidebar.php'; ?>
    <section class="panel-body">
        <div class="finance-head">
            <div><h1>Finans Ayarlari</h1><p>Komisyon, vergi, provider fee ve manuel payout davranisi.</p></div>
        </div>
        <?php if (!empty($loadError)): ?><div class="finance-alert"><?= e($loadError) ?></div><?php endif; ?>
        <section class="finance-card">
            <form class="finance-form settings-grid" data-zpanel-finance-form>
                <input type="hidden" name="_csrf" value="<?= e($csrfToken ?? '') ?>">
                <label>Site komisyon orani<input type="number" name="site_commission_rate" step="0.0001" min="0" max="1" value="<?= e($settings['site_commission_rate'] ?? '0.10') ?>" required></label>
                <label>Vergi orani<input type="number" name="tax_rate" step="0.0001" min="0" max="1" value="<?= e($settings['tax_rate'] ?? '0.20') ?>" required></label>
                <label>Provider fee orani<input type="number" name="provider_fee_rate" step="0.0001" min="0" max="1" value="<?= e($settings['provider_fee_rate'] ?? '0') ?>" required></label>
                <label>Sabit provider fee<input type="number" name="provider_fee_fixed" step="0.01" min="0" value="<?= e($settings['provider_fee_fixed'] ?? '0') ?>" required></label>
                <label>Minimum cekim tutari<input type="number" name="minimum_withdrawal_amount" step="0.01" min="0.01" value="<?= e($settings['minimum_withdrawal_amount'] ?? '100') ?>" required></label>
                <label>Payout gecikmesi dakika<input type="number" name="payout_delay_minutes" step="1" min="0" value="<?= e($settings['payout_delay_minutes'] ?? '20') ?>" required></label>
                <label>Balance hold gun<input type="number" name="balance_hold_days" step="1" min="0" value="<?= e($settings['balance_hold_days'] ?? '0') ?>" required></label>
                <label>Para birimi<input name="currency" maxlength="3" value="<?= e($settings['currency'] ?? 'TRY') ?>" required></label>
                <label>Vergi hesap tipi<select name="tax_calc_type"><option value="gross" <?= ($settings['tax_calc_type'] ?? 'gross') === 'gross' ? 'selected' : '' ?>>gross</option><option value="net" <?= ($settings['tax_calc_type'] ?? '') === 'net' ? 'selected' : '' ?>>net</option></select></label>
                <label>Payout modu<select name="payout_mode"><option value="manual" <?= ($settings['payout_mode'] ?? 'manual') === 'manual' ? 'selected' : '' ?>>manual</option><option value="api" <?= ($settings['payout_mode'] ?? '') === 'api' ? 'selected' : '' ?>>api TODO</option></select></label>
                <button class="pill primary" type="button" data-zpanel-endpoint="/api/zpanel/financial-settings/update">Ayarlari Kaydet</button>
            </form>
        </section>
    </section>
</div>
