{% extends 'expat_life/base.html' %}

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

{% block content %}

<style>
    /* =========================================================
       EDIT PROFILE PAGE - PREMIUM LIVE IN SRI LANKA THEME
    ========================================================= */

    :root {
        --lis-deep: #07131c;
        --lis-navy: #0b2638;
        --lis-blue: #0d6efd;
        --lis-blue-dark: #0b3d91;
        --lis-teal: #0f766e;
        --lis-gold: #ffc107;
        --lis-gold-light: #ffd45f;
        --lis-soft-blue: #f5f9ff;
        --lis-white: #ffffff;
        --lis-text: #102033;
        --lis-muted: #64748b;
        --lis-border: rgba(15, 42, 64, 0.10);
        --lis-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
        --lis-shadow-strong: 0 28px 70px rgba(15, 23, 42, 0.16);
    }

    .profile-edit-section {
        position: relative;
        overflow: hidden;
        min-height: 82vh;
        background:
            radial-gradient(circle at 10% 12%, rgba(255, 193, 7, 0.13), transparent 28%),
            radial-gradient(circle at 88% 14%, rgba(13, 110, 253, 0.10), transparent 30%),
            radial-gradient(circle at 82% 86%, rgba(15, 118, 110, 0.12), transparent 32%),
            linear-gradient(180deg, #f5f9ff 0%, #ffffff 100%);
        padding: 90px 0;
    }

    .profile-edit-section::before {
        content: "";
        position: absolute;
        width: 420px;
        height: 420px;
        right: -190px;
        top: -190px;
        border-radius: 50%;
        background: rgba(255, 193, 7, 0.12);
        pointer-events: none;
    }

    .profile-edit-section::after {
        content: "";
        position: absolute;
        width: 360px;
        height: 360px;
        left: -170px;
        bottom: -180px;
        border-radius: 50%;
        background: rgba(13, 110, 253, 0.08);
        pointer-events: none;
    }

    .profile-edit-card {
        position: relative;
        overflow: hidden;
        border: 1px solid rgba(15, 42, 64, 0.08);
        border-radius: 34px;
        background:
            radial-gradient(circle at 92% 8%, rgba(255, 193, 7, 0.14), transparent 32%),
            linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
        box-shadow: var(--lis-shadow-strong);
    }

    .profile-edit-card::before {
        content: "";
        position: absolute;
        inset: 0 0 auto 0;
        height: 6px;
        background: linear-gradient(90deg, var(--lis-gold), var(--lis-teal), var(--lis-blue));
        z-index: 2;
    }

    .profile-edit-card::after {
        content: "";
        position: absolute;
        width: 240px;
        height: 240px;
        right: -120px;
        bottom: -120px;
        border-radius: 50%;
        background: rgba(15, 118, 110, 0.08);
        pointer-events: none;
    }

    .profile-edit-card-body {
        position: relative;
        z-index: 3;
        padding: 3rem;
    }

    .profile-edit-header {
        text-align: center;
        max-width: 680px;
        margin: 0 auto 2.4rem;
    }

    .profile-edit-icon-wrap {
        width: 88px;
        height: 88px;
        margin: 0 auto 1.3rem;
        border-radius: 30px;
        background:
            radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.75), transparent 28%),
            linear-gradient(135deg, var(--lis-gold-light), var(--lis-gold));
        color: var(--lis-deep);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 2.35rem;
        box-shadow:
            0 18px 38px rgba(255, 193, 7, 0.28),
            0 0 0 10px rgba(255, 193, 7, 0.10);
    }

    .section-mini-title {
        display: inline-flex;
        align-items: center;
        gap: 0.45rem;
        padding: 7px 15px;
        border-radius: 999px;
        background: rgba(15, 118, 110, 0.09);
        border: 1px solid rgba(15, 118, 110, 0.14);
        color: var(--lis-teal);
        font-size: 0.78rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.075em;
        margin-bottom: 14px;
    }

    .section-mini-title::before {
        content: "";
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--lis-gold);
        box-shadow: 0 0 0 5px rgba(255, 193, 7, 0.14);
    }

    .profile-edit-header h2 {
        color: var(--lis-text);
        font-weight: 950;
        letter-spacing: -0.035em;
        line-height: 1.12;
        margin-bottom: 0.75rem;
        font-size: clamp(2rem, 3.4vw, 2.75rem);
    }

    .profile-edit-header p {
        color: var(--lis-muted);
        margin-bottom: 0;
        font-size: 1rem;
        line-height: 1.75;
    }

    .profile-edit-form .form-label {
        color: var(--lis-text);
        font-weight: 850;
        margin-bottom: 0.5rem;
        letter-spacing: -0.01em;
    }

    .profile-edit-form input,
    .profile-edit-form select,
    .profile-edit-form textarea {
        width: 100%;
        border: 1px solid rgba(15, 42, 64, 0.12);
        border-radius: 17px;
        padding: 0.92rem 1rem;
        font-size: 0.96rem;
        color: var(--lis-text);
        background:
            linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
        transition: all 0.22s ease;
        box-shadow: 0 10px 22px rgba(15, 23, 42, 0.035);
    }

    .profile-edit-form textarea {
        min-height: 130px;
        resize: vertical;
    }

    .profile-edit-form input:focus,
    .profile-edit-form select:focus,
    .profile-edit-form textarea:focus {
        outline: none;
        border-color: rgba(15, 118, 110, 0.52);
        box-shadow:
            0 0 0 0.22rem rgba(15, 118, 110, 0.11),
            0 12px 24px rgba(13, 110, 253, 0.07);
        background: #ffffff;
    }

    .profile-edit-form input::placeholder,
    .profile-edit-form textarea::placeholder {
        color: #94a3b8;
    }

    .profile-edit-form .helptext {
        display: block;
        margin-top: 0.45rem;
        color: var(--lis-muted);
        font-size: 0.86rem;
        line-height: 1.55;
    }

    .profile-edit-form .text-danger,
    .profile-edit-form .errorlist {
        color: #b42318 !important;
        font-size: 0.88rem;
        font-weight: 700;
    }

    .profile-edit-form .errorlist {
        list-style: none;
        padding-left: 0;
        margin: 0.45rem 0 0;
    }

    .profile-edit-form .errorlist li,
    .profile-edit-form .text-danger {
        padding: 0.65rem 0.85rem;
        border-radius: 14px;
        background: rgba(180, 35, 24, 0.08);
        border: 1px solid rgba(180, 35, 24, 0.14);
    }

    .profile-edit-note {
        margin-top: 1.7rem;
        margin-bottom: 1.7rem;
        padding: 1rem 1.1rem;
        border-radius: 18px;
        background:
            linear-gradient(135deg, rgba(255, 193, 7, 0.11), rgba(15, 118, 110, 0.06));
        color: #475569;
        font-size: 0.92rem;
        line-height: 1.65;
        border: 1px solid rgba(255, 193, 7, 0.18);
    }

    .profile-edit-note i {
        color: var(--lis-teal);
    }

    .profile-edit-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.85rem;
    }

    .profile-edit-actions .btn {
        border-radius: 999px;
        padding: 0.85rem 1.55rem;
        font-weight: 850;
        letter-spacing: 0.01em;
        transition: all 0.22s ease;
    }

    .btn-profile-save {
        background: linear-gradient(135deg, var(--lis-deep), var(--lis-blue));
        color: #ffffff;
        border: none;
        box-shadow: 0 16px 32px rgba(13, 110, 253, 0.20);
    }

    .btn-profile-save:hover {
        background: linear-gradient(135deg, var(--lis-deep), var(--lis-teal));
        color: #ffffff;
        transform: translateY(-2px);
        box-shadow: 0 20px 38px rgba(15, 118, 110, 0.24);
    }

    .btn-profile-cancel {
        color: var(--lis-deep);
        border: 1px solid rgba(7, 19, 28, 0.20);
        background: #ffffff;
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
    }

    .btn-profile-cancel:hover {
        background: var(--lis-deep);
        border-color: var(--lis-deep);
        color: #ffffff;
        transform: translateY(-2px);
    }

    @media (max-width: 767.98px) {
        .profile-edit-section {
            padding: 60px 0;
            min-height: auto;
        }

        .profile-edit-card {
            border-radius: 28px;
        }

        .profile-edit-card-body {
            padding: 2rem 1.35rem;
        }

        .profile-edit-icon-wrap {
            width: 76px;
            height: 76px;
            border-radius: 24px;
            font-size: 2rem;
        }

        .profile-edit-actions {
            flex-direction: column;
        }

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

<section class="profile-edit-section">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-8 col-xl-7">
                <div class="profile-edit-card">
                    <div class="profile-edit-card-body">

                        <div class="profile-edit-header">
                            <div class="profile-edit-icon-wrap">
                                <i class="bi bi-person-lines-fill"></i>
                            </div>

                            <span class="section-mini-title">Guest Profile</span>

                            <h2>Edit Profile</h2>

                            <p>
                                Keep your Live in Sri Lanka profile accurate so we can guide you with better lifestyle,
                                housing, service, and local support options.
                            </p>
                        </div>

                        <form method="post" class="profile-edit-form">
                            {% csrf_token %}

                            <div class="row g-3">
                                {% for field in form %}
                                    <div class="col-md-6 {% if field.name == 'message' %}col-12{% endif %}">
                                        <label class="form-label" for="{{ field.id_for_label }}">
                                            {{ field.label }}
                                        </label>

                                        {{ field }}

                                        {% if field.help_text %}
                                            <span class="helptext">{{ field.help_text }}</span>
                                        {% endif %}

                                        {% if field.errors %}
                                            <div class="text-danger small mt-2">
                                                {{ field.errors }}
                                            </div>
                                        {% endif %}
                                    </div>
                                {% endfor %}
                            </div>

                            <div class="profile-edit-note">
                                <i class="bi bi-shield-check me-2"></i>
                                Your profile details help us understand your needs and provide more relevant private opportunities,
                                local support, and guidance.
                            </div>

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

                                <a href="{% url 'expat_life:foreigner_profile_page' %}" class="btn btn-profile-cancel">
                                    <i class="bi bi-x-circle me-2"></i>
                                    Cancel
                                </a>
                            </div>
                        </form>

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

{% endblock %}