{% extends 'rental_app/base_rental.html' %}
{% load static %}
{% block title %}Rental Owner Dashboard{% endblock %}


{% block extra_css %}
<style>
    /* =========================================================
       RENTAL OWNER DASHBOARD — PREMIUM TOUCH
    ========================================================= */

    .rental-dashboard-page {
        min-height: 100vh;
        background:
            radial-gradient(circle at top left, rgba(251, 191, 36, 0.12), transparent 32%),
            radial-gradient(circle at top right, rgba(14, 116, 144, 0.10), transparent 34%),
            linear-gradient(180deg, #f8fafc 0%, #eff6ff 42%, #ffffff 100%);
    }

    /* =========================================================
       SIGNUP SUCCESS PANEL
    ========================================================= */

    .rental-success-panel {
        border-radius: 32px;
        border: 1px solid rgba(34, 197, 94, 0.22);
        background:
            radial-gradient(circle at top right, rgba(34, 197, 94, 0.12), transparent 32%),
            linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
        box-shadow: 0 22px 48px rgba(15, 23, 42, 0.10);
        padding: 1.6rem 1.7rem;
    }

    .rental-success-icon {
        width: 58px;
        height: 58px;
        min-width: 58px;
        border-radius: 22px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1.75rem;
        background: #dcfce7;
        color: #15803d;
    }

    .rental-success-title {
        color: #0f172a;
        font-size: 1.35rem;
        font-weight: 900;
        margin-bottom: 0.45rem;
    }

    .rental-success-copy {
        color: #475569;
        line-height: 1.7;
    }

    .rental-credential-panel {
        border-radius: 26px;
        border: 1px solid #dbe4ee;
        background: rgba(255, 255, 255, 0.96);
        padding: 1.15rem 1.25rem;
    }

    .rental-credential-row {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        padding: 0.42rem 0;
    }

    .rental-credential-label {
        color: #0f172a;
        font-weight: 900;
        min-width: 150px;
    }

    .rental-credential-value {
        color: #334155;
        word-break: break-word;
    }

    .rental-security-note {
        border-top: 1px dashed #dbe4ee;
        margin-top: 1rem;
        padding-top: 1rem;
        color: #64748b;
        line-height: 1.65;
        font-size: 0.92rem;
    }

    /* =========================================================
       DASHBOARD HERO / WELCOME
    ========================================================= */

    .rental-dashboard-hero-section {
        padding-top: 3rem;
        padding-bottom: 3.5rem;
    }

    .rental-dashboard-welcome-card {
        position: relative;
        overflow: hidden;
        height: 100%;
        border-radius: 38px;
        background:
            radial-gradient(circle at top right, rgba(251, 191, 36, 0.18), transparent 34%),
            linear-gradient(135deg, #082f49 0%, #0e7490 58%, #0f766e 100%);
        color: #ffffff;
        border: none;
        box-shadow: 0 30px 70px rgba(15, 23, 42, 0.20);
        padding: 2.55rem 2.35rem;
    }

    .rental-dashboard-welcome-card::before {
        content: "";
        position: absolute;
        top: -100px;
        right: -80px;
        width: 290px;
        height: 290px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.08);
        pointer-events: none;
    }

    .rental-dashboard-welcome-card::after {
        content: "";
        position: absolute;
        bottom: -140px;
        left: -90px;
        width: 340px;
        height: 340px;
        border-radius: 50%;
        background: rgba(251, 191, 36, 0.09);
        pointer-events: none;
    }

    .rental-dashboard-welcome-inner {
        position: relative;
        z-index: 2;
    }

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

    .rental-dashboard-welcome-card h1 {
        font-size: clamp(2.2rem, 4vw, 3.55rem);
        line-height: 1.08;
        font-weight: 950;
        letter-spacing: -0.045em;
        margin-bottom: 0.9rem;
    }

    .rental-dashboard-welcome-card .lead {
        color: rgba(255, 255, 255, 0.88);
        line-height: 1.78;
        font-size: 1.05rem;
        max-width: 800px;
    }

    /* Dashboard stats inside hero */
    .rental-mini-stat-card {
        height: 100%;
        border-radius: 24px;
        background: rgba(255, 255, 255, 0.14);
        border: 1px solid rgba(255, 255, 255, 0.20);
        backdrop-filter: blur(8px);
        padding: 1rem 0.95rem;
        text-align: center;
    }

    .rental-mini-stat-card h4 {
        color: #ffffff;
        font-size: 1.7rem;
        font-weight: 950;
        margin-bottom: 0.2rem;
    }

    .rental-mini-stat-card p {
        color: rgba(255, 255, 255, 0.80);
        font-weight: 700;
        margin-bottom: 0;
        font-size: 0.86rem;
    }

    /* =========================================================
       OWNER STATUS CARD
    ========================================================= */

    .rental-dashboard-status-card {
        height: 100%;
        border-radius: 36px;
        border: 1px solid rgba(226, 232, 240, 0.95);
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 22px 52px rgba(15, 23, 42, 0.11);
        padding: 1.65rem;
    }

    .rental-status-title {
        color: #0f172a;
        font-weight: 950;
        margin-bottom: 1.2rem;
    }

    .rental-status-line {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1rem;
        padding: 0.85rem 0;
        border-bottom: 1px dashed #dbe4ee;
    }

    .rental-status-line:last-of-type {
        border-bottom: 0;
    }

    .rental-status-label {
        color: #334155;
        font-weight: 850;
    }

    .rental-status-value {
        text-align: right;
        font-weight: 900;
    }

    .rental-status-pill {
        display: inline-flex;
        align-items: center;
        gap: 0.42rem;
        padding: 0.42rem 0.78rem;
        border-radius: 999px;
        font-size: 0.8rem;
        font-weight: 900;
        white-space: nowrap;
    }

    .rental-status-pill.success {
        background: #dcfce7;
        color: #166534;
    }

    .rental-status-pill.warning {
        background: #fef3c7;
        color: #92400e;
    }

    .rental-status-pill.muted {
        background: #e2e8f0;
        color: #475569;
    }

    .rental-status-add-btn {
        border-radius: 999px;
        min-height: 52px;
        font-weight: 900;
        background: linear-gradient(135deg, #0f172a, #334155);
        border: none;
    }

    .rental-status-alert {
        border-radius: 24px;
        border: 1px solid #fde68a;
        background: #fffbeb;
        color: #92400e;
        line-height: 1.65;
    }

    /* =========================================================
       QUICK ACTION SECTION
    ========================================================= */

    .rental-dashboard-actions-section {
        padding-top: 1rem;
        padding-bottom: 3.8rem;
    }

    .rental-action-card {
        position: relative;
        overflow: hidden;
        height: 100%;
        border-radius: 32px;
        border: 1px solid rgba(226, 232, 240, 0.95);
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
        padding: 1.55rem 1.35rem;
        display: flex;
        flex-direction: column;
        transition: all 0.22s ease;
    }

    .rental-action-card::after {
        content: "";
        position: absolute;
        top: -70px;
        right: -70px;
        width: 150px;
        height: 150px;
        border-radius: 50%;
        background: rgba(14, 116, 144, 0.055);
        pointer-events: none;
    }

    .rental-action-card:hover {
        transform: translateY(-4px);
        border-color: rgba(14, 116, 144, 0.22);
        box-shadow: 0 28px 58px rgba(15, 23, 42, 0.12);
    }

    .rental-action-card > * {
        position: relative;
        z-index: 2;
    }

    .rental-action-card-icon {
        width: 64px;
        height: 64px;
        border-radius: 22px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1.55rem;
        background: linear-gradient(135deg, #ecfeff, #cffafe);
        color: #0e7490;
        margin-bottom: 0.6rem;
    }

    .rental-action-card.gold .rental-action-card-icon {
        background: #fef3c7;
        color: #b45309;
    }

    .rental-action-card.green .rental-action-card-icon {
        background: #dcfce7;
        color: #15803d;
    }

    .rental-action-card.dark .rental-action-card-icon {
        background: #e2e8f0;
        color: #334155;
    }

    .rental-action-card h5 {
        color: #0f172a;
        font-weight: 950;
        line-height: 1.35;
        margin-bottom: 0.55rem;
    }

    .rental-action-card p {
        color: #64748b;
        line-height: 1.68;
        font-size: 0.94rem;
        flex-grow: 1;
        margin-bottom: 1.15rem;
    }

    .rental-action-card .btn {
        align-self: flex-start;
        border-radius: 999px;
        font-weight: 850;
        padding: 0.65rem 1.05rem;
    }

    .dashboard-profile-icon {
        width: 82px;
        height: 82px;
        border-radius: 28px;
        object-fit: cover;
        border: 4px solid rgba(14, 116, 144, 0.14);
        box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
        margin-bottom: 0.5rem;
    }

    .rental-profile-card {
        text-align: center;
    }

    .rental-profile-card .btn {
        align-self: center;
    }

    /* =========================================================
       LISTINGS SECTION
    ========================================================= */

    .rental-listings-section {
        padding-top: 0.5rem;
        padding-bottom: 5rem;
    }

    .rental-listings-heading {
        margin-bottom: 1.8rem;
    }

    .rental-listings-heading h2 {
        color: #0f172a;
        font-weight: 950;
        letter-spacing: -0.025em;
        margin-bottom: 0.3rem;
    }

    .rental-listings-heading p {
        color: #64748b;
        line-height: 1.7;
    }

    .rental-listings-add-btn {
        border-radius: 999px;
        font-weight: 900;
        padding: 0.8rem 1.3rem;
        background: linear-gradient(135deg, #0f172a, #334155);
        border: none;
    }

    .rental-listing-card {
        height: 100%;
        border-radius: 32px;
        overflow: hidden;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        box-shadow: 0 18px 42px rgba(15, 23, 42, 0.09);
        transition: all 0.22s ease;
    }

    .rental-listing-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 28px 58px rgba(15, 23, 42, 0.13);
    }

    .rental-listing-image,
    .rental-listing-placeholder {
        width: 100%;
        height: 230px;
        object-fit: cover;
        display: block;
    }

    .rental-listing-placeholder {
        display: flex;
        align-items: center;
        justify-content: center;
        background:
            radial-gradient(circle at top right, rgba(251, 191, 36, 0.10), transparent 32%),
            linear-gradient(135deg, #f8fafc, #eff6ff);
        color: #0e7490;
        font-size: 2.8rem;
    }

    .rental-listing-body {
        padding: 1.45rem 1.45rem 1.55rem;
        display: flex;
        flex-direction: column;
        height: calc(100% - 230px);
    }

    .rental-listing-badges {
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
        margin-bottom: 1rem;
    }

    .rental-listing-badges .badge {
        border-radius: 999px;
        padding: 0.5rem 0.72rem;
        font-size: 0.76rem;
        font-weight: 850;
    }

    .rental-listing-title {
        color: #0f172a;
        font-weight: 950;
        font-size: 1.18rem;
        line-height: 1.38;
        margin-bottom: 0.6rem;
    }

    .rental-listing-meta {
        color: #64748b;
        line-height: 1.6;
        margin-bottom: 0.48rem;
    }

    .rental-listing-detail {
        color: #334155;
        margin-bottom: 0.48rem;
    }

    .rental-listing-description {
        color: #64748b;
        line-height: 1.68;
        font-size: 0.93rem;
        margin-bottom: 0.9rem;
    }

    .rental-listing-created {
        color: #64748b;
        font-size: 0.86rem;
        padding-top: 0.2rem;
        margin-bottom: 1rem;
    }

    .rental-listing-actions {
        margin-top: auto;
        display: grid;
        gap: 0.65rem;
    }

    .rental-listing-actions .btn {
        border-radius: 999px;
        font-weight: 900;
        padding: 0.7rem 1rem;
    }

    /* =========================================================
       EMPTY STATE
    ========================================================= */

    .rental-empty-state {
        border-radius: 34px;
        padding: 3rem 1.6rem;
        border: 1px dashed rgba(14, 116, 144, 0.32);
        background:
            radial-gradient(circle at top right, rgba(251, 191, 36, 0.10), transparent 32%),
            linear-gradient(135deg, #f8fafc, #ecfeff);
        text-align: center;
        box-shadow: 0 18px 42px rgba(15, 23, 42, 0.06);
    }

    .rental-empty-icon {
        width: 96px;
        height: 96px;
        margin: 0 auto 1.25rem;
        border-radius: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #ffffff;
        color: #0e7490;
        font-size: 2.45rem;
        box-shadow: 0 16px 32px rgba(15, 23, 42, 0.10);
    }

    .rental-empty-state h5 {
        color: #0f172a;
        font-weight: 950;
        font-size: 1.35rem;
        margin-bottom: 0.55rem;
    }

    .rental-empty-state p {
        color: #64748b;
        line-height: 1.72;
        max-width: 680px;
        margin-left: auto;
        margin-right: auto;
    }

    .rental-empty-state .btn {
        border-radius: 999px;
        font-weight: 900;
        padding: 0.8rem 1.25rem;
    }

    /* =========================================================
       RESPONSIVE
    ========================================================= */

    @media (min-width: 576px) {
        .rental-credential-row {
            flex-direction: row;
            align-items: flex-start;
            gap: 0.8rem;
        }
    }

    @media (max-width: 991.98px) {
        .rental-dashboard-welcome-card {
            padding: 2rem 1.45rem;
            border-radius: 30px;
        }

        .rental-dashboard-status-card {
            border-radius: 30px;
        }

        .rental-status-line {
            flex-direction: column;
            gap: 0.45rem;
        }

        .rental-status-value {
            text-align: left;
        }
    }

    @media (max-width: 767.98px) {
        .rental-success-panel {
            padding: 1.2rem;
            border-radius: 26px;
        }

        .rental-action-card {
            border-radius: 26px;
            padding: 1.35rem 1.2rem;
        }

        .rental-listing-card {
            border-radius: 28px;
        }

        .rental-listings-heading {
            margin-bottom: 1.2rem;
        }
    }

    /* =========================================================
   CONNECTED ENSOLANKA ACCESS
    ========================================================= */

    .rental-access-panel {
        border-radius: 36px;
        border: 1px solid rgba(226, 232, 240, 0.95);
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 22px 52px rgba(15, 23, 42, 0.10);
        padding: 1.8rem;
    }

    .rental-access-header {
        margin-bottom: 1.6rem;
    }

    .rental-access-kicker {
        display: inline-flex;
        align-items: center;
        gap: 0.45rem;
        color: #0e7490;
        font-size: 0.83rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.5rem;
    }

    .rental-access-header h2 {
        color: #0f172a;
        font-weight: 950;
        letter-spacing: -0.025em;
        margin-bottom: 0.4rem;
    }

    .rental-access-header p {
        color: #64748b;
        line-height: 1.7;
        margin-bottom: 0;
    }

    .rental-action-card form {
        margin-top: auto;
    }

    .rental-action-card form .btn {
        border-radius: 999px;
        font-weight: 850;
        padding: 0.65rem 1.05rem;
    }

    @media (max-width: 767.98px) {
        .rental-access-panel {
            border-radius: 28px;
            padding: 1.35rem;
        }
    }
</style>
{% endblock %}


{% block content %}

<section class="rental-dashboard-page">

    <!-- =====================================================
         HERO / OWNER OVERVIEW
    ====================================================== -->
    <section class="rental-dashboard-hero-section">
        <div class="container">

            {% if just_signed_up %}
                <div class="row justify-content-center mb-4">
                    <div class="col-12 col-lg-10">
                        <div class="rental-success-panel">

                            <div class="d-flex flex-column flex-md-row align-items-start gap-3">
                                <div class="rental-success-icon">
                                    <i class="bi bi-check-circle-fill"></i>
                                </div>

                                <div class="w-100">
                                    <h4 class="rental-success-title">
                                        Welcome! Your rental owner account has been created successfully.
                                    </h4>

                                    <p class="rental-success-copy mb-3">
                                        You are now signed in to your rental owner dashboard.
                                        Please keep your login details safe for future access.
                                    </p>

                                    {% if account_role or new_account_email or username or password %}
                                        <div class="rental-credential-panel">
                                            <div class="row g-2">

                                                {% if account_role %}
                                                    <div class="col-12">
                                                        <div class="rental-credential-row">
                                                            <span class="rental-credential-label">
                                                                Account Type:
                                                            </span>
                                                            <span class="rental-credential-value">
                                                                {{ account_role }}
                                                            </span>
                                                        </div>
                                                    </div>
                                                {% endif %}

                                                {% if new_account_email %}
                                                    <div class="col-12">
                                                        <div class="rental-credential-row">
                                                            <span class="rental-credential-label">
                                                                Email:
                                                            </span>
                                                            <span class="rental-credential-value">
                                                                {{ new_account_email }}
                                                            </span>
                                                        </div>
                                                    </div>
                                                {% endif %}

                                                {% if username %}
                                                    <div class="col-12">
                                                        <div class="rental-credential-row">
                                                            <span class="rental-credential-label">
                                                                Username:
                                                            </span>
                                                            <span class="rental-credential-value">
                                                                {{ username }}
                                                            </span>
                                                        </div>
                                                    </div>
                                                {% endif %}

                                                {% if password %}
                                                    <div class="col-12">
                                                        <div class="rental-credential-row">
                                                            <span class="rental-credential-label">
                                                                Temporary Password:
                                                            </span>
                                                            <span class="rental-credential-value">
                                                                {{ password }}
                                                            </span>
                                                        </div>
                                                    </div>
                                                {% endif %}

                                            </div>

                                            <div class="rental-security-note">
                                                Your initial username and password have been sent to your email address.
                                                For better security, please change your password after your first login.
                                            </div>
                                        </div>
                                    {% endif %}
                                </div>
                            </div>

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


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

                <div class="col-lg-8">
                    <div class="rental-dashboard-welcome-card">
                        <div class="rental-dashboard-welcome-inner">

                            <span class="rental-dashboard-mini-title">
                                <i class="bi bi-buildings-fill"></i>
                                Rental Owner Dashboard
                            </span>

                            <h1>
                                Welcome, {{ owner.full_name }}
                            </h1>

                            <p class="lead mb-4">
                                Manage your property submissions, view approval status,
                                monitor your rental listings, and grow your visibility
                                among international guests from one place.
                            </p>

                            <div class="row g-3 mt-2">

                                <div class="col-sm-6 col-lg-3">
                                    <div class="rental-mini-stat-card">
                                        <h4>{{ total_listings }}</h4>
                                        <p>Total Listings</p>
                                    </div>
                                </div>

                                <div class="col-sm-6 col-lg-3">
                                    <div class="rental-mini-stat-card">
                                        <h4>{{ approved_listings }}</h4>
                                        <p>Approved</p>
                                    </div>
                                </div>

                                <div class="col-sm-6 col-lg-3">
                                    <div class="rental-mini-stat-card">
                                        <h4>{{ pending_listings }}</h4>
                                        <p>Pending</p>
                                    </div>
                                </div>

                                <div class="col-sm-6 col-lg-3">
                                    <div class="rental-mini-stat-card">
                                        <h4>{{ active_listings }}</h4>
                                        <p>Active</p>
                                    </div>
                                </div>

                            </div>

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


                <div class="col-lg-4">
                    <div class="rental-dashboard-status-card">

                        <h5 class="rental-status-title">
                            Owner Status
                        </h5>

                        <div class="rental-status-line">
                            <span class="rental-status-label">
                                Owner Type
                            </span>

                            <span class="rental-status-value">
                                {{ owner.get_owner_type_display }}
                            </span>
                        </div>

                        <div class="rental-status-line">
                            <span class="rental-status-label">
                                Approved
                            </span>

                            <span class="rental-status-value">
                                {% if owner.is_approved %}
                                    <span class="rental-status-pill success">
                                        <i class="bi bi-check-circle-fill"></i>
                                        Yes
                                    </span>
                                {% else %}
                                    <span class="rental-status-pill warning">
                                        <i class="bi bi-hourglass-split"></i>
                                        Pending Review
                                    </span>
                                {% endif %}
                            </span>
                        </div>

                        <div class="rental-status-line">
                            <span class="rental-status-label">
                                Can Submit Listings
                            </span>

                            <span class="rental-status-value">
                                {% if owner.can_submit_listings %}
                                    <span class="rental-status-pill success">
                                        <i class="bi bi-check-circle-fill"></i>
                                        Yes
                                    </span>
                                {% else %}
                                    <span class="rental-status-pill muted">
                                        <i class="bi bi-dash-circle-fill"></i>
                                        Not Yet
                                    </span>
                                {% endif %}
                            </span>
                        </div>

                        <div class="mt-4">
                            {% if owner.is_approved and owner.can_submit_listings %}
                                <a href="{% url 'rental_app:rental_listing_create' %}"
                                   class="btn btn-dark w-100 rental-status-add-btn">
                                    <i class="bi bi-house-add-fill me-2"></i>
                                    Add New Listing
                                </a>
                            {% else %}
                                <div class="alert rental-status-alert mb-0">
                                    Your account is awaiting approval or listing permission.
                                    Once enabled, you will be able to submit rental properties here.
                                </div>
                            {% endif %}
                        </div>

                    </div>
                </div>

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


    <!-- =====================================================
         QUICK DASHBOARD ACTIONS
    ====================================================== -->
    <section class="rental-dashboard-actions-section">
        <div class="container">

            <div class="row g-4">

                <div class="col-md-6 col-xl-3">
                    <div class="rental-action-card rental-profile-card h-100">

                        <img
                            src="{% if owner.profile_image %}{{ owner.profile_image.url }}{% else %}{% static default_profile_image %}{% endif %}"
                            alt="Profile Image"
                            class="dashboard-profile-icon"
                        >

                        <h5 class="fw-bold mt-3">
                            My Profile
                        </h5>

                        <p>
                            View your rental owner profile details, contact information,
                            and owner status.
                        </p>

                        <a href="{% url 'rental_app:rental_owner_profile_page' %}"
                           class="btn btn-outline-dark">
                            Open
                        </a>
                    </div>
                </div>


                <div class="col-md-6 col-xl-3">
                    <div class="rental-action-card green h-100">

                        <span class="rental-action-card-icon">
                            <i class="bi bi-house-add-fill"></i>
                        </span>

                        <h5 class="fw-bold mt-3">
                            Create New Listing
                        </h5>

                        <p>
                            Add a new rental property listing with photos, pricing,
                            location details, and availability information.
                        </p>

                        <a href="{% url 'rental_app:rental_listing_create' %}"
                           class="btn btn-outline-dark">
                            Create
                        </a>
                    </div>
                </div>


                <div class="col-md-6 col-xl-3">
                    <div class="rental-action-card gold h-100">

                        <span class="rental-action-card-icon">
                            <i class="bi bi-house-heart-fill"></i>
                        </span>

                        <h5 class="fw-bold mt-3">
                            Interest Requests
                        </h5>

                        <p>
                            View international guests who have expressed interest
                            in your property listings.
                        </p>

                        <a href="{% url 'rental_app:interested_foreigners_list' %}"
                           class="btn btn-outline-dark">
                            Open
                        </a>
                    </div>
                </div>


                <div class="col-md-6 col-xl-3">
                    <div class="rental-action-card dark h-100">

                        <span class="rental-action-card-icon">
                            <i class="bi bi-credit-card-2-front-fill"></i>
                        </span>

                        <h5 class="fw-bold mt-3">
                            Payment Center
                        </h5>

                        <p>
                            Pay featured owner fees, review payment records,
                            and boost visibility for better listing placement.
                        </p>

                        <a href="{% url 'rental_app:rental_owner_payment_center' %}"
                           class="btn btn-outline-dark">
                            Open
                        </a>
                    </div>
                </div>

            </div>

        </div>
    </section>

    <!-- =====================================================
     CONNECTED ENSOLANKA ACCESS
    ====================================================== -->
    <section class="rental-dashboard-actions-section pt-0">
        <div class="container">

            <div class="rental-access-panel">

                <div class="rental-access-header">
                    <span class="rental-access-kicker">
                        <i class="bi bi-link-45deg"></i>
                        Connected Ensolanka Access
                    </span>

                    <h2>
                        Expand Your Account
                    </h2>

                    <p>
                        Use your existing Rental Owner account to activate related Ensolanka services
                        without creating a separate login.
                    </p>
                </div>

                <div class="row g-4">

                    <!-- Property Care Access -->
                    <div class="col-lg-6">
                        <div class="rental-action-card green h-100">

                            <span class="rental-action-card-icon">
                                <i class="bi bi-house-gear-fill"></i>
                            </span>

                            <h5 class="fw-bold mt-3">
                                Property Care Access
                            </h5>

                            {% if has_property_manager_profile %}
                                <p>
                                    Your Property Care profile is already active.
                                    Open your Property Care dashboard to register properties,
                                    request maintenance support, and manage care plans.
                                </p>

                                <a href="{% url 'property_manager_app:property_manager_dashboard' %}"
                                class="btn btn-outline-dark">
                                    <i class="bi bi-arrow-right-circle-fill me-2"></i>
                                    Open Property Care Dashboard
                                </a>
                            {% else %}
                                <p>
                                    Activate Property Care access using your existing Rental Owner
                                    profile details and begin managing care and maintenance needs.
                                </p>

                                <form method="post"
                                    action="{% url 'rental_app:activate_property_manager_from_rental_owner' %}">
                                    {% csrf_token %}

                                    <button type="submit"
                                            class="btn btn-outline-dark">
                                        <i class="bi bi-person-plus-fill me-2"></i>
                                        Activate Property Care Access
                                    </button>
                                </form>
                            {% endif %}

                        </div>
                    </div>


                    <!-- Affiliate Access -->
                    <div class="col-lg-6">
                        <div class="rental-action-card gold h-100">

                            <span class="rental-action-card-icon">
                                <i class="bi bi-globe2"></i>
                            </span>

                            <h5 class="fw-bold mt-3">
                                Affiliate Access
                            </h5>

                            {% if has_affiliate_profile %}
                                <p>
                                    Your Affiliate profile is already active.
                                    Open your Affiliate Dashboard to access referral tools,
                                    ambassador resources, and earning opportunities.
                                </p>

                                <a href="{% url 'affiliates_app:affiliate_dashboard' %}"
                                class="btn btn-outline-dark">
                                    <i class="bi bi-arrow-right-circle-fill me-2"></i>
                                    Open Affiliate Dashboard
                                </a>
                            {% else %}
                                <p>
                                    Activate Ensolanka Global Ambassador access using your existing
                                    Rental Owner account details and start promoting Sri Lanka opportunities.
                                </p>

                                <form method="post"
                                    action="{% url 'rental_app:activate_affiliate_from_rental_owner' %}">
                                    {% csrf_token %}

                                    <button type="submit"
                                            class="btn btn-outline-dark">
                                        <i class="bi bi-person-plus-fill me-2"></i>
                                        Activate Affiliate Access
                                    </button>
                                </form>
                            {% endif %}

                        </div>
                    </div>

                </div>

            </div>

        </div>
    </section>
    <!-- =====================================================
         MY LISTINGS
    ====================================================== -->
    <section class="rental-listings-section">
        <div class="container">

            <div class="d-flex flex-column flex-lg-row justify-content-between align-items-lg-center rental-listings-heading">
                <div>
                    <h2>
                        My Listings
                    </h2>

                    <p class="mb-0">
                        View and manage your submitted rental properties.
                    </p>
                </div>

                {% if owner.is_approved and owner.can_submit_listings %}
                    <div class="mt-3 mt-lg-0">
                        <a href="{% url 'rental_app:rental_listing_create' %}"
                           class="btn btn-dark rental-listings-add-btn">
                            <i class="bi bi-plus-circle-fill me-2"></i>
                            Add New Listing
                        </a>
                    </div>
                {% endif %}
            </div>


            <div class="row g-4">
                {% for listing in listings %}
                    <div class="col-md-6 col-xl-4">
                        <div class="rental-listing-card">

                            {% if listing.images.first %}
                                <img src="{{ listing.images.first.image.url }}"
                                     class="rental-listing-image"
                                     alt="{{ listing.title }}">
                            {% else %}
                                <div class="rental-listing-placeholder">
                                    <i class="bi bi-house-heart-fill"></i>
                                </div>
                            {% endif %}

                            <div class="rental-listing-body">

                                <div class="rental-listing-badges">
                                    {% if listing.is_approved %}
                                        <span class="badge bg-success">Approved</span>
                                    {% else %}
                                        <span class="badge bg-warning text-dark">Pending</span>
                                    {% endif %}

                                    {% if listing.is_active %}
                                        <span class="badge bg-primary">Active</span>
                                    {% else %}
                                        <span class="badge bg-secondary">Inactive</span>
                                    {% endif %}

                                    {% if listing.visibility == 'private' %}
                                        <span class="badge bg-dark">Private</span>
                                    {% else %}
                                        <span class="badge bg-info text-dark">Public</span>
                                    {% endif %}

                                    {% if listing.is_featured %}
                                        <span class="badge bg-danger">Featured</span>
                                    {% endif %}
                                </div>

                                <h5 class="rental-listing-title">
                                    {{ listing.title }}
                                </h5>

                                <p class="rental-listing-meta">
                                    <i class="bi bi-geo-alt-fill me-1"></i>
                                    {{ listing.city }}{% if listing.area %}, {{ listing.area }}{% endif %}
                                </p>

                                <p class="rental-listing-detail">
                                    <strong>Rent:</strong>
                                    ${{ listing.monthly_rent_usd }}/month
                                </p>

                                <p class="rental-listing-detail">
                                    <strong>Type:</strong>
                                    {{ listing.get_property_type_display }}
                                </p>

                                <p class="rental-listing-description">
                                    {{ listing.short_description|truncatechars:110 }}
                                </p>

                                <div class="rental-listing-created">
                                    Created: {{ listing.created_at|date:"M d, Y" }}
                                </div>

                                <div class="rental-listing-actions">
                                    <a href="{% url 'rental_app:rental_owner_listing_detail' listing.slug %}"
                                       class="btn btn-outline-dark">
                                        View Listing
                                    </a>

                                    <a href="{% url 'rental_app:rental_listing_edit' listing.slug %}"
                                       class="btn btn-dark">
                                        Edit Listing
                                    </a>
                                </div>

                            </div>
                        </div>
                    </div>
                {% empty %}
                    <div class="col-12">
                        <div class="rental-empty-state">

                            <div class="rental-empty-icon">
                                <i class="bi bi-house-add-fill"></i>
                            </div>

                            <h5>
                                No listings submitted yet
                            </h5>

                            <p class="mb-3">
                                Once your account is approved for submissions, you can start adding
                                rental properties here and present them to international guests.
                            </p>

                            {% if owner.is_approved and owner.can_submit_listings %}
                                <a href="{% url 'rental_app:rental_listing_create' %}"
                                   class="btn btn-dark">
                                    <i class="bi bi-plus-circle-fill me-2"></i>
                                    Add Your First Listing
                                </a>
                            {% endif %}

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

        </div>
    </section>

</section>

{% endblock %}