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

{% block title %}Event Packages | Host in Sri Lanka{% endblock %}

{% block content %}

<style>
    /* =========================================================
       HOST EVENT PACKAGE LIST — PREMIUM DASHBOARD STYLE
    ========================================================= */

    .hosting-package-list-page {
        min-height: 100vh;
        padding: 4rem 0 5rem;
        background:
            radial-gradient(circle at top left, rgba(255, 193, 7, 0.12), transparent 28%),
            radial-gradient(circle at top right, rgba(116, 49, 41, 0.10), transparent 32%),
            linear-gradient(180deg, #fffaf5 0%, #fff4e8 42%, #ffffff 100%);
    }

    .hosting-package-hero {
        position: relative;
        overflow: hidden;
        border-radius: 38px;
        padding: 2.6rem 2.4rem;
        margin-bottom: 2rem;
        color: #ffffff;
        background:
            radial-gradient(circle at top right, rgba(255, 211, 107, 0.22), transparent 32%),
            linear-gradient(135deg, #2d1716 0%, #743129 56%, #a7601b 100%);
        box-shadow: 0 30px 68px rgba(58, 30, 24, 0.20);
    }

    .hosting-package-hero::before {
        content: "";
        position: absolute;
        top: -110px;
        right: -85px;
        width: 300px;
        height: 300px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.07);
        pointer-events: none;
    }

    .hosting-package-hero::after {
        content: "";
        position: absolute;
        bottom: -150px;
        left: -110px;
        width: 360px;
        height: 360px;
        border-radius: 50%;
        background: rgba(255, 193, 7, 0.10);
        pointer-events: none;
    }

    .hosting-package-hero-inner {
        position: relative;
        z-index: 2;
    }

    .hosting-package-kicker {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.52rem 1rem;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.14);
        border: 1px solid rgba(255, 255, 255, 0.22);
        color: #ffe7aa;
        font-size: 0.84rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 1rem;
    }

    .hosting-package-hero h1 {
        font-size: clamp(2.15rem, 4vw, 3.45rem);
        font-weight: 950;
        line-height: 1.1;
        letter-spacing: -0.045em;
        margin-bottom: 0.75rem;
    }

    .hosting-package-hero p {
        max-width: 840px;
        margin-bottom: 0;
        color: rgba(255, 255, 255, 0.88);
        font-size: 1.03rem;
        line-height: 1.8;
    }

    .hosting-package-hero-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.85rem;
        margin-top: 1.6rem;
    }

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

    .hosting-btn-gold {
        background: #ffc107;
        color: #2d1716;
        border: none;
    }

    .hosting-btn-gold:hover {
        background: #ffe082;
        color: #2d1716;
        transform: translateY(-1px);
    }

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

    .hosting-btn-light-outline:hover {
        background: #ffffff;
        color: #2d1716;
    }

    .hosting-package-summary-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .hosting-package-summary-card {
        border-radius: 26px;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid rgba(239, 226, 211, 0.95);
        box-shadow: 0 18px 38px rgba(58, 30, 24, 0.08);
        padding: 1.25rem;
    }

    .hosting-package-summary-icon {
        width: 48px;
        height: 48px;
        border-radius: 17px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #fff4e4;
        color: #a7601b;
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    .hosting-package-summary-card span {
        display: block;
        color: #7a655d;
        font-size: 0.78rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.045em;
        margin-bottom: 0.25rem;
    }

    .hosting-package-summary-card strong {
        color: #2d1716;
        font-size: 1.65rem;
        font-weight: 950;
        line-height: 1;
    }

    .hosting-package-main-card {
        border-radius: 34px;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid rgba(239, 226, 211, 0.95);
        box-shadow: 0 24px 56px rgba(58, 30, 24, 0.10);
        overflow: hidden;
    }

    .hosting-package-main-header {
        padding: 1.6rem 1.7rem;
        border-bottom: 1px solid #efe2d3;
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.08), transparent 28%),
            linear-gradient(180deg, #ffffff 0%, #fffaf5 100%);
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        flex-wrap: wrap;
    }

    .hosting-package-main-header h2 {
        color: #2d1716;
        font-weight: 950;
        margin-bottom: 0.25rem;
    }

    .hosting-package-main-header p {
        color: #7a655d;
        margin-bottom: 0;
        line-height: 1.65;
    }

    .hosting-package-list-wrap {
        padding: 1.5rem;
    }

    .hosting-package-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.25rem;
    }

    .hosting-package-card {
        border-radius: 28px;
        overflow: hidden;
        background: #ffffff;
        border: 1px solid #efe2d3;
        box-shadow: 0 16px 34px rgba(58, 30, 24, 0.07);
        height: 100%;
        display: flex;
        flex-direction: column;
        transition: 0.25s ease;
    }

    .hosting-package-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 24px 48px rgba(58, 30, 24, 0.12);
    }

    .hosting-package-image-wrap {
        position: relative;
        height: 215px;
        background: #fff4e4;
        overflow: hidden;
    }

    .hosting-package-image-wrap img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: 0.35s ease;
    }

    .hosting-package-card:hover .hosting-package-image-wrap img {
        transform: scale(1.04);
    }

    .hosting-package-image-placeholder {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #a7601b;
        font-size: 3rem;
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.18), transparent 34%),
            linear-gradient(135deg, #fffaf5, #fff4e4);
    }

    .hosting-package-badges {
        position: absolute;
        left: 1rem;
        right: 1rem;
        top: 1rem;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .hosting-status-badge,
    .hosting-featured-badge {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        padding: 0.4rem 0.7rem;
        border-radius: 999px;
        font-size: 0.72rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        backdrop-filter: blur(10px);
    }

    .hosting-status-badge {
        background: rgba(255, 255, 255, 0.92);
        color: #2d1716;
    }

    .hosting-featured-badge {
        background: rgba(255, 193, 7, 0.92);
        color: #2d1716;
    }

    .hosting-package-card-body {
        padding: 1.25rem;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .hosting-package-category {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        color: #a7601b;
        font-size: 0.78rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.045em;
        margin-bottom: 0.55rem;
    }

    .hosting-package-card h3 {
        color: #2d1716;
        font-size: 1.18rem;
        font-weight: 950;
        line-height: 1.3;
        margin-bottom: 0.55rem;
    }

    .hosting-package-venue {
        display: flex;
        align-items: flex-start;
        gap: 0.45rem;
        color: #7a655d;
        font-size: 0.92rem;
        line-height: 1.55;
        margin-bottom: 0.8rem;
    }

    .hosting-package-venue i {
        color: #a7601b;
        margin-top: 0.18rem;
    }

    .hosting-package-intro {
        color: #6f5b53;
        line-height: 1.68;
        font-size: 0.93rem;
        margin-bottom: 1.1rem;
    }

    .hosting-package-meta-row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.55rem;
        margin-top: auto;
        margin-bottom: 1rem;
    }

    .hosting-package-meta-chip {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        padding: 0.42rem 0.68rem;
        border-radius: 999px;
        background: #fffaf5;
        border: 1px solid #efe2d3;
        color: #6f5b53;
        font-size: 0.78rem;
        font-weight: 750;
    }

    .hosting-package-meta-chip.price {
        background: #fff4e4;
        border-color: #efd7ae;
        color: #7a4c18;
        font-weight: 900;
    }

    .hosting-package-inclusion-row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
        margin-bottom: 1rem;
    }

    .hosting-package-inclusion {
        display: inline-flex;
        align-items: center;
        gap: 0.3rem;
        border-radius: 999px;
        padding: 0.35rem 0.58rem;
        font-size: 0.72rem;
        font-weight: 850;
        color: #2d1716;
        background: #fff4e4;
        border: 1px solid #efd7ae;
    }

    .hosting-package-card-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.55rem;
        border-top: 1px solid #f0e4d6;
        padding-top: 1rem;
    }

    .hosting-package-card-actions .btn {
        border-radius: 999px;
        font-size: 0.84rem;
        font-weight: 850;
        min-height: 42px;
    }

    .hosting-empty-state {
        text-align: center;
        padding: 4rem 1.5rem;
    }

    .hosting-empty-icon {
        width: 96px;
        height: 96px;
        border-radius: 34px;
        background: linear-gradient(135deg, #fff4e4, #ffe7aa);
        color: #a7601b;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 2.7rem;
        margin-bottom: 1.4rem;
        box-shadow: 0 18px 36px rgba(167, 96, 27, 0.14);
    }

    .hosting-empty-state h3 {
        color: #2d1716;
        font-weight: 950;
        margin-bottom: 0.6rem;
    }

    .hosting-empty-state p {
        color: #7a655d;
        max-width: 650px;
        margin: 0 auto 1.5rem;
        line-height: 1.75;
    }

    @media (max-width: 1199.98px) {
        .hosting-package-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }

        .hosting-package-summary-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }
    }

    @media (max-width: 991.98px) {
        .hosting-package-list-page {
            padding-top: 2.8rem;
        }

        .hosting-package-hero {
            padding: 2rem 1.45rem;
            border-radius: 30px;
        }
    }

    @media (max-width: 767.98px) {
        .hosting-package-grid {
            grid-template-columns: 1fr;
        }

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

        .hosting-package-hero-actions {
            flex-direction: column;
            align-items: stretch;
        }

        .hosting-package-hero-actions .btn {
            width: 100%;
        }

        .hosting-package-main-header {
            padding: 1.35rem;
        }

        .hosting-package-list-wrap {
            padding: 1rem;
        }

        .hosting-package-card-actions {
            grid-template-columns: 1fr;
        }
    }
</style>


<section class="hosting-package-list-page">
    <div class="container">

        <!-- HERO -->
        <div class="hosting-package-hero">
            <div class="hosting-package-hero-inner">

                <span class="hosting-package-kicker">
                    <i class="bi bi-gift-fill"></i>
                    Hosting Event Packages
                </span>

                <h1>Manage Event Packages</h1>

                <p>
                    Create and manage event packages connected to your venues. These packages can later
                    be shown to guests for romantic dates, proposal events, anniversaries, birthdays,
                    honeymoon moments, private dinners, and custom celebrations.
                </p>

                <div class="hosting-package-hero-actions">
                    <a href="{% url 'hosting_app:host_event_package_create' %}"
                       class="btn hosting-btn-gold">
                        <i class="bi bi-gift-fill me-2"></i>
                        Create Event Package
                    </a>

                    <a href="{% url 'hosting_app:host_venue_list' %}"
                       class="btn hosting-btn-light-outline">
                        <i class="bi bi-buildings-fill me-2"></i>
                        My Venues
                    </a>

                    <a href="{% url 'hosting_app:host_dashboard' %}"
                       class="btn hosting-btn-light-outline">
                        <i class="bi bi-arrow-left-circle me-2"></i>
                        Back to Dashboard
                    </a>
                </div>

            </div>
        </div>


        <!-- SUMMARY -->
        <div class="hosting-package-summary-grid">

            <div class="hosting-package-summary-card">
                <div class="hosting-package-summary-icon">
                    <i class="bi bi-box-seam-fill"></i>
                </div>
                <span>Total Packages</span>
                <strong>{{ total_count }}</strong>
            </div>

            <div class="hosting-package-summary-card">
                <div class="hosting-package-summary-icon">
                    <i class="bi bi-check-circle-fill"></i>
                </div>
                <span>Active Packages</span>
                <strong>{{ active_count }}</strong>
            </div>

            <div class="hosting-package-summary-card">
                <div class="hosting-package-summary-icon">
                    <i class="bi bi-star-fill"></i>
                </div>
                <span>Featured</span>
                <strong>{{ featured_count }}</strong>
            </div>

            <div class="hosting-package-summary-card">
                <div class="hosting-package-summary-icon">
                    <i class="bi bi-eye-fill"></i>
                </div>
                <span>Public Ready</span>
                <strong>{{ public_ready_count }}</strong>
            </div>

        </div>


        <!-- PACKAGES CARD -->
        <div class="hosting-package-main-card">

            <div class="hosting-package-main-header">
                <div>
                    <h2>Package Listings</h2>
                    <p>
                        Review your created packages and continue preparing them for admin approval,
                        public listing, and guest booking workflows.
                    </p>
                </div>

                <a href="{% url 'hosting_app:host_event_package_create' %}"
                   class="btn btn-dark rounded-pill fw-bold">
                    <i class="bi bi-plus-circle-fill me-2"></i>
                    New Package
                </a>
            </div>

            <div class="hosting-package-list-wrap">

                {% if packages %}
                    <div class="hosting-package-grid">

                        {% for package in packages %}
                            <div class="hosting-package-card">

                                <div class="hosting-package-image-wrap">

                                    {% if package.image %}
                                        <img src="{{ package.image.url }}"
                                             alt="{{ package.title }}">
                                    {% elif package.package_image %}
                                        <img src="{{ package.package_image.url }}"
                                             alt="{{ package.title }}">
                                    {% else %}
                                        <div class="hosting-package-image-placeholder">
                                            <i class="bi bi-gift-fill"></i>
                                        </div>
                                    {% endif %}

                                    <div class="hosting-package-badges">
                                        <span class="hosting-status-badge">
                                            <i class="bi bi-circle-fill"></i>
                                            {% if package.listing_status %}
                                                {{ package.get_listing_status_display }}
                                            {% else %}
                                                Draft
                                            {% endif %}
                                        </span>

                                        {% if package.is_featured %}
                                            <span class="hosting-featured-badge">
                                                <i class="bi bi-star-fill"></i>
                                                Featured
                                            </span>
                                        {% endif %}
                                    </div>
                                </div>

                                <div class="hosting-package-card-body">

                                    <div class="hosting-package-category">
                                        <i class="bi bi-heart-fill"></i>
                                        {% if package.event_type %}
                                            {{ package.get_event_type_display }}
                                        {% else %}
                                            Event Package
                                        {% endif %}
                                    </div>

                                    <h3>{{ package.title }}</h3>

                                    <div class="hosting-package-venue">
                                        <i class="bi bi-building-heart"></i>
                                        <span>
                                            {% if package.venue %}
                                                {{ package.venue.venue_name }}
                                                {% if package.venue.city or package.venue.district %}
                                                    <br>
                                                    <small>
                                                        {% if package.venue.get_city_display %}
                                                            {{ package.venue.get_city_display }}
                                                        {% else %}
                                                            {{ package.venue.city }}
                                                        {% endif %}
                                                        {% if package.venue.city and package.venue.district %}, {% endif %}
                                                        {% if package.venue.get_district_display %}
                                                            {{ package.venue.get_district_display }}
                                                        {% else %}
                                                            {{ package.venue.district }}
                                                        {% endif %}
                                                    </small>
                                                {% endif %}
                                            {% else %}
                                                Venue not selected
                                            {% endif %}
                                        </span>
                                    </div>

                                    <p class="hosting-package-intro">
                                        {% if package.short_description %}
                                            {{ package.short_description|truncatechars:135 }}
                                        {% else %}
                                            Add a short package description to help guests understand what this experience includes.
                                        {% endif %}
                                    </p>

                                    <div class="hosting-package-meta-row">

                                        <span class="hosting-package-meta-chip price">
                                            <i class="bi bi-cash-coin"></i>
                                            USD {{ package.base_price_usd }}
                                        </span>

                                        {% if package.duration_hours %}
                                            <span class="hosting-package-meta-chip">
                                                <i class="bi bi-clock-fill"></i>
                                                {{ package.duration_hours }} hrs
                                            </span>
                                        {% endif %}

                                        {% if package.max_people_included %}
                                            <span class="hosting-package-meta-chip">
                                                <i class="bi bi-people-fill"></i>
                                                {{ package.max_people_included }} included
                                            </span>
                                        {% endif %}

                                        {% if package.is_active %}
                                            <span class="hosting-package-meta-chip">
                                                <i class="bi bi-check-circle-fill"></i>
                                                Active
                                            </span>
                                        {% else %}
                                            <span class="hosting-package-meta-chip">
                                                <i class="bi bi-pause-circle-fill"></i>
                                                Inactive
                                            </span>
                                        {% endif %}

                                    </div>

                                    <div class="hosting-package-inclusion-row">

                                        {% if package.includes_meals %}
                                            <span class="hosting-package-inclusion">
                                                <i class="bi bi-cup-hot-fill"></i>
                                                Meals
                                            </span>
                                        {% endif %}

                                        {% if package.includes_decoration %}
                                            <span class="hosting-package-inclusion">
                                                <i class="bi bi-balloon-heart-fill"></i>
                                                Decoration
                                            </span>
                                        {% endif %}

                                        {% if package.includes_photography %}
                                            <span class="hosting-package-inclusion">
                                                <i class="bi bi-camera-fill"></i>
                                                Photography
                                            </span>
                                        {% endif %}

                                        {% if package.includes_music %}
                                            <span class="hosting-package-inclusion">
                                                <i class="bi bi-music-note-beamed"></i>
                                                Music
                                            </span>
                                        {% endif %}

                                        {% if package.is_customizable %}
                                            <span class="hosting-package-inclusion">
                                                <i class="bi bi-magic"></i>
                                                Customizable
                                            </span>
                                        {% endif %}

                                    </div>

                                    <div class="hosting-package-card-actions">
                                        <a href="{% url 'hosting_app:host_event_package_detail' package.slug %}"
                                           class="btn btn-dark">
                                            <i class="bi bi-eye-fill me-1"></i>
                                            View
                                        </a>

                                        <a href="{% url 'hosting_app:host_event_package_update' package.slug %}"
                                           class="btn btn-outline-dark">
                                            <i class="bi bi-pencil-square me-1"></i>
                                            Edit
                                        </a>

                                        {% if package.venue %}
                                            <a href="{% url 'hosting_app:host_venue_detail' package.venue.slug %}"
                                               class="btn btn-outline-secondary">
                                                <i class="bi bi-building-heart me-1"></i>
                                                Venue
                                            </a>
                                        {% else %}
                                            <a href="#"
                                               class="btn btn-outline-secondary disabled"
                                               aria-disabled="true">
                                                <i class="bi bi-building-heart me-1"></i>
                                                Venue
                                            </a>
                                        {% endif %}

                                        <a href="#"
                                           class="btn btn-outline-secondary disabled"
                                           aria-disabled="true">
                                            <i class="bi bi-receipt-cutoff me-1"></i>
                                            Requests
                                        </a>
                                    </div>

                                </div>
                            </div>
                        {% endfor %}

                    </div>
                {% else %}

                    <div class="hosting-empty-state">
                        <div class="hosting-empty-icon">
                            <i class="bi bi-gift-fill"></i>
                        </div>

                        <h3>No Event Packages Added Yet</h3>

                        <p>
                            Start by creating your first package for a romantic date, proposal,
                            anniversary, birthday, private dinner, honeymoon moment, or custom celebration.
                            Packages help guests understand what they can book and how pricing works.
                        </p>

                        <a href="{% url 'hosting_app:host_event_package_create' %}"
                           class="btn hosting-btn-gold rounded-pill px-4 py-3 fw-bold">
                            <i class="bi bi-gift-fill me-2"></i>
                            Create My First Package
                        </a>
                    </div>

                {% endif %}

            </div>
        </div>

    </div>
</section>

{% endblock %}