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

{% block title %}My Venues | Host in Sri Lanka{% endblock %}

{% block content %}

<style>
    .hosting-venue-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-venue-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-venue-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-venue-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-venue-hero-inner {
        position: relative;
        z-index: 2;
    }

    .hosting-venue-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-venue-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-venue-hero p {
        max-width: 820px;
        margin-bottom: 0;
        color: rgba(255, 255, 255, 0.88);
        font-size: 1.03rem;
        line-height: 1.8;
    }

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

    .hosting-venue-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-venue-summary-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .hosting-venue-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-venue-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-venue-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-venue-summary-card strong {
        color: #2d1716;
        font-size: 1.65rem;
        font-weight: 950;
        line-height: 1;
    }

    .hosting-venue-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-venue-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-venue-main-header h2 {
        color: #2d1716;
        font-weight: 950;
        margin-bottom: 0.25rem;
    }

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

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

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

    .hosting-venue-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-venue-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 24px 48px rgba(58, 30, 24, 0.12);
    }

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

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

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

    .hosting-venue-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-venue-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-venue-card-body {
        padding: 1.25rem;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .hosting-venue-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-venue-card h3 {
        color: #2d1716;
        font-size: 1.18rem;
        font-weight: 950;
        line-height: 1.3;
        margin-bottom: 0.55rem;
    }

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

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

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

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

    .hosting-venue-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-venue-card-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.55rem;
        border-top: 1px solid #f0e4d6;
        padding-top: 1rem;
    }

    .hosting-venue-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: 620px;
        margin: 0 auto 1.5rem;
        line-height: 1.75;
    }

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

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

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

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

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

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

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

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

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

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

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


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

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

                <span class="hosting-venue-kicker">
                    <i class="bi bi-buildings-fill"></i>
                    Hosting Partner Venues
                </span>

                <h1>Manage My Venues</h1>

                <p>
                    Add, review, and manage the venues you want to present through
                    Host in Sri Lanka. These venues can later be connected with event packages,
                    meal plans, and add-on services for guest celebrations.
                </p>

                <div class="hosting-venue-hero-actions">
                    <a href="{% url 'hosting_app:host_venue_create' %}"
                       class="btn hosting-btn-gold">
                        <i class="bi bi-building-add me-2"></i>
                        Add New Venue
                    </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-venue-summary-grid">

            <div class="hosting-venue-summary-card">
                <div class="hosting-venue-summary-icon">
                    <i class="bi bi-buildings-fill"></i>
                </div>
                <span>Total Venues</span>
                <strong>{{ venues.count }}</strong>
            </div>

            <div class="hosting-venue-summary-card">
                <div class="hosting-venue-summary-icon">
                    <i class="bi bi-eye-fill"></i>
                </div>
                <span>Public Listings</span>
                <strong>{{ public_count }}</strong>
            </div>

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

            <div class="hosting-venue-summary-card">
                <div class="hosting-venue-summary-icon">
                    <i class="bi bi-images"></i>
                </div>
                <span>Gallery Ready</span>
                <strong>{{ gallery_ready_count }}</strong>
            </div>

        </div>


        <!-- VENUES CARD -->
        <div class="hosting-venue-main-card">

            <div class="hosting-venue-main-header">
                <div>
                    <h2>Venue Listings</h2>
                    <p>
                        Review your created venues and continue preparing them for approval, public listing,
                        gallery images, and event package creation.
                    </p>
                </div>

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

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

                {% if venues %}
                    <div class="hosting-venue-grid">

                        {% for venue in venues %}
                            <div class="hosting-venue-card">

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

                                    {% if venue.cover_image %}
                                        <img src="{{ venue.cover_image.url }}"
                                             alt="{{ venue.venue_name }}">
                                    {% else %}
                                        <div class="hosting-venue-image-placeholder">
                                            <i class="bi bi-building-heart"></i>
                                        </div>
                                    {% endif %}

                                    <div class="hosting-venue-badges">
                                        <span class="hosting-status-badge">
                                            <i class="bi bi-circle-fill"></i>

                                            {% if venue.listing_status %}
                                                {{ venue.get_listing_status_display }}
                                            {% else %}
                                                Draft
                                            {% endif %}
                                        </span>

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

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

                                    <div class="hosting-venue-category">
                                        <i class="bi bi-tag-fill"></i>
                                        {% if venue.venue_category %}
                                            {{ venue.get_venue_category_display }}
                                        {% else %}
                                            Venue
                                        {% endif %}
                                    </div>

                                    <h3>{{ venue.venue_name }}</h3>

                                    <div class="hosting-venue-location">
                                        <i class="bi bi-geo-alt-fill"></i>
                                        <span>
                                            {% if venue.city or venue.district %}
                                                {{ venue.city }}{% if venue.city and venue.district %}, {% endif %}{{ venue.district }}
                                            {% else %}
                                                Location not added
                                            {% endif %}
                                        </span>
                                    </div>

                                    <p class="hosting-venue-intro">
                                        {% if venue.short_description %}
                                            {{ venue.short_description|truncatechars:130 }}
                                        {% else %}
                                            Add a short venue description to help guests understand the experience you can host.
                                        {% endif %}
                                    </p>

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

                                        {% if venue.max_guest_capacity %}
                                            <span class="hosting-venue-meta-chip">
                                                <i class="bi bi-people-fill"></i>
                                                Up to {{ venue.max_guest_capacity }}
                                            </span>
                                        {% endif %}

                                        {% if venue.is_public %}
                                            <span class="hosting-venue-meta-chip">
                                                <i class="bi bi-check-circle-fill"></i>
                                                Public
                                            </span>
                                        {% else %}
                                            <span class="hosting-venue-meta-chip">
                                                <i class="bi bi-eye-slash-fill"></i>
                                                Not Public
                                            </span>
                                        {% endif %}

                                        {% if venue.meal_service_available %}
                                            <span class="hosting-venue-meta-chip">
                                                <i class="bi bi-cup-hot-fill"></i>
                                                Meals
                                            </span>
                                        {% endif %}

                                        {% if venue.parking_available %}
                                            <span class="hosting-venue-meta-chip">
                                                <i class="bi bi-p-square-fill"></i>
                                                Parking
                                            </span>
                                        {% endif %}

                                        <span class="hosting-venue-meta-chip">
                                            <i class="bi bi-images"></i>
                                            {{ venue.gallery_images.count }} Images
                                        </span>

                                    </div>

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

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

                                        <a href="{% url 'hosting_app:host_venue_gallery_manage' venue.slug %}"
                                           class="btn btn-outline-secondary">
                                            <i class="bi bi-images me-1"></i>
                                            Gallery
                                        </a>

                                        <a href="#"
                                           class="btn btn-outline-secondary disabled"
                                           aria-disabled="true">
                                            <i class="bi bi-gift-fill me-1"></i>
                                            Packages
                                        </a>
                                    </div>

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

                    </div>
                {% else %}

                    <div class="hosting-empty-state">
                        <div class="hosting-empty-icon">
                            <i class="bi bi-building-add"></i>
                        </div>

                        <h3>No Venues Added Yet</h3>

                        <p>
                            Start by adding your first restaurant, hotel, villa, rooftop, garden,
                            beach venue, resort, or event space. Once your venue is ready,
                            you can add gallery images and later create event packages, meal plans,
                            and add-on services.
                        </p>

                        <a href="{% url 'hosting_app:host_venue_create' %}"
                           class="btn hosting-btn-gold rounded-pill px-4 py-3 fw-bold">
                            <i class="bi bi-building-add me-2"></i>
                            Add My First Venue
                        </a>
                    </div>

                {% endif %}

            </div>
        </div>

    </div>
</section>

{% endblock %}