{% extends 'dating_app/base_dating.html' %}
{% load static %}

{% block title %}Dating Partner Wallet Top-up{% endblock %}

{% block content %}

<style>
    /* =========================================================
       DATING PARTNER WALLET TOP-UP
    ========================================================= */

    .dating-wallet-page {
        min-height: 100vh;
        padding: 4rem 0 5rem;
        background:
            radial-gradient(circle at top left, rgba(236, 72, 153, 0.12), transparent 30%),
            radial-gradient(circle at top right, rgba(168, 85, 247, 0.10), transparent 32%),
            linear-gradient(180deg, #fff7fb 0%, #ffffff 100%);
    }

    .dating-wallet-hero {
        position: relative;
        overflow: hidden;
        border-radius: 36px;
        padding: 2.8rem 2.5rem;
        margin-bottom: 2rem;
        background:
            radial-gradient(circle at top right, rgba(244, 114, 182, 0.22), transparent 34%),
            linear-gradient(135deg, #831843 0%, #be185d 52%, #7e22ce 100%);
        color: #ffffff;
        box-shadow: 0 28px 68px rgba(157, 23, 77, 0.22);
    }

    .dating-wallet-hero::before {
        content: "";
        position: absolute;
        top: -95px;
        right: -70px;
        width: 260px;
        height: 260px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.09);
        pointer-events: none;
    }

    .dating-wallet-hero::after {
        content: "";
        position: absolute;
        bottom: -120px;
        left: -80px;
        width: 310px;
        height: 310px;
        border-radius: 50%;
        background: rgba(251, 207, 232, 0.10);
        pointer-events: none;
    }

    .dating-wallet-hero-inner {
        position: relative;
        z-index: 2;
    }

    .dating-wallet-mini-title {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.48rem 0.95rem;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.14);
        border: 1px solid rgba(255, 255, 255, 0.22);
        color: #fce7f3;
        font-size: 0.84rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.045em;
        margin-bottom: 1rem;
    }

    .dating-wallet-hero h1 {
        font-size: clamp(2.2rem, 4vw, 3.6rem);
        font-weight: 950;
        letter-spacing: -0.045em;
        line-height: 1.07;
        margin-bottom: 0.95rem;
    }

    .dating-wallet-hero p {
        max-width: 920px;
        color: rgba(255, 255, 255, 0.88);
        font-size: 1.04rem;
        line-height: 1.78;
        margin-bottom: 0;
    }

    .dating-wallet-panel {
        margin-top: 1.35rem;
        border-radius: 28px;
        padding: 1.35rem;
        background: rgba(255, 255, 255, 0.12);
        border: 1px solid rgba(255, 255, 255, 0.18);
        backdrop-filter: blur(6px);
    }

    .dating-wallet-panel-item {
        height: 100%;
        border-radius: 22px;
        padding: 1rem 1.05rem;
        background: rgba(255, 255, 255, 0.97);
        color: #111827 !important;
        box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
    }

    .dating-wallet-label {
        display: block;
        color: #6b7280 !important;
        font-size: 0.78rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.4rem;
    }

    .dating-wallet-value {
        color: #111827 !important;
        font-weight: 950;
        font-size: 1.08rem;
        line-height: 1.4;
        margin-bottom: 0;
    }

    .dating-wallet-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.85rem;
        margin-top: 1.5rem;
    }

    .dating-wallet-actions .btn {
        border-radius: 999px;
        font-weight: 850;
        padding: 0.82rem 1.35rem;
        min-height: 48px;
    }

    .dating-btn-pink {
        background: #f9a8d4;
        color: #831843;
        border: none;
    }

    .dating-btn-pink:hover {
        background: #fce7f3;
        color: #831843;
        transform: translateY(-1px);
    }

    .dating-btn-light-outline {
        background: rgba(255, 255, 255, 0.10);
        color: #ffffff;
        border: 1px solid rgba(255, 255, 255, 0.42);
    }

    .dating-btn-light-outline:hover {
        background: #ffffff;
        color: #831843;
    }

    .dating-wallet-card {
        border-radius: 34px;
        background: rgba(255, 255, 255, 0.99);
        border: 1px solid rgba(252, 231, 243, 0.95);
        box-shadow: 0 24px 56px rgba(157, 23, 77, 0.10);
        overflow: hidden;
        margin-bottom: 1.5rem;
    }

    .dating-wallet-card-header {
        padding: 1.65rem 1.8rem 1.15rem;
        border-bottom: 1px solid #fce7f3;
        background:
            radial-gradient(circle at top right, rgba(236, 72, 153, 0.08), transparent 28%),
            linear-gradient(180deg, #ffffff 0%, #fff7fb 100%);
    }

    .dating-wallet-card-header h2,
    .dating-wallet-card-header h3 {
        color: #111827;
        font-weight: 950;
        margin-bottom: 0.35rem;
    }

    .dating-wallet-card-header p {
        color: #6b7280;
        line-height: 1.7;
        margin-bottom: 0;
    }

    .dating-wallet-card-body {
        padding: 1.8rem;
    }

    .dating-form-group {
        margin-bottom: 1.35rem;
    }

    .dating-form-group label {
        display: block;
        color: #111827;
        font-weight: 850;
        margin-bottom: 0.5rem;
    }

    .dating-form-group input,
    .dating-form-group select,
    .dating-form-group textarea {
        border-radius: 18px;
        border: 1px solid #fbcfe8;
        background: #fff7fb;
        min-height: 52px;
        color: #111827;
        transition: all 0.2s ease;
    }

    .dating-form-group input:focus,
    .dating-form-group select:focus,
    .dating-form-group textarea:focus {
        border-color: #db2777;
        background: #ffffff;
        box-shadow: 0 0 0 0.22rem rgba(219, 39, 119, 0.13);
    }

    .dating-field-error {
        color: #dc2626;
        font-size: 0.86rem;
        font-weight: 750;
        margin-top: 0.4rem;
    }

    .quick-amount-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.75rem;
        margin-top: 0.85rem;
    }

    .quick-amount-btn {
        border-radius: 18px;
        border: 1px solid #fbcfe8;
        background: #ffffff;
        color: #831843;
        padding: 0.8rem 0.75rem;
        font-weight: 900;
        transition: 0.2s ease;
    }

    .quick-amount-btn:hover {
        border-color: #db2777;
        background: #fdf2f8;
        color: #be185d;
        transform: translateY(-1px);
    }

    .payment-method-list {
        display: grid;
        gap: 0.9rem;
    }

    .payment-method-card {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        border: 1.5px solid #fbcfe8;
        border-radius: 1.15rem;
        padding: 0.95rem 1rem;
        background: #ffffff;
        cursor: pointer;
        transition: all 0.2s ease-in-out;
        min-height: 78px;
    }

    .payment-method-card:hover {
        border-color: #db2777;
        box-shadow: 0 0.45rem 1rem rgba(157, 23, 77, 0.08);
    }

    .payment-method-left {
        display: flex;
        align-items: center;
        gap: 0.9rem;
        min-width: 0;
    }

    .payment-method-icon {
        width: 46px;
        height: 46px;
        border-radius: 0.9rem;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        flex-shrink: 0;
    }

    .stripe-card .payment-method-icon {
        background: #eef4ff;
        color: #635bff;
    }

    .paypal-card .payment-method-icon {
        background: #eef7ff;
        color: #0070ba;
    }

    .payment-method-title {
        font-weight: 900;
        color: #111827;
        line-height: 1.2;
    }

    .payment-method-subtitle {
        font-size: 0.9rem;
        color: #6b7280;
        line-height: 1.35;
        margin-top: 0.15rem;
    }

    .payment-method-right {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        flex-shrink: 0;
    }

    .payment-method-status {
        font-size: 0.78rem;
        font-weight: 850;
        color: #be185d;
        background: #fdf2f8;
        border: 1px solid #fbcfe8;
        border-radius: 999px;
        padding: 0.3rem 0.65rem;
    }

    .payment-method-check {
        color: #be185d;
        font-size: 1.15rem;
        opacity: 0;
        transition: opacity 0.2s ease-in-out;
        line-height: 1;
    }

    .btn-check:checked + .payment-method-card {
        border-color: #db2777;
        background: #fdf2f8;
        box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.12);
    }

    .btn-check:checked + .payment-method-card .payment-method-check {
        opacity: 1;
    }

    .dating-wallet-submit {
        border-radius: 999px;
        min-height: 54px;
        font-weight: 900;
        background: linear-gradient(135deg, #831843, #be185d, #7e22ce);
        color: #ffffff;
        border: none;
        box-shadow: 0 14px 28px rgba(190, 24, 93, 0.22);
    }

    .dating-wallet-submit:hover {
        color: #831843;
        background: linear-gradient(135deg, #f9a8d4, #fce7f3);
        transform: translateY(-2px);
    }

    .dating-note-box {
        border-radius: 24px;
        padding: 1rem 1.1rem;
        background: #fff7ed;
        border: 1px solid #fed7aa;
        color: #92400e;
        line-height: 1.7;
    }

    .dating-note-box strong {
        color: #111827;
    }

    .dating-side-stat {
        border-radius: 24px;
        padding: 1.15rem;
        background: #fff7fb;
        border: 1px solid #fbcfe8;
        margin-bottom: 0.9rem;
    }

    .dating-side-stat span {
        display: block;
        color: #6b7280;
        font-size: 0.78rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.35rem;
    }

    .dating-side-stat strong {
        color: #111827;
        font-weight: 950;
        font-size: 1.18rem;
    }

    .dating-wallet-balance-box {
        border-radius: 28px;
        padding: 1.35rem;
        color: #ffffff;
        background:
            radial-gradient(circle at top right, rgba(244, 114, 182, 0.20), transparent 34%),
            linear-gradient(135deg, #831843 0%, #be185d 58%, #7e22ce 100%);
        margin-bottom: 1rem;
    }

    .dating-wallet-balance-box span {
        display: block;
        color: rgba(255, 255, 255, 0.72);
        font-size: 0.78rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.35rem;
    }

    .dating-wallet-balance-box strong {
        display: block;
        color: #ffffff;
        font-size: 2.35rem;
        font-weight: 950;
        letter-spacing: -0.04em;
        line-height: 1;
    }

    @media (max-width: 991.98px) {
        .dating-wallet-page {
            padding-top: 2.8rem;
        }

        .dating-wallet-hero {
            padding: 2rem 1.45rem;
            border-radius: 30px;
        }
    }

    @media (max-width: 767.98px) {
        .dating-wallet-card-body,
        .dating-wallet-card-header {
            padding-left: 1.15rem;
            padding-right: 1.15rem;
        }

        .dating-wallet-actions {
            flex-direction: column;
            align-items: stretch;
        }

        .dating-wallet-actions .btn {
            width: 100%;
        }

        .quick-amount-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }

        .payment-method-card {
            padding: 0.9rem;
        }
    }
</style>


<section class="dating-wallet-page">
    <div class="container">

        <div class="dating-wallet-hero">
            <div class="dating-wallet-hero-inner">

                <span class="dating-wallet-mini-title">
                    <i class="bi bi-wallet2"></i>
                    Dating Partner Wallet
                </span>

                <h1>Top Up Your Wallet</h1>

                <p>
                    Add funds to your Dating Partner wallet so you can pay confirmation fees,
                    featured profile upgrades, premium visibility options, and other eligible dating platform payments.
                </p>

                <div class="dating-wallet-panel">
                    <div class="row g-3">

                        <div class="col-md-4">
                            <div class="dating-wallet-panel-item">
                                <span class="dating-wallet-label">Account</span>
                                <p class="dating-wallet-value">
                                    {{ profile.user.get_full_name|default:profile.user.username }}
                                </p>
                            </div>
                        </div>

                        <div class="col-md-4">
                            <div class="dating-wallet-panel-item">
                                <span class="dating-wallet-label">Wallet Type</span>
                                <p class="dating-wallet-value">
                                    {{ account_label|default:"Dating Partner Wallet" }}
                                </p>
                            </div>
                        </div>

                        <div class="col-md-4">
                            <div class="dating-wallet-panel-item">
                                <span class="dating-wallet-label">Current Balance</span>
                                <p class="dating-wallet-value">
                                    USD {{ wallet.balance_usd|floatformat:2 }}
                                </p>
                            </div>
                        </div>

                    </div>
                </div>

                <div class="dating-wallet-actions">
                    <a href="{% url 'dating_app:dating_partner_payment_center' %}"
                       class="btn dating-btn-light-outline">
                        <i class="bi bi-arrow-left-circle me-2"></i>
                        Back to Payment Center
                    </a>

                    <a href="{% url 'dating_app:dating_partner_dashboard' %}"
                       class="btn dating-btn-light-outline">
                        <i class="bi bi-speedometer2 me-2"></i>
                        My Dashboard
                    </a>

                    <a href="{% url 'dating_app:home_dating' %}"
                       class="btn dating-btn-pink">
                        <i class="bi bi-heart-fill me-2"></i>
                        Dating Home
                    </a>
                </div>

            </div>
        </div>


        <div class="row g-4 align-items-start">

            <div class="col-lg-8">
                <div class="dating-wallet-card">

                    <div class="dating-wallet-card-header">
                        <h2>Top-up Details</h2>
                        <p>
                            Enter the amount you want to add to your wallet and choose your preferred payment method.
                        </p>
                    </div>

                    <div class="dating-wallet-card-body">

                        <form method="post">
                            {% csrf_token %}

                            {% if form.non_field_errors %}
                                <div class="alert alert-danger rounded-4">
                                    {% for error in form.non_field_errors %}
                                        <div>{{ error }}</div>
                                    {% endfor %}
                                </div>
                            {% endif %}

                            <div class="dating-form-group">
                                <label for="{{ form.amount_usd.id_for_label }}">
                                    Top-up Amount USD
                                </label>

                                {{ form.amount_usd }}

                                {% for error in form.amount_usd.errors %}
                                    <div class="dating-field-error">{{ error }}</div>
                                {% endfor %}

                                <div class="quick-amount-grid">
                                    <button type="button" class="quick-amount-btn" data-amount="10">USD 10</button>
                                    <button type="button" class="quick-amount-btn" data-amount="25">USD 25</button>
                                    <button type="button" class="quick-amount-btn" data-amount="50">USD 50</button>
                                    <button type="button" class="quick-amount-btn" data-amount="100">USD 100</button>
                                </div>
                            </div>


                            <div class="dating-form-group">
                                <label class="form-label fw-bold mb-3">
                                    Payment Method
                                </label>

                                <div class="payment-method-list">

                                    <input
                                        class="btn-check"
                                        type="radio"
                                        name="payment_method"
                                        id="payStripe"
                                        value="stripe"
                                        {% if form.payment_method.value == "stripe" or not form.payment_method.value %}checked{% endif %}
                                    >

                                    <label class="payment-method-card stripe-card" for="payStripe">
                                        <div class="payment-method-left">
                                            <div class="payment-method-icon">
                                                <i class="bi bi-credit-card-2-front-fill"></i>
                                            </div>

                                            <div>
                                                <div class="payment-method-title">Stripe</div>
                                                <div class="payment-method-subtitle">
                                                    Pay securely with card
                                                </div>
                                            </div>
                                        </div>

                                        <div class="payment-method-right">
                                            <span class="payment-method-status">Available</span>
                                            <span class="payment-method-check">
                                                <i class="bi bi-check-circle-fill"></i>
                                            </span>
                                        </div>
                                    </label>


                                    <input
                                        class="btn-check"
                                        type="radio"
                                        name="payment_method"
                                        id="payPaypal"
                                        value="paypal"
                                        {% if form.payment_method.value == "paypal" %}checked{% endif %}
                                    >

                                    <label class="payment-method-card paypal-card" for="payPaypal">
                                        <div class="payment-method-left">
                                            <div class="payment-method-icon">
                                                <i class="bi bi-paypal"></i>
                                            </div>

                                            <div>
                                                <div class="payment-method-title">PayPal</div>
                                                <div class="payment-method-subtitle">
                                                    Pay securely with your PayPal account
                                                </div>
                                            </div>
                                        </div>

                                        <div class="payment-method-right">
                                            <span class="payment-method-status">Available</span>
                                            <span class="payment-method-check">
                                                <i class="bi bi-check-circle-fill"></i>
                                            </span>
                                        </div>
                                    </label>

                                </div>

                                {% for error in form.payment_method.errors %}
                                    <div class="dating-field-error">{{ error }}</div>
                                {% endfor %}
                            </div>


                            <div class="dating-note-box mb-4">
                                <strong>Important:</strong>
                                Wallet top-up payments are credited to your Dating Partner wallet only after
                                payment confirmation. You can later use your wallet balance for eligible dating platform payments.
                            </div>

                            <button type="submit" class="btn dating-wallet-submit w-100">
                                <i class="bi bi-lock-fill me-2"></i>
                                Continue to Secure Payment
                            </button>

                        </form>

                    </div>
                </div>
            </div>


            <div class="col-lg-4">

                <div class="dating-wallet-card">
                    <div class="dating-wallet-card-header">
                        <h3>Wallet Summary</h3>
                        <p>
                            Your wallet helps you manage future dating partner payments more conveniently.
                        </p>
                    </div>

                    <div class="dating-wallet-card-body">
                        <div class="dating-wallet-balance-box">
                            <span>Available Balance</span>
                            <strong>USD {{ wallet.balance_usd|floatformat:2 }}</strong>
                        </div>

                        <div class="dating-side-stat">
                            <span>Wallet Status</span>
                            <strong>
                                {% if wallet.is_active %}
                                    Active
                                {% else %}
                                    Inactive
                                {% endif %}
                            </strong>
                        </div>

                        <div class="dating-side-stat">
                            <span>Profile Type</span>
                            <strong>Dating Partner</strong>
                        </div>

                        <div class="dating-side-stat">
                            <span>Minimum Top-up</span>
                            <strong>USD 5.00</strong>
                        </div>
                    </div>
                </div>


                <div class="dating-wallet-card">
                    <div class="dating-wallet-card-header">
                        <h3>What can wallet funds be used for?</h3>
                        <p>
                            Wallet funds can support eligible Dating Partner payments.
                        </p>
                    </div>

                    <div class="dating-wallet-card-body">
                        <ul class="mb-0 ps-3 text-muted" style="line-height: 1.85;">
                            <li>Dating Partner confirmation fee.</li>
                            <li>Featured or premium profile visibility fee.</li>
                            <li>Future dating platform upgrades where wallet usage is enabled.</li>
                            <li>Other eligible Dating Partner payments approved by the platform.</li>
                        </ul>
                    </div>
                </div>


                <div class="dating-wallet-card">
                    <div class="dating-wallet-card-header">
                        <h3>Quick Links</h3>
                        <p>
                            Continue managing your Dating Partner account.
                        </p>
                    </div>

                    <div class="dating-wallet-card-body">
                        <div class="d-grid gap-2">
                            <a href="{% url 'dating_app:dating_partner_payment_center' %}"
                               class="btn btn-dark rounded-pill fw-bold">
                                <i class="bi bi-wallet2 me-2"></i>
                                Payment Center
                            </a>

                            <a href="{% url 'dating_app:dating_partner_dashboard' %}"
                               class="btn btn-outline-dark rounded-pill fw-bold">
                                <i class="bi bi-speedometer2 me-2"></i>
                                Dashboard
                            </a>
                        </div>
                    </div>
                </div>

            </div>

        </div>

    </div>
</section>


<script>
    document.addEventListener('DOMContentLoaded', function () {
        const amountInput = document.getElementById('{{ form.amount_usd.id_for_label }}');
        const quickButtons = document.querySelectorAll('.quick-amount-btn');

        quickButtons.forEach(function (button) {
            button.addEventListener('click', function () {
                const amount = button.dataset.amount || '';
                if (amountInput) {
                    amountInput.value = amount;
                    amountInput.focus();
                }
            });
        });
    });
</script>

{% endblock %}