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

{% block title %}Add-on Services | Host in Sri Lanka{% endblock %}

{% block content %}

<style>
    /* =========================================================
       HOST ADD-ON SERVICE LIST — PREMIUM DASHBOARD STYLE
    ========================================================= */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    .hosting-addon-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-addon-venue i {
        color: #a7601b;
        margin-top: 0.18rem;
    }

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

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

    .hosting-addon-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-addon-meta-chip.price {
        background: #fff4e4;
        border-color: #efd7ae;
        color: #7a4c18;
        font-weight: 900;
    }

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

    .hosting-addon-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-addon-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }

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

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

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

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

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

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

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

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

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

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


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

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

                <span class="hosting-addon-kicker">
                    <i class="bi bi-stars"></i>
                    Hosting Add-on Services
                </span>

                <h1>Manage Add-on Services</h1>

                <p>
                    Create optional add-on services connected to your venues. These can support
                    event packages with decoration, cakes, flowers, photography, music, transport,
                    spa experiences, surprise arrangements, or other custom celebration services.
                </p>

                <div class="hosting-addon-hero-actions">
                    <a href="{% url 'hosting_app:host_add_on_service_create' %}"
                       class="btn hosting-btn-gold">
                        <i class="bi bi-stars me-2"></i>
                        Add Service Add-on
                    </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-addon-summary-grid">

            <div class="hosting-addon-summary-card">
                <div class="hosting-addon-summary-icon">
                    <i class="bi bi-list-stars"></i>
                </div>
                <span>Total Add-ons</span>
                <strong>{{ total_count }}</strong>
            </div>

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

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

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

        </div>


        <!-- ADD-ON SERVICES CARD -->
        <div class="hosting-addon-main-card">

            <div class="hosting-addon-main-header">
                <div>
                    <h2>Add-on Service Listings</h2>
                    <p>
                        Review optional services and continue preparing them for admin approval,
                        public listing, and future guest booking workflows.
                    </p>
                </div>

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

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

                {% if add_on_services %}
                    <div class="hosting-addon-grid">

                        {% for service in add_on_services %}
                            <div class="hosting-addon-card">

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

                                    {% if service.add_on_image %}
                                        <img src="{{ service.add_on_image.url }}"
                                            alt="{{ service.title }}">
                                    {% else %}
                                        <div class="hosting-addon-image-placeholder">
                                            <i class="bi bi-stars"></i>
                                        </div>
                                    {% endif %}

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

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

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

                                    <div class="hosting-addon-category">
                                        <i class="bi bi-stars"></i>
                                        Add-on Service
                                    </div>

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

                                    <div class="hosting-addon-venue">
                                        <i class="bi bi-building-heart"></i>
                                        <span>
                                            {% if service.venue %}
                                                {{ service.venue.venue_name }}

                                                {% if service.venue.city or service.venue.district %}
                                                    <br>
                                                    <small>
                                                        {% if service.venue.get_city_display %}
                                                            {{ service.venue.get_city_display }}
                                                        {% else %}
                                                            {{ service.venue.city }}
                                                        {% endif %}
                                                        {% if service.venue.city and service.venue.district %}, {% endif %}
                                                        {% if service.venue.get_district_display %}
                                                            {{ service.venue.get_district_display }}
                                                        {% else %}
                                                            {{ service.venue.district }}
                                                        {% endif %}
                                                    </small>
                                                {% endif %}
                                            {% else %}
                                                Venue not selected
                                            {% endif %}
                                        </span>
                                    </div>

                                    <p class="hosting-addon-intro">
                                        {% if service.description %}
                                            {{ service.description|truncatechars:140 }}
                                        {% else %}
                                            Add a service description to help guests understand this optional arrangement.
                                        {% endif %}
                                    </p>

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

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

                                        {% if service.pricing_type %}
                                            <span class="hosting-addon-meta-chip">
                                                <i class="bi bi-tag-fill"></i>
                                                {{ service.get_pricing_type_display }}
                                            </span>
                                        {% endif %}

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

                                    </div>

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

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

                                        {% if service.venue %}
                                            <a href="{% url 'hosting_app:host_venue_detail' service.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-stars"></i>
                        </div>

                        <h3>No Add-on Services Added Yet</h3>

                        <p>
                            Start by adding optional services such as decoration, photography, birthday cake,
                            flowers, music, romantic table setup, surprise arrangement, spa package,
                            transport, or custom event support.
                        </p>

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

                {% endif %}

            </div>
        </div>

    </div>
</section>

{% endblock %}