{% extends "base.html" %}
{% block content %}
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-6 animate-up">
            <div class="glass-card p-4">
                <h3 class="fw-bold mb-4 text-center">提取数字资产</h3>
                
                <div class="d-flex justify-content-between mb-4">
                    <span class="text-secondary">可用余额</span>
                    <span class="fw-bold">{{ account.balance|default:"0.00" }} USDT</span>
                </div>

                <div class="mb-4">
                    <label class="form-label text-secondary">提取币种</label>
                    <div class="d-flex align-items-center bg-dark p-3 rounded border border-secondary border-opacity-25">
                        <i class="bi bi-coin text-warning fs-4 me-3"></i>
                        <div class="flex-grow-1">
                            <h6 class="m-0 fw-bold">USDT</h6>
                            <small class="text-secondary">Tether US</small>
                        </div>
                        <i class="bi bi-chevron-down text-secondary"></i>
                    </div>
                </div>

                <form method="POST">
                    {% csrf_token %}
                    <div class="mb-4">
                        <label class="form-label text-secondary">提现网络</label>
                        <select class="form-select bg-dark text-white border-secondary border-opacity-25 py-2">
                            <option value="TRC20">TRON (TRC20) - 手续费 1.00 USDT</option>
                            <option value="ERC20" disabled>Ethereum (ERC20) - 手续费 15.00 USDT</option>
                        </select>
                    </div>

                    <div class="mb-4">
                        <label class="form-label text-secondary">提现地址</label>
                        <input type="text" name="address" class="form-control bg-dark text-white border-secondary border-opacity-25 py-2" placeholder="请输入您的提现地址" required>
                    </div>

                    <div class="mb-4">
                        <label class="form-label text-secondary">提现金额</label>
                        <div class="input-group">
                            <input type="number" name="amount" id="withdraw-amount" step="0.01" class="form-control bg-dark text-white border-secondary border-opacity-25 py-2" placeholder="最小提现数量 10" required>
                            <button type="button" class="btn btn-outline-secondary border-secondary border-opacity-25 text-warning" onclick="document.getElementById('withdraw-amount').value = '{{ account.balance }}'">全部</button>
                        </div>
                        <div class="d-flex justify-content-between mt-2 small">
                            <span class="text-secondary">手续费</span>
                            <span class="text-white">1.00 USDT</span>
                        </div>
                    </div>

                    <div class="bg-warning bg-opacity-10 p-3 rounded mb-4">
                        <div class="d-flex justify-content-between">
                            <span class="text-secondary small">实际到账金额</span>
                            <h5 class="fw-bold text-warning m-0" id="final-amount">0.00 USDT</h5>
                        </div>
                    </div>

                    <button type="submit" class="btn btn-primary-custom w-100 py-3">提交提现申请</button>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    document.getElementById('withdraw-amount').addEventListener('input', function(e) {
        const val = parseFloat(e.target.value) || 0;
        const final = Math.max(0, val - 1).toFixed(2);
        document.getElementById('final-amount').innerText = final + ' USDT';
    });
</script>
{% endblock %}
