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

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

{% block content %}

<style>
    /* =========================================================
       HOSTING CLIENT CHANGE USERNAME — PREMIUM
    ========================================================= */

    .hosting-username-page {
        min-height: 100vh;
        padding: 4rem 0 5rem;
        background:
            radial-gradient(circle at top left, rgba(255, 193, 7, 0.11), transparent 28%),
            radial-gradient(circle at top right, rgba(138, 57, 45, 0.10), transparent 32%),
            linear-gradient(180deg, #fffaf5 0%, #fff4e8 44%, #ffffff 100%);
    }

    .hosting-username-hero {
        position: relative;
        overflow: hidden;
        border-radius: 38px;
        padding: 2.5rem 2.35rem;
        margin-bottom: 2rem;
        color: #ffffff;
        background:
            radial-gradient(circle at top right, rgba(255, 211, 107, 0.20), transparent 32%),
            linear-gradient(135deg, #2d1716 0%, #743129 56%, #a7601b 100%);
        box-shadow: 0 30px 68px rgba(58, 30, 24, 0.20);
    }

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

    .hosting-username-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-username-hero h1 {
        font-size: clamp(2.1rem, 4vw, 3.35rem);
        font-weight: 950;
        line-height: 1.12;
        letter-spacing: -0.045em;
        margin-bottom: 0.8rem;
    }

    .hosting-username-hero p {
        max-width: 840px;
        margin-bottom: 0;
        color: rgba(255, 255, 255, 0.88);
        font-size: 1.03rem;
        line-height: 1.8;
    }

    .hosting-username-layout {
        align-items: stretch;
    }

    .hosting-username-card,
    .hosting-username-side-card {
        height: 100%;
        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-username-card-header,
    .hosting-username-side-header {
        padding: 1.6rem 1.7rem 1.15rem;
        border-bottom: 1px solid #efe2d3;
        background:
            radial-gradient(circle at top right, rgba(183, 106, 31, 0.06), transparent 28%),
            linear-gradient(180deg, #ffffff 0%, #fffaf5 100%);
    }

    .hosting-username-card-header h2,
    .hosting-username-side-header h3 {
        color: #2f1d18;
        font-weight: 950;
        margin-bottom: 0.4rem;
    }

    .hosting-username-card-header p,
    .hosting-username-side-header p {
        color: #7a655d;
        line-height: 1.7;
        margin-bottom: 0;
    }

    .hosting-username-card-body,
    .hosting-username-side-body {
        padding: 1.7rem;
    }

    .hosting-username-field .form-label {
        display: block;
        color: #2f1d18;
        font-weight: 850;
        margin-bottom: 0.55rem;
    }

    .hosting-username-field input {
        width: 100%;
        border-radius: 16px;
        border: 1px solid #eadbc9;
        padding: 0.9rem 1rem;
        background: #fffaf5;
        color: #2f1d18;
        transition: all 0.22s ease;
    }

    .hosting-username-field input:focus {
        outline: none;
        background: #ffffff;
        border-color: #a7601b;
        box-shadow: 0 0 0 0.22rem rgba(167, 96, 27, 0.14);
    }

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

    .hosting-current-box {
        border-radius: 22px;
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.10), transparent 28%),
            #fffaf5;
        border: 1px solid #efe2d3;
        padding: 1rem 1.1rem;
        margin-bottom: 1.3rem;
    }

    .hosting-current-label {
        color: #7a655d;
        font-size: 0.8rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.045em;
        margin-bottom: 0.35rem;
    }

    .hosting-current-value {
        color: #2f1d18;
        font-size: 1.2rem;
        font-weight: 950;
        word-break: break-word;
    }

    .hosting-username-note {
        margin-top: 1.5rem;
        border-radius: 22px;
        padding: 1rem 1.1rem;
        background: #fff4e4;
        border: 1px solid #efd7ae;
        color: #8a5418;
        line-height: 1.72;
    }

    .hosting-username-actions {
        margin-top: 1.7rem;
        display: flex;
        flex-wrap: wrap;
        gap: 0.85rem;
    }

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

    .hosting-username-save-btn {
        color: #fff;
        border: none;
        background: linear-gradient(135deg, #321816, #a7601b);
    }

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

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

    .hosting-tip-list {
        display: grid;
        gap: 0.95rem;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .hosting-tip-item {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        color: #6b564d;
        line-height: 1.68;
    }

    .hosting-tip-item i {
        color: #a7601b;
        font-size: 1.05rem;
        margin-top: 0.2rem;
        flex-shrink: 0;
    }

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

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

        .hosting-username-card-header,
        .hosting-username-side-header,
        .hosting-username-card-body,
        .hosting-username-side-body {
            padding-left: 1.35rem;
            padding-right: 1.35rem;
        }
    }

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

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


<section class="hosting-username-page">
    <div class="container">

        <!-- =====================================================
             HERO
        ====================================================== -->
        <div class="hosting-username-hero">
            <div class="hosting-username-hero-inner">
                <span class="hosting-username-kicker">
                    <i class="bi bi-person-gear"></i>
                    Hosting Client Account
                </span>

                <h1>Change Username</h1>

                <p>
                    Update the username used to sign in to your Host in Sri Lanka client account.
                    Choose a clear and memorable username that you can use securely going forward.
                </p>
            </div>
        </div>


        <div class="row g-4 justify-content-center hosting-username-layout">

            <!-- MAIN FORM -->
            <div class="col-lg-7">
                <div class="hosting-username-card">

                    <div class="hosting-username-card-header">
                        <h2>Update Login Username</h2>
                        <p>
                            Your username is part of your Hosting Client account identity.
                            Changes take effect immediately after saving.
                        </p>
                    </div>

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

                        <div class="hosting-current-box">
                            <div class="hosting-current-label">
                                Current Username
                            </div>

                            <div class="hosting-current-value">
                                {{ request.user.username }}
                            </div>
                        </div>

                        <form method="post">
                            {% csrf_token %}

                            {% for field in form %}
                                <div class="hosting-username-field mb-3">
                                    <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="hosting-username-error">
                                            {{ error }}
                                        </div>
                                    {% endfor %}
                                </div>
                            {% endfor %}

                            <div class="hosting-username-note">
                                After updating your username, continue using the same password unless you separately change it from the password settings page.
                            </div>

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

                                <a href="{% url 'hosting_app:hosting_client_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 hosting-username-non-field-error mb-0">
                                    {% for error in form.non_field_errors %}
                                        <div>{{ error }}</div>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </form>
                    </div>

                </div>
            </div>


            <!-- SIDE INFO -->
            <div class="col-lg-5">
                <div class="hosting-username-side-card">

                    <div class="hosting-username-side-header">
                        <h3>Username Tips</h3>
                        <p>
                            A few reminders before you update your Hosting Client sign-in identity.
                        </p>
                    </div>

                    <div class="hosting-username-side-body">
                        <ul class="hosting-tip-list">
                            <li class="hosting-tip-item">
                                <i class="bi bi-check-circle-fill"></i>
                                <span>Choose a username you can easily remember for future sign-ins.</span>
                            </li>

                            <li class="hosting-tip-item">
                                <i class="bi bi-check-circle-fill"></i>
                                <span>Your username must be unique and cannot already belong to another account.</span>
                            </li>

                            <li class="hosting-tip-item">
                                <i class="bi bi-check-circle-fill"></i>
                                <span>This change does not alter your full name, profile details, email address, client type, or hosting account status.</span>
                            </li>

                            <li class="hosting-tip-item">
                                <i class="bi bi-check-circle-fill"></i>
                                <span>Use the separate password page if you also want to update your account security.</span>
                            </li>
                        </ul>
                    </div>

                </div>
            </div>

        </div>

    </div>
</section>

{% endblock %}