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

{% block title %}Review Booking | Host in Sri Lanka{% endblock %}

{% block content %}

<style>
    /* =========================================================
       LOCAL CLIENT BOOKING REVIEW — HOSTING APP THEME
    ========================================================= */

    .local-review-page {
        min-height: 100vh;
        background:
            radial-gradient(circle at top left, rgba(255, 193, 7, 0.10), transparent 30%),
            radial-gradient(circle at top right, rgba(116, 49, 41, 0.10), transparent 32%),
            linear-gradient(180deg, #fffaf5 0%, #ffffff 48%, #fff7ed 100%);
        color: #2c1b17;
        padding: 4rem 0 5rem;
    }

    .local-review-hero {
        border-radius: 36px;
        padding: 2.6rem 2.3rem;
        color: #ffffff;
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.22), transparent 35%),
            linear-gradient(145deg, #2e1817 0%, #6d2e28 64%, #a3601b 100%);
        box-shadow: 0 30px 70px rgba(53, 27, 22, 0.20);
        margin-bottom: 2rem;
    }

    .local-review-kicker {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.52rem 1rem;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.13);
        border: 1px solid rgba(255, 255, 255, 0.20);
        color: #ffd36b;
        font-size: 0.84rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.055em;
        margin-bottom: 1rem;
    }

    .local-review-hero h1 {
        font-size: clamp(2.15rem, 4vw, 3.65rem);
        font-weight: 950;
        line-height: 1.06;
        letter-spacing: -0.05em;
        margin-bottom: 0.8rem;
    }

    .local-review-hero p {
        color: rgba(255, 255, 255, 0.84);
        line-height: 1.8;
        max-width: 860px;
        margin-bottom: 0;
    }

    .local-review-card {
        border-radius: 32px;
        background: linear-gradient(145deg, #fffaf4 0%, #ffffff 100%);
        border: 1px solid rgba(124, 74, 50, 0.10);
        box-shadow: 0 18px 42px rgba(55, 31, 22, 0.07);
        overflow: hidden;
        margin-bottom: 1.4rem;
    }

    .local-review-card-header {
        padding: 1.45rem 1.55rem 1rem;
        border-bottom: 1px solid rgba(124, 74, 50, 0.10);
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.08), transparent 30%),
            linear-gradient(145deg, #fffaf4 0%, #ffffff 100%);
    }

    .local-review-card-header h2,
    .local-review-card-header h3 {
        color: #38231d;
        font-weight: 950;
        margin-bottom: 0.35rem;
    }

    .local-review-card-header p {
        color: #78625a;
        line-height: 1.65;
        margin-bottom: 0;
    }

    .local-review-card-body {
        padding: 1.55rem;
    }

    .local-review-info-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.9rem;
    }

    .local-review-info-item {
        border-radius: 22px;
        padding: 1rem;
        background: #fff7e8;
        border: 1px solid #efd8b7;
    }

    .local-review-info-item span {
        display: block;
        color: #8b6550;
        font-size: 0.76rem;
        font-weight: 950;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.35rem;
    }

    .local-review-info-item strong {
        color: #38231d;
        font-weight: 900;
        word-break: break-word;
    }

    .local-review-total-box {
        border-radius: 28px;
        padding: 1.45rem;
        color: #ffffff;
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.22), transparent 35%),
            linear-gradient(145deg, #2e1817 0%, #6d2e28 64%, #a3601b 100%);
        margin-bottom: 1rem;
    }

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

    .local-review-total-box strong {
        display: block;
        color: #ffffff;
        font-size: 2.25rem;
        font-weight: 950;
        line-height: 1;
    }

    .local-review-line {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.8rem 0;
        border-bottom: 1px solid #efd8b7;
        color: #6f4f3f;
    }

    .local-review-line:last-child {
        border-bottom: none;
    }

    .local-review-line strong {
        color: #38231d;
        text-align: right;
    }

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

    .local-review-actions .btn {
        border-radius: 999px;
        min-height: 52px;
        font-weight: 950;
        padding: 0.85rem 1.35rem;
    }

    .local-btn-gold {
        background: linear-gradient(135deg, #ffc83f, #df9219);
        color: #26160d;
        border: none;
        font-weight: 950 !important;
        box-shadow: 0 18px 34px rgba(223, 146, 25, 0.30);
        transition: all 0.22s ease;
    }

    .local-btn-gold:hover,
    .local-btn-gold:focus {
        background: linear-gradient(135deg, #2e1817, #6d2e28);
        color: #ffffff !important;
        transform: translateY(-2px);
        box-shadow: 0 22px 42px rgba(54, 28, 23, 0.28);
    }

    .local-review-status {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        border-radius: 999px;
        padding: 0.42rem 0.75rem;
        background: #fff7e8;
        border: 1px solid #efd8b7;
        color: #6f4f3f;
        font-size: 0.78rem;
        font-weight: 900;
    }

    .local-review-status.paid {
        background: #ecfdf5;
        border-color: #a7f3d0;
        color: #047857;
    }

    .local-review-status.due {
        background: #fffbeb;
        border-color: #fde68a;
        color: #92400e;
    }

    .local-review-status.cancelled {
        background: #fef2f2;
        border-color: #fecaca;
        color: #b91c1c;
    }

    @media (max-width: 767.98px) {
        .local-review-page {
            padding-top: 2.8rem;
        }

        .local-review-hero {
            padding: 2rem 1.35rem;
            border-radius: 30px;
        }

        .local-review-info-grid {
            grid-template-columns: 1fr;
        }

        .local-review-actions {
            flex-direction: column;
            align-items: stretch;
        }

        .local-review-actions .btn {
            width: 100%;
        }

        .local-review-line {
            flex-direction: column;
            gap: 0.25rem;
        }

        .local-review-line strong {
            text-align: left;
        }
    }

    @media (max-width: 575.98px) {
        .local-review-page > .container {
            padding-left: 1.25rem !important;
            padding-right: 1.25rem !important;
        }
    }
</style>


<section class="local-review-page">
    <div class="container">

        <!-- HERO -->
        <div class="local-review-hero">
            <span class="local-review-kicker">
                <i class="bi bi-check-circle-fill"></i>
                Review Local Client Booking
            </span>

            <h1>Review your booking before payment</h1>

            <p>
                Please check your selected venue, event details, package, meal plan, add-on services,
                and total amount. After confirmation, you can complete payment from your Hosting Client Payment Center.
            </p>
        </div>


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

            <!-- MAIN -->
            <div class="col-lg-8">

                <!-- Booking Details -->
                <div class="local-review-card">
                    <div class="local-review-card-header">
                        <h2>Booking Details</h2>
                        <p>
                            Your selected event and venue information.
                        </p>
                    </div>

                    <div class="local-review-card-body">
                        <div class="local-review-info-grid">

                            <div class="local-review-info-item">
                                <span>Client</span>
                                <strong>
                                    {% if hosting_client_profile %}
                                        {{ hosting_client_profile.full_name }}
                                    {% elif booking.hosting_client_profile %}
                                        {{ booking.hosting_client_profile.full_name }}
                                    {% elif booking.booked_by_user %}
                                        {{ booking.booked_by_user.get_username }}
                                    {% else %}
                                        Local Client
                                    {% endif %}
                                </strong>
                            </div>

                            <div class="local-review-info-item">
                                <span>Client Type</span>
                                <strong>{{ booking.get_client_type_display }}</strong>
                            </div>

                            <div class="local-review-info-item">
                                <span>Venue</span>
                                <strong>{{ booking.venue_name_snapshot }}</strong>
                            </div>

                            <div class="local-review-info-item">
                                <span>Host</span>
                                <strong>{{ booking.host_business_name_snapshot|default:"Hosting Partner" }}</strong>
                            </div>

                            <div class="local-review-info-item">
                                <span>Event Type</span>
                                <strong>{{ booking.get_event_type_display }}</strong>
                            </div>

                            <div class="local-review-info-item">
                                <span>Event Date</span>
                                <strong>{{ booking.preferred_event_date }}</strong>
                            </div>

                            <div class="local-review-info-item">
                                <span>Start Time</span>
                                <strong>{{ booking.preferred_start_time|default:"Flexible / Not specified" }}</strong>
                            </div>

                            <div class="local-review-info-item">
                                <span>Guests</span>
                                <strong>{{ booking.number_of_guests }}</strong>
                            </div>

                            {% if booking.expected_duration_hours %}
                                <div class="local-review-info-item">
                                    <span>Duration</span>
                                    <strong>{{ booking.expected_duration_hours }} hours</strong>
                                </div>
                            {% endif %}

                            <div class="local-review-info-item">
                                <span>Booking Status</span>
                                <strong>
                                    <span class="local-review-status">
                                        <i class="bi bi-list-check"></i>
                                        {{ booking.get_status_display }}
                                    </span>
                                </strong>
                            </div>

                            <div class="local-review-info-item">
                                <span>Payment Status</span>
                                <strong>
                                    <span class="local-review-status {% if booking.payment_status == 'paid' %}paid{% elif booking.payment_status == 'due' or booking.payment_status == 'unpaid' %}due{% elif booking.payment_status == 'cancelled' %}cancelled{% endif %}">
                                        <i class="bi bi-credit-card-fill"></i>
                                        {{ booking.get_payment_status_display }}
                                    </span>
                                </strong>
                            </div>

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


                <!-- Selected Items -->
                <div class="local-review-card">
                    <div class="local-review-card-header">
                        <h3>Selected Items</h3>
                        <p>
                            Package, meal plan, and add-on services included in this booking.
                        </p>
                    </div>

                    <div class="local-review-card-body">

                        <div class="local-review-line">
                            <span>Event Package</span>
                            <strong>
                                {% if booking.selected_package %}
                                    {{ booking.package_title_snapshot }} — USD {{ booking.package_amount_snapshot_usd|floatformat:2 }}
                                {% else %}
                                    Not selected
                                {% endif %}
                            </strong>
                        </div>

                        <div class="local-review-line">
                            <span>Meal Plan</span>
                            <strong>
                                {% if booking.selected_meal_plan %}
                                    {{ booking.meal_plan_title_snapshot }} — USD {{ booking.meal_amount_snapshot_usd|floatformat:2 }}
                                {% else %}
                                    Not selected
                                {% endif %}
                            </strong>
                        </div>

                        <div class="local-review-line">
                            <span>Add-on Services</span>
                            <strong>USD {{ booking.add_on_amount_snapshot_usd|floatformat:2 }}</strong>
                        </div>

                        {% if selected_add_ons %}
                            <div class="mt-3">
                                {% for item in selected_add_ons %}
                                    <div class="local-review-info-item mb-2">
                                        <span>{{ item.add_on_title_snapshot }}</span>
                                        <strong>
                                            {{ item.quantity }} × USD {{ item.unit_price_snapshot_usd|floatformat:2 }}
                                            = USD {{ item.subtotal_snapshot_usd|floatformat:2 }}
                                        </strong>
                                    </div>
                                {% endfor %}
                            </div>
                        {% endif %}

                    </div>
                </div>


                <!-- Notes -->
                {% if booking.occasion_title or booking.occasion_note or booking.special_requests %}
                    <div class="local-review-card">
                        <div class="local-review-card-header">
                            <h3>Occasion Notes</h3>
                            <p>
                                Your personal notes and special requests.
                            </p>
                        </div>

                        <div class="local-review-card-body">

                            {% if booking.occasion_title %}
                                <div class="local-review-info-item mb-2">
                                    <span>Occasion Title</span>
                                    <strong>{{ booking.occasion_title }}</strong>
                                </div>
                            {% endif %}

                            {% if booking.occasion_note %}
                                <div class="local-review-info-item mb-2">
                                    <span>Occasion Note</span>
                                    <strong style="white-space: pre-line;">{{ booking.occasion_note }}</strong>
                                </div>
                            {% endif %}

                            {% if booking.special_requests %}
                                <div class="local-review-info-item">
                                    <span>Special Requests</span>
                                    <strong style="white-space: pre-line;">{{ booking.special_requests }}</strong>
                                </div>
                            {% endif %}

                        </div>
                    </div>
                {% endif %}

            </div>


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

                <div class="local-review-card">
                    <div class="local-review-card-header">
                        <h3>Payment Summary</h3>
                        <p>
                            This amount will appear in your Hosting Client Payment Center.
                        </p>
                    </div>

                    <div class="local-review-card-body">

                        <div class="local-review-total-box">
                            <span>Total Booking Amount</span>
                            <strong>USD {{ booking.total_amount_usd|floatformat:2 }}</strong>
                        </div>

                        <div class="local-review-line">
                            <span>Package</span>
                            <strong>USD {{ booking.package_amount_snapshot_usd|floatformat:2 }}</strong>
                        </div>

                        <div class="local-review-line">
                            <span>Meal</span>
                            <strong>USD {{ booking.meal_amount_snapshot_usd|floatformat:2 }}</strong>
                        </div>

                        <div class="local-review-line">
                            <span>Add-ons</span>
                            <strong>USD {{ booking.add_on_amount_snapshot_usd|floatformat:2 }}</strong>
                        </div>

                        {% if booking.payment_reference_code %}
                            <div class="local-review-line">
                                <span>Reference</span>
                                <strong>{{ booking.payment_reference_code }}</strong>
                            </div>
                        {% endif %}

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

                            <div class="local-review-actions">

                                {% if booking.payment_status == 'paid' %}
                                    <a href="{% url 'hosting_app:hosting_client_payment_center' %}"
                                       class="btn local-btn-gold w-100">
                                        <i class="bi bi-wallet2 me-2"></i>
                                        Go to Payment Center
                                    </a>
                                {% else %}
                                    <button type="submit" class="btn local-btn-gold w-100">
                                        <i class="bi bi-wallet2 me-2"></i>
                                        Confirm & Go to Payment Center
                                    </button>
                                {% endif %}

                                {% if booking.payment_status == 'paid' %}
                                    <button type="button"
                                            class="btn btn-success w-100"
                                            disabled>
                                        <i class="bi bi-lock-fill me-2"></i>
                                        Booking Paid - Editing Locked
                                    </button>

                                    <div class="small text-muted mt-2">
                                        This booking has already been paid. Editing is disabled to protect the confirmed event details.
                                    </div>
                                {% else %}
                                    <a href="{% url 'hosting_app:local_client_booking_start' venue.slug %}"
                                    class="btn btn-outline-dark w-100">
                                        <i class="bi bi-pencil-square me-2"></i>
                                        Edit Booking
                                    </a>
                                {% endif %}

                                <a href="{% url 'hosting_app:public_host_venue_detail' venue.slug %}"
                                   class="btn btn-outline-secondary w-100">
                                    <i class="bi bi-arrow-left-circle me-2"></i>
                                    Back to Venue
                                </a>

                                <a href="{% url 'hosting_app:hosting_client_dashboard' %}"
                                   class="btn btn-outline-secondary w-100">
                                    <i class="bi bi-speedometer2 me-2"></i>
                                    Client Dashboard
                                </a>

                            </div>
                        </form>

                    </div>
                </div>

            </div>

        </div>

    </div>
</section>

{% endblock %}