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

{% block title %}Choose New Password | Live in Sri Lanka{% endblock %}

{% block content %}

<style>
    .guest-confirm-hero {
        position: relative;
        min-height: 100vh;
        padding: 6rem 0;
        background:
            radial-gradient(circle at top left, rgba(255, 193, 7, 0.14), transparent 34%),
            radial-gradient(circle at bottom right, rgba(32, 201, 151, 0.16), transparent 32%),
            linear-gradient(135deg, #07131c 0%, #0b3d91 52%, #0f766e 100%);
        color: #fff;
        overflow: hidden;
    }

    .guest-confirm-hero::before {
        content: "";
        position: absolute;
        inset: 0;
        background:
            linear-gradient(120deg, rgba(255, 255, 255, 0.07), transparent 35%),
            radial-gradient(circle at 80% 10%, rgba(255, 193, 7, 0.10), transparent 28%);
        pointer-events: none;
    }

    .guest-confirm-hero::after {
        content: "";
        position: absolute;
        right: -160px;
        bottom: -180px;
        width: 480px;
        height: 480px;
        border-radius: 50%;
        background: rgba(255, 193, 7, 0.08);
        pointer-events: none;
    }

    .guest-confirm-hero .container {
        position: relative;
        z-index: 2;
    }

    .guest-confirm-hero .section-mini-title {
        display: inline-flex;
        align-items: center;
        gap: 0.45rem;
        background: rgba(255, 193, 7, 0.16);
        color: #ffd36b;
        border: 1px solid rgba(255, 193, 7, 0.32);
        font-weight: 900;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.075em;
        padding: 7px 15px;
        border-radius: 999px;
        margin-bottom: 16px;
        backdrop-filter: blur(10px);
    }

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

    .guest-confirm-hero h1 {
        color: #fff;
        font-size: clamp(2.35rem, 4.2vw, 4.1rem);
        font-weight: 900;
        letter-spacing: -0.045em;
        line-height: 1.06;
    }

    .guest-confirm-hero .lead {
        color: rgba(255, 255, 255, 0.86) !important;
        font-size: 1.12rem;
        line-height: 1.8;
    }

    .guest-password-rules {
        margin-top: 24px;
        display: grid;
        gap: 12px;
    }

    .guest-password-rule {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        color: rgba(255, 255, 255, 0.92);
        font-weight: 600;
        line-height: 1.55;
    }

    .guest-password-rule i {
        color: #ffd36b;
        font-size: 1.15rem;
        margin-top: 2px;
    }

    .guest-confirm-card {
        background: rgba(255, 255, 255, 0.98);
        border-radius: 32px;
        box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24);
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, 0.35);
    }

    .guest-confirm-card-header {
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.12), transparent 34%),
            linear-gradient(135deg, #ffffff 0%, #f5f9ff 100%);
        padding: 28px 32px;
        color: #102033;
        text-align: center;
        border-bottom: 1px solid rgba(13, 110, 253, 0.10);
    }

    .guest-confirm-card-header h3 {
        margin: 0;
        font-weight: 900;
        color: #102033;
        letter-spacing: -0.025em;
    }

    .guest-confirm-card-header p {
        color: #64748b !important;
        font-size: 0.92rem;
        margin-top: 8px;
        margin-bottom: 0;
    }

    .guest-confirm-card-body {
        padding: 32px;
    }

    .guest-confirm-card-body .form-label {
        color: #102033;
        font-weight: 700;
    }

    .guest-confirm-card-body .form-control {
        border-radius: 15px;
        border: 1px solid #cbd5e1;
        padding: 0.78rem 0.95rem;
        box-shadow: none;
        color: #102033;
    }

    .guest-confirm-card-body .form-control:focus {
        border-color: #0d6efd;
        box-shadow: 0 0 0 0.22rem rgba(13, 110, 253, 0.12);
    }

    .guest-confirm-submit-btn {
        background: linear-gradient(135deg, #07131c, #0d6efd);
        border: none;
        border-radius: 48px;
        padding: 0.85rem 1rem;
        font-weight: 800;
        color: #ffffff;
        box-shadow: 0 16px 32px rgba(13, 110, 253, 0.22);
    }

    .guest-confirm-submit-btn:hover {
        background: linear-gradient(135deg, #07131c, #0f766e);
        color: #ffffff;
    }

    .guest-invalid-reset-box {
        padding: 2rem 1.4rem;
        text-align: center;
    }

    .guest-invalid-reset-icon {
        width: 88px;
        height: 88px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 30px;
        background:
            radial-gradient(circle at top right, rgba(255, 193, 7, 0.18), transparent 36%),
            linear-gradient(135deg, #ecfdf5, #e9f2ff);
        color: #0f766e;
        font-size: 2.35rem;
        margin-bottom: 1rem;
    }

    .guest-invalid-reset-box h3 {
        color: #102033;
        font-weight: 900;
        margin-bottom: 0.7rem;
    }

    .guest-invalid-reset-box p {
        color: #64748b;
        line-height: 1.7;
        margin-bottom: 1.3rem;
    }

    .guest-invalid-reset-box a {
        border-radius: 48px;
        padding: 0.85rem 1.35rem;
        font-weight: 800;
        text-decoration: none;
        color: #fff;
        background: linear-gradient(135deg, #07131c, #0d6efd);
        display: inline-block;
        box-shadow: 0 14px 28px rgba(13, 110, 253, 0.18);
    }

    .guest-invalid-reset-box a:hover {
        background: linear-gradient(135deg, #07131c, #0f766e);
        color: #ffffff;
    }

    .guest-field-error {
        color: #b91c1c;
        font-size: 0.88rem;
        font-weight: 600;
        margin-top: 6px;
    }

    .guest-form-error {
        background: #fef2f2;
        border: 1px solid #fecaca;
        color: #991b1b;
        border-radius: 18px;
        padding: 14px 16px;
        margin-bottom: 18px;
        font-weight: 600;
    }

    .guest-password-help {
        margin-top: 16px;
        padding: 14px 16px;
        border-radius: 18px;
        background: #f8fbff;
        border: 1px solid rgba(13, 110, 253, 0.12);
        color: #475569;
        font-size: 0.9rem;
        line-height: 1.65;
    }

    @media (max-width: 768px) {
        .guest-confirm-hero {
            padding: 4rem 0;
        }

        .guest-confirm-card-body {
            padding: 24px;
        }

        .guest-confirm-card-header {
            padding: 22px 20px;
        }

        .guest-confirm-card {
            border-radius: 26px;
        }
    }
</style>>

<section class="guest-confirm-hero">
    <div class="container">
        <div class="row align-items-center g-5 justify-content-center">

            <!-- LEFT CONTENT -->
            <div class="col-lg-5">
                <span class="section-mini-title">Secure Password Reset</span>

                <h1 class="fw-bold mb-3">
                    Create a New Password
                </h1>

                <p class="lead text-muted mb-4">
                    Choose a strong new password for your Guest account
                    and return safely to your Live in Sri Lanka journey.
                </p>

                <div class="guest-password-rules">
                    <div class="guest-password-rule">
                        <i class="bi bi-shield-check"></i>
                        <span>Use a password that is difficult for others to guess.</span>
                    </div>

                    <div class="guest-password-rule">
                        <i class="bi bi-key-fill"></i>
                        <span>Avoid using a password you already use on another account.</span>
                    </div>

                    <div class="guest-password-rule">
                        <i class="bi bi-person-lock"></i>
                        <span>Your new password protects access to your Guest dashboard and selections.</span>
                    </div>
                </div>
            </div>


            <!-- FORM / INVALID LINK CARD -->
            <div class="col-lg-5">
                <div class="guest-confirm-card shadow-lg">

                    {% if validlink %}

                        <div class="guest-confirm-card-header">
                            <h3 class="fw-bold mb-2">Set New Password</h3>
                            <p>
                                Enter and confirm your new password below.
                            </p>
                        </div>

                        <form method="post" class="guest-confirm-card-body">
                            {% csrf_token %}

                            {% if form.non_field_errors %}
                                <div class="guest-form-error">
                                    {{ form.non_field_errors }}
                                </div>
                            {% endif %}

                            <div class="mb-3">
                                <label for="{{ form.new_password1.id_for_label }}" class="form-label">
                                    New Password
                                </label>

                                <input
                                    type="password"
                                    name="{{ form.new_password1.html_name }}"
                                    id="{{ form.new_password1.id_for_label }}"
                                    class="form-control"
                                    autocomplete="new-password"
                                    required
                                >

                                {% if form.new_password1.errors %}
                                    <div class="guest-field-error">
                                        {{ form.new_password1.errors|striptags }}
                                    </div>
                                {% endif %}
                            </div>

                            <div class="mb-4">
                                <label for="{{ form.new_password2.id_for_label }}" class="form-label">
                                    Confirm New Password
                                </label>

                                <input
                                    type="password"
                                    name="{{ form.new_password2.html_name }}"
                                    id="{{ form.new_password2.id_for_label }}"
                                    class="form-control"
                                    autocomplete="new-password"
                                    required
                                >

                                {% if form.new_password2.errors %}
                                    <div class="guest-field-error">
                                        {{ form.new_password2.errors|striptags }}
                                    </div>
                                {% endif %}
                            </div>

                            {% if form.new_password1.help_text %}
                                <div class="guest-password-help">
                                    {{ form.new_password1.help_text|safe }}
                                </div>
                            {% endif %}

                            <button type="submit" class="btn btn-dark btn-lg w-100 guest-confirm-submit-btn mt-4">
                                <i class="bi bi-check-circle-fill me-2"></i>
                                Save New Password
                            </button>
                        </form>

                    {% else %}

                        <div class="guest-invalid-reset-box">
                            <div class="guest-invalid-reset-icon">
                                <i class="bi bi-exclamation-triangle-fill"></i>
                            </div>

                            <h3>Password Reset Link Is Invalid</h3>

                            <p>
                                This password reset link may have already been used or may have expired.
                                Please request a fresh password reset email.
                            </p>

                            <a href="{% url 'expat_life:foreigner_password_reset' %}">
                                Request New Reset Link
                            </a>
                        </div>

                    {% endif %}

                </div>
            </div>

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

{% endblock %}