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

{% block title %}Change Username{% endblock %}

{% block content %}

<style>
    /* =========================================================
       CHANGE USERNAME 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);
    }

    .username-page-section {
        position: relative;
        overflow: hidden;
        min-height: 80vh;
        display: flex;
        align-items: center;
        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;
    }

    .username-page-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;
    }

    .username-page-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;
    }

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

    .username-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;
    }

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

    .username-card-body {
        position: relative;
        z-index: 3;
        padding: 2.8rem;
    }

    .username-header {
        text-align: center;
        margin-bottom: 2.1rem;
    }

    .username-icon-wrap {
        width: 86px;
        height: 86px;
        margin: 0 auto 1.3rem;
        border-radius: 28px;
        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);
    }

    .username-header h2 {
        color: var(--lis-text);
        font-weight: 950;
        letter-spacing: -0.035em;
        line-height: 1.12;
        margin-bottom: 0.75rem;
    }

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

    .username-form p {
        margin-bottom: 1.25rem;
    }

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

    .username-form input,
    .username-form select,
    .username-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);
    }

    .username-form input:focus,
    .username-form select:focus,
    .username-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;
    }

    .username-form input::placeholder {
        color: #94a3b8;
    }

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

    .username-form ul {
        margin-top: 0.55rem;
        padding-left: 1.1rem;
        color: var(--lis-muted);
        font-size: 0.88rem;
        line-height: 1.6;
    }

    .username-form .errorlist {
        list-style: none;
        padding-left: 0;
        margin: 0.45rem 0 0;
        color: #b42318;
        font-size: 0.88rem;
        font-weight: 700;
    }

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

    .username-note {
        margin-top: 1.4rem;
        margin-bottom: 1.6rem;
        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);
    }

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

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

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

    .btn-username-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-username-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-username-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-username-cancel:hover {
        background: var(--lis-deep);
        border-color: var(--lis-deep);
        color: #ffffff;
        transform: translateY(-2px);
    }

    @media (max-width: 576px) {
        .username-page-section {
            padding: 60px 0;
            min-height: auto;
        }

        .username-card {
            border-radius: 28px;
        }

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

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

        .username-header h2 {
            font-size: 1.75rem;
        }

        .username-actions {
            flex-direction: column;
        }

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

<section class="username-page-section">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-6 col-xl-5">
                <div class="username-card">
                    <div class="username-card-body">

                        <div class="username-header">
                            <div class="username-icon-wrap">
                                <i class="bi bi-person-badge"></i>
                            </div>

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

                            <h2>Change Username</h2>

                            <p>
                                Update the username connected to your Live in Sri Lanka guest profile.
                            </p>
                        </div>

                        <form method="post" class="username-form">
                            {% csrf_token %}
                            {{ form.as_p }}

                            <div class="username-note">
                                <i class="bi bi-info-circle me-2"></i>
                                Choose a clear username that helps you identify your account easily when using your guest dashboard and profile area.
                            </div>

                            <div class="username-actions">
                                <button type="submit" class="btn btn-username-save">
                                    <i class="bi bi-check-circle me-2"></i>
                                    Update Username
                                </button>

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

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

{% endblock %}