{% extends 'rental_app/base_rental.html' %}

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

{% block content %}

<style>
    .rental-confirm-hero {
        position: relative;
        min-height: 100vh;
        padding: 6rem 0;
        background:
            radial-gradient(circle at top left, rgba(251, 191, 36, 0.18), transparent 34%),
            radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.16), transparent 32%),
            linear-gradient(135deg, #082f49 0%, #075985 52%, #164e63 100%);
        color: #fff;
        overflow: hidden;
    }

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

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

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

    .rental-confirm-hero .section-mini-title {
        display: inline-block;
        background: rgba(255, 255, 255, 0.16);
        color: #fde68a;
        border: 1px solid rgba(255, 255, 255, 0.24);
        font-weight: 800;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        padding: 6px 14px;
        border-radius: 40px;
        margin-bottom: 16px;
    }

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

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

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

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

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

    .rental-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);
    }

    .rental-confirm-card-header {
        background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
        padding: 28px 32px;
        color: #0f172a;
        text-align: center;
        border-bottom: 1px solid #e2e8f0;
    }

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

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

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

    .rental-confirm-card-body .form-label {
        color: #0f172a;
        font-weight: 700;
    }

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

    .rental-confirm-card-body .form-control:focus {
        border-color: #075985;
        box-shadow: 0 0 0 0.22rem rgba(7, 89, 133, 0.13);
    }

    .rental-confirm-submit-btn {
        background: linear-gradient(135deg, #075985, #0f766e);
        border: none;
        border-radius: 48px;
        padding: 0.85rem 1rem;
        font-weight: 800;
        box-shadow: 0 16px 32px rgba(7, 89, 133, 0.24);
    }

    .rental-confirm-submit-btn:hover {
        background: linear-gradient(135deg, #0369a1, #0d9488);
    }

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

    .rental-invalid-reset-icon {
        width: 88px;
        height: 88px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 30px;
        background: #fef2f2;
        color: #b91c1c;
        font-size: 2.35rem;
        margin-bottom: 1rem;
    }

    .rental-invalid-reset-box h3 {
        color: #0f172a;
        font-weight: 900;
        margin-bottom: 0.7rem;
    }

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

    .rental-invalid-reset-box a {
        border-radius: 48px;
        padding: 0.85rem 1.35rem;
        font-weight: 800;
        text-decoration: none;
        color: #fff;
        background: linear-gradient(135deg, #075985, #0f766e);
        display: inline-block;
    }

    .rental-invalid-reset-box a:hover {
        background: linear-gradient(135deg, #0369a1, #0d9488);
    }

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

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

    .rental-password-help {
        margin-top: 16px;
        padding: 14px 16px;
        border-radius: 18px;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        color: #475569;
        font-size: 0.9rem;
        line-height: 1.65;
    }

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

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

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

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

<section class="rental-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 Rental Owner account
                    and return safely to your Rent in Sri Lanka property dashboard.
                </p>

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

                    <div class="rental-password-rule">
                        <i class="bi bi-key-fill"></i>
                        <span>Avoid reusing a password from another website or account.</span>
                    </div>

                    <div class="rental-password-rule">
                        <i class="bi bi-house-lock-fill"></i>
                        <span>Your new password protects access to your rental owner dashboard.</span>
                    </div>
                </div>
            </div>


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

                    {% if validlink %}

                        <div class="rental-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="rental-confirm-card-body">
                            {% csrf_token %}

                            {% if form.non_field_errors %}
                                <div class="rental-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="rental-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="rental-field-error">
                                        {{ form.new_password2.errors|striptags }}
                                    </div>
                                {% endif %}
                            </div>

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

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

                    {% else %}

                        <div class="rental-invalid-reset-box">
                            <div class="rental-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 'rental_app:rental_password_reset' %}">
                                Request New Reset Link
                            </a>
                        </div>

                    {% endif %}

                </div>
            </div>

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

{% endblock %}