{% extends 'hosting_app/base_hosting.html' %}
{% load static %}

{% block title %}Payment Successful | Hosting Client Portal{% endblock %}

{% block extra_css %}
<style>
    .host-payment-page {
        background: #fffaf5;
        color: #2f211d;
    }

    .host-payment-hero {
        position: relative;
        min-height: 520px;
        display: flex;
        align-items: center;
        overflow: hidden;
        background:
            linear-gradient(
                100deg,
                rgba(27, 16, 15, 0.94) 0%,
                rgba(54, 27, 24, 0.88) 42%,
                rgba(89, 44, 30, 0.64) 72%,
                rgba(89, 44, 30, 0.50) 100%
            ),
            url("{% static 'expat_life/images/hosting_hero.webp' %}") center center / cover no-repeat;
    }

    .host-payment-hero::before {
        content: "";
        position: absolute;
        width: 520px;
        height: 520px;
        border-radius: 50%;
        right: -180px;
        top: -220px;
        background: radial-gradient(circle, rgba(255, 193, 7, 0.34), rgba(255, 193, 7, 0));
        z-index: 1;
    }

    .host-payment-hero::after {
        content: "";
        position: absolute;
        width: 520px;
        height: 520px;
        border-radius: 50%;
        left: -240px;
        bottom: -310px;
        background: radial-gradient(circle, rgba(202, 95, 58, 0.30), rgba(202, 95, 58, 0));
        z-index: 1;
    }

    .host-payment-hero-inner {
        position: relative;
        z-index: 2;
        padding: 95px 0 120px;
    }

    .host-payment-badge {
        display: inline-flex;
        align-items: center;
        gap: 9px;
        padding: 10px 18px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.12);
        border: 1px solid rgba(255, 255, 255, 0.18);
        backdrop-filter: blur(8px);
        color: #fff;
        font-weight: 850;
        font-size: 0.82rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 24px;
    }

    .host-payment-title {
        color: #fff;
        font-weight: 950;
        line-height: 1.05;
        font-size: clamp(2.6rem, 5vw, 4.7rem);
        max-width: 900px;
        margin-bottom: 22px;
        letter-spacing: -0.04em;
    }

    .host-payment-title span {
        color: #ffd36b;
    }

    .host-payment-subtitle {
        color: rgba(255, 255, 255, 0.86);
        font-size: clamp(1.04rem, 2vw, 1.25rem);
        line-height: 1.78;
        max-width: 820px;
        margin-bottom: 0;
    }

    .host-payment-icon-wrap {
        width: 100px;
        height: 100px;
        border-radius: 32px;
        background: linear-gradient(135deg, #ffc83f, #df9219);
        color: #26160d;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 3.2rem;
        box-shadow: 0 24px 54px rgba(223, 146, 25, 0.34);
    }

    .host-payment-main {
        position: relative;
        z-index: 4;
        margin-top: -84px;
        padding-bottom: 80px;
    }

    .host-payment-card {
        background: #ffffff;
        border: 1px solid rgba(121, 73, 53, 0.10);
        border-radius: 38px;
        box-shadow: 0 30px 76px rgba(56, 31, 23, 0.16);
        overflow: hidden;
    }

    .host-payment-card-header {
        padding: 1.6rem 1.8rem;
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.22), transparent 34%),
            linear-gradient(135deg, #fffaf4 0%, #ffffff 58%, #fff3e5 100%);
        border-bottom: 1px solid rgba(121, 73, 53, 0.10);
    }

    .host-payment-card-header h4 {
        margin: 0;
        color: #38231d;
        font-weight: 900;
    }

    .host-payment-card-header p {
        margin: .28rem 0 0;
        color: #78625a;
        font-size: .94rem;
        line-height: 1.6;
    }

    .host-payment-status-badge {
        display: inline-flex;
        align-items: center;
        gap: .4rem;
        padding: .55rem .95rem;
        border-radius: 999px;
        background: rgba(22, 163, 74, 0.12);
        border: 1px solid rgba(22, 163, 74, 0.22);
        color: #166534;
        font-weight: 850;
        font-size: .82rem;
    }

    .host-summary-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }

    .host-summary-box {
        padding: 1rem;
        border-radius: 22px;
        background: #fffaf4;
        border: 1px solid #f0dcc2;
    }

    .host-summary-box .label {
        display: block;
        color: #8a6c5d;
        font-size: .76rem;
        font-weight: 850;
        text-transform: uppercase;
        letter-spacing: .06em;
        margin-bottom: .35rem;
    }

    .host-summary-box .value {
        color: #38231d;
        font-weight: 900;
        font-size: 1rem;
        word-break: break-word;
    }

    .host-amount-highlight {
        background:
            radial-gradient(circle at right top, rgba(255, 211, 107, 0.26), transparent 40%),
            linear-gradient(145deg, #301919 0%, #743129 68%, #a75f1b 100%);
        border: none;
        position: relative;
        overflow: hidden;
    }

    .host-amount-highlight .label,
    .host-amount-highlight .value {
        color: #fff;
        position: relative;
        z-index: 2;
    }

    .host-amount-highlight .value {
        color: #ffd36b;
        font-size: 1.4rem;
    }

    .host-items-panel {
        border-radius: 28px;
        border: 1px solid #f0dcc2;
        background: #ffffff;
        padding: 1.5rem;
        height: 100%;
    }

    .host-items-list {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .host-item-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: 1rem 0;
        border-bottom: 1px solid #f1e3cf;
    }

    .host-item-row:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .host-item-icon {
        width: 44px;
        height: 44px;
        border-radius: 16px;
        background: linear-gradient(135deg, #fff1d5, #ffe0ad);
        color: #9f5a13;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        font-size: 1.2rem;
    }

    .host-item-title {
        font-weight: 900;
        color: #38231d;
        margin-bottom: .12rem;
    }

    .host-item-note {
        color: #7a655d;
        font-size: .86rem;
    }

    .host-next-card {
        border-radius: 28px;
        padding: 1.5rem;
        background:
            radial-gradient(circle at right top, rgba(255, 193, 7, 0.16), transparent 42%),
            linear-gradient(145deg, #fffaf4 0%, #ffffff 100%);
        border: 1px solid #f0dcc2;
    }

    .host-next-card h5 {
        color: #38231d;
        font-weight: 900;
    }

    .host-next-card p {
        color: #78625a;
        line-height: 1.75;
    }

    .host-trust-note {
        border-radius: 22px;
        background: rgba(184, 111, 31, 0.08);
        border: 1px solid rgba(184, 111, 31, 0.16);
        padding: 1rem;
        color: #604b43;
        font-size: .93rem;
        line-height: 1.65;
    }

    .host-trust-note i {
        color: #b86f1f;
    }

    .host-btn-gold {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 56px;
        border-radius: 18px;
        padding: 14px 24px;
        font-weight: 900;
        background: linear-gradient(135deg, #ffc83f, #df9219);
        border: none;
        color: #26160d;
        text-decoration: none;
        box-shadow: 0 18px 34px rgba(223, 146, 25, 0.24);
        transition: all 0.22s ease;
    }

    .host-btn-gold:hover {
        transform: translateY(-2px);
        color: #26160d;
        background: linear-gradient(135deg, #ffd45f, #ec9f21);
    }

    .host-btn-dark {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 56px;
        border-radius: 18px;
        padding: 14px 24px;
        font-weight: 900;
        background: #2c1b17;
        border: 1px solid #2c1b17;
        color: #fff;
        text-decoration: none;
        transition: all 0.22s ease;
    }

    .host-btn-dark:hover {
        transform: translateY(-2px);
        color: #fff;
        background: #3a241e;
    }

    .host-btn-outline {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 56px;
        border-radius: 18px;
        padding: 14px 24px;
        font-weight: 900;
        background: #fff;
        border: 1px solid #ecd7b8;
        color: #3a241e;
        text-decoration: none;
        transition: all 0.22s ease;
    }

    .host-btn-outline:hover {
        transform: translateY(-2px);
        color: #3a241e;
        background: #fff8ef;
    }

    @media (max-width: 991.98px) {
        .host-payment-hero-inner {
            padding-left: 24px;
            padding-right: 24px;
        }
    }

    @media (max-width: 767.98px) {
        .host-payment-hero {
            background-position: 68% center;
        }

        .host-payment-hero-inner {
            padding: 70px 18px 105px;
        }

        .host-payment-title {
            font-size: 2.3rem;
            line-height: 1.12;
        }

        .host-payment-subtitle {
            font-size: 1rem;
            line-height: 1.58;
        }

        .host-payment-badge {
            max-width: 100%;
            white-space: normal;
            line-height: 1.35;
        }

        .host-payment-icon-wrap {
            width: 76px;
            height: 76px;
            border-radius: 22px;
            font-size: 2.35rem;
        }

        .host-summary-grid {
            grid-template-columns: 1fr;
        }

        .host-payment-card {
            border-radius: 28px;
        }

        .host-payment-card-header,
        .host-payment-card .p-4,
        .host-payment-card .p-md-5 {
            padding-left: 1.15rem !important;
            padding-right: 1.15rem !important;
        }

        .host-item-row {
            align-items: flex-start;
        }

        .host-btn-gold,
        .host-btn-dark,
        .host-btn-outline {
            width: 100%;
        }
    }
</style>
{% endblock %}

{% block content %}

<div class="host-payment-page">

    <section class="host-payment-hero">
        <div class="container host-payment-hero-inner">
            <div class="row align-items-center g-4">
                <div class="col-lg-8 text-white">
                    <span class="host-payment-badge">
                        <i class="bi bi-shield-check"></i>
                        Secure Event Payment Completed
                    </span>

                    <h1 class="host-payment-title">
                        Payment successful. <span>Your event booking is confirmed.</span>
                    </h1>

                    <p class="host-payment-subtitle">
                        Thank you. Your Hosting Client payment has been recorded successfully.
                        Your selected event booking, package, meal plan, or add-on payment has been updated
                        in the Host in Sri Lanka platform.
                    </p>
                </div>

                <div class="col-lg-4 text-lg-end">
                    <div class="host-payment-icon-wrap">
                        <i class="bi bi-check-circle-fill"></i>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="host-payment-main">
        <div class="container px-3 px-sm-4">
            <div class="host-payment-card mx-auto" style="max-width:1050px;">

                <div class="host-payment-card-header">
                    <div class="d-flex flex-column flex-md-row justify-content-between gap-3">
                        <div>
                            <h4>Payment Confirmation</h4>
                            <p>
                                Transaction reference and paid item summary for your event hosting request.
                            </p>
                        </div>

                        <div class="text-md-end">
                            <span class="host-payment-status-badge">
                                <i class="bi bi-check-circle-fill"></i>
                                {{ payment_transaction.get_status_display }}
                            </span>
                        </div>
                    </div>
                </div>

                <div class="p-4 p-md-5">

                    <div class="host-summary-grid mb-4">
                        <div class="host-summary-box">
                            <span class="label">Transaction No</span>
                            <span class="value">#{{ payment_transaction.id }}</span>
                        </div>

                        <div class="host-summary-box">
                            <span class="label">Payment Method</span>
                            <span class="value">{{ payment_transaction.get_payment_method_display }}</span>
                        </div>

                        <div class="host-summary-box host-amount-highlight">
                            <span class="label">Total Selected Amount</span>
                            <span class="value">${{ payment_transaction.total_amount_usd }}</span>
                        </div>

                        <div class="host-summary-box">
                            <span class="label">Gateway Paid</span>
                            <span class="value">${{ payment_transaction.gateway_amount_usd }}</span>
                        </div>

                        <div class="host-summary-box">
                            <span class="label">Wallet Used</span>
                            <span class="value">${{ payment_transaction.wallet_deduction_usd }}</span>
                        </div>

                        <div class="host-summary-box">
                            <span class="label">Gateway Reference</span>
                            <span class="value">
                                {% if payment_transaction.gateway_transaction_id %}
                                    {{ payment_transaction.gateway_transaction_id }}
                                {% elif payment_transaction.gateway_session_id %}
                                    {{ payment_transaction.gateway_session_id }}
                                {% else %}
                                    Internal wallet payment
                                {% endif %}
                            </span>
                        </div>
                    </div>

                    <div class="row g-4">
                        <div class="col-lg-7">
                            <div class="host-items-panel">
                                <div class="d-flex align-items-center justify-content-between mb-3">
                                    <div>
                                        <h5 class="fw-bold mb-1">Paid Items</h5>
                                        <p class="text-muted small mb-0">
                                            These items were included in this event payment transaction.
                                        </p>
                                    </div>

                                    <i class="bi bi-receipt-cutoff fs-3 text-warning"></i>
                                </div>

                                <ul class="host-items-list">
                                    {% for item in payment_transaction.items.all %}
                                        <li class="host-item-row">
                                            <div class="d-flex align-items-start gap-3">
                                                <div class="host-item-icon">
                                                    <i class="bi bi-calendar2-check-fill"></i>
                                                </div>

                                                <div>
                                                    <div class="host-item-title">
                                                        {{ item.payable_item.title }}
                                                    </div>
                                                    <div class="host-item-note">
                                                        Event payment successfully processed
                                                    </div>
                                                </div>
                                            </div>

                                            <strong>${{ item.amount_usd }}</strong>
                                        </li>
                                    {% empty %}
                                        <li class="text-muted">
                                            No payment items found.
                                        </li>
                                    {% endfor %}
                                </ul>
                            </div>
                        </div>

                        <div class="col-lg-5">
                            <div class="host-next-card mb-4">
                                <h5 class="mb-2">
                                    <i class="bi bi-calendar-heart-fill me-2 text-warning"></i>
                                    What happens next?
                                </h5>

                                <p class="mb-0">
                                    Your booking payment has been recorded. The hosting arrangement can now move
                                    forward according to the confirmed booking details, venue availability,
                                    selected package, meals, add-ons, and coordination notes.
                                </p>
                            </div>

                            <div class="host-trust-note mb-4">
                                <i class="bi bi-lock-fill me-2"></i>
                                Your transaction has been recorded securely. Please keep your transaction number
                                <strong>#{{ payment_transaction.id }}</strong> for future reference.
                            </div>

                            <div class="d-grid gap-3">
                                <a href="{% url 'hosting_app:hosting_client_payment_center' %}"
                                   class="host-btn-gold">
                                    <i class="bi bi-credit-card me-2"></i>
                                    Back to Payment Center
                                </a>

                                <a href="{% url 'hosting_app:hosting_client_dashboard' %}"
                                   class="host-btn-dark">
                                    <i class="bi bi-speedometer2 me-2"></i>
                                    Go to Client Dashboard
                                </a>

                                <a href="{% url 'hosting_app:hosting_client_booking_list' %}"
                                   class="host-btn-outline">
                                    <i class="bi bi-calendar2-check me-2"></i>
                                    View My Bookings
                                </a>
                            </div>
                        </div>
                    </div>

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

</div>

{% endblock %}