{% extends 'property_manager_app/base_property_manager.html' %}

{% block title %}Edit Property Care Profile{% endblock %}

{% block content %}

<style>
    /* =========================================================
       PROPERTY CARE EDIT PROFILE — PREMIUM
    ========================================================= */

    .pm-edit-profile-page {
        min-height: 100vh;
        padding: 4rem 0 5rem;
        background:
            radial-gradient(circle at top left, rgba(251, 191, 36, 0.10), transparent 28%),
            radial-gradient(circle at top right, rgba(15, 118, 110, 0.11), transparent 32%),
            linear-gradient(180deg, #f8fafc 0%, #ecfdf5 44%, #ffffff 100%);
    }

    .pm-edit-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(251, 191, 36, 0.18), transparent 32%),
            linear-gradient(135deg, #052e25 0%, #0f766e 58%, #115e59 100%);
        box-shadow: 0 30px 68px rgba(15, 23, 42, 0.20);
    }

    .pm-edit-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;
    }

    .pm-edit-hero::after {
        content: "";
        position: absolute;
        bottom: -150px;
        left: -110px;
        width: 360px;
        height: 360px;
        border-radius: 50%;
        background: rgba(251, 191, 36, 0.08);
        pointer-events: none;
    }

    .pm-edit-hero-inner {
        position: relative;
        z-index: 2;
    }

    .pm-edit-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: #fef3c7;
        font-size: 0.84rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 1rem;
    }

    .pm-edit-hero h1 {
        font-size: clamp(2.15rem, 4vw, 3.45rem);
        font-weight: 950;
        line-height: 1.12;
        letter-spacing: -0.045em;
        margin-bottom: 0.8rem;
    }

    .pm-edit-hero p {
        max-width: 850px;
        margin-bottom: 0;
        color: rgba(255, 255, 255, 0.88);
        font-size: 1.04rem;
        line-height: 1.8;
    }

    .pm-edit-shell {
        border-radius: 36px;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid rgba(226, 232, 240, 0.95);
        box-shadow: 0 24px 56px rgba(15, 23, 42, 0.10);
        overflow: hidden;
    }

    .pm-edit-card-header {
        padding: 1.7rem 1.8rem 1.25rem;
        border-bottom: 1px solid #e2e8f0;
        background:
            radial-gradient(circle at top right, rgba(15, 118, 110, 0.06), transparent 28%),
            linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    }

    .pm-edit-card-header h2 {
        color: #0f172a;
        font-weight: 950;
        margin-bottom: 0.4rem;
    }

    .pm-edit-card-header p {
        color: #64748b;
        line-height: 1.7;
        margin-bottom: 0;
    }

    .pm-edit-card-body {
        padding: 1.8rem;
    }

    .pm-edit-form-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .pm-edit-field.full-width {
        grid-column: 1 / -1;
    }

    .pm-edit-field .form-label {
        display: block;
        color: #0f172a;
        font-weight: 850;
        margin-bottom: 0.55rem;
    }

    .pm-edit-field input,
    .pm-edit-field select,
    .pm-edit-field textarea {
        width: 100%;
        border-radius: 16px;
        border: 1px solid #dbe4ee;
        padding: 0.84rem 1rem;
        background: #f8fafc;
        color: #0f172a;
        transition: all 0.22s ease;
    }

    .pm-edit-field textarea {
        min-height: 125px;
        resize: vertical;
    }

    .pm-edit-field input:focus,
    .pm-edit-field select:focus,
    .pm-edit-field textarea:focus {
        outline: none;
        background: #ffffff;
        border-color: #0f766e;
        box-shadow: 0 0 0 0.22rem rgba(15, 118, 110, 0.14);
    }

    .pm-edit-error {
        color: #dc2626;
        font-size: 0.88rem;
        margin-top: 0.35rem;
        font-weight: 700;
    }

    .pm-edit-actions {
        margin-top: 1.8rem;
        display: flex;
        flex-wrap: wrap;
        gap: 0.85rem;
    }

    .pm-edit-actions .btn {
        border-radius: 999px;
        font-weight: 850;
        min-height: 52px;
        padding-left: 1.35rem;
        padding-right: 1.35rem;
    }

    .pm-edit-save-btn {
        color: #fff;
        border: none;
        background: linear-gradient(135deg, #0f172a, #0f766e);
    }

    .pm-edit-save-btn:hover {
        color: #fff;
        transform: translateY(-1px);
    }

    .pm-edit-note {
        margin-top: 1.6rem;
        border-radius: 22px;
        padding: 1rem 1.1rem;
        background: #ecfeff;
        border: 1px solid #a5f3fc;
        color: #0f766e;
        line-height: 1.7;
    }

    .pm-edit-non-field-error {
        margin-top: 1.4rem;
        border-radius: 20px;
    }

    @media (max-width: 991.98px) {
        .pm-edit-profile-page {
            padding-top: 2.8rem;
        }

        .pm-edit-hero {
            padding: 2rem 1.45rem;
            border-radius: 30px;
        }

        .pm-edit-card-header,
        .pm-edit-card-body {
            padding-left: 1.35rem;
            padding-right: 1.35rem;
        }

        .pm-edit-form-grid {
            grid-template-columns: 1fr;
        }
    }

    @media (max-width: 767.98px) {
        .pm-edit-actions {
            flex-direction: column;
            align-items: stretch;
        }

        .pm-edit-actions .btn {
            width: 100%;
        }
    }
</style>


<section class="pm-edit-profile-page">
    <div class="container">

        <!-- =====================================================
             HERO
        ====================================================== -->
        <div class="pm-edit-hero">
            <div class="pm-edit-hero-inner">
                <span class="pm-edit-kicker">
                    <i class="bi bi-pencil-square"></i>
                    Property Care Profile
                </span>

                <h1>Edit Property Care Profile</h1>

                <p>
                    Update your owner details, current location, emergency contact,
                    communication information, and care expectations for your Home in Sri Lanka account.
                </p>
            </div>
        </div>


        <!-- =====================================================
             FORM CARD
        ====================================================== -->
        <div class="row justify-content-center">
            <div class="col-xl-10">
                <div class="pm-edit-shell">

                    <div class="pm-edit-card-header">
                        <h2>Owner & Contact Information</h2>
                        <p>
                            Keep these details accurate so Ensolanka can coordinate property care, reviews, and communication effectively.
                        </p>
                    </div>

                    <div class="pm-edit-card-body">
                        <form method="post">
                            {% csrf_token %}

                            <div class="pm-edit-form-grid">
                                {% for field in form %}
                                    <div class="pm-edit-field 
                                        {% if field.name == 'short_note' %}full-width{% endif %}">
                                        
                                        <label class="form-label" for="{{ field.id_for_label }}">
                                            {{ field.label }}
                                        </label>

                                        {{ field }}

                                        {% if field.help_text %}
                                            <div class="form-text">
                                                {{ field.help_text }}
                                            </div>
                                        {% endif %}

                                        {% for error in field.errors %}
                                            <div class="pm-edit-error">
                                                {{ error }}
                                            </div>
                                        {% endfor %}
                                    </div>
                                {% endfor %}
                            </div>

                            <div class="pm-edit-note">
                                Updating your full name and email will keep your linked Property Care account information aligned where relevant.
                            </div>

                            <div class="pm-edit-actions">
                                <button type="submit"
                                        class="btn pm-edit-save-btn">
                                    <i class="bi bi-save-fill me-2"></i>
                                    Save Changes
                                </button>

                                <a href="{% url 'property_manager_app:property_manager_profile_page' %}"
                                   class="btn btn-outline-secondary">
                                    <i class="bi bi-arrow-left-circle me-2"></i>
                                    Cancel
                                </a>
                            </div>

                            {% if form.non_field_errors %}
                                <div class="alert alert-danger pm-edit-non-field-error mb-0">
                                    {% for error in form.non_field_errors %}
                                        <div>{{ error }}</div>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </form>
                    </div>

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

    </div>
</section>

{% endblock %}