{% extends 'rental_app/base_rental.html' %}
{% block title %}Rental Owner Sign In{% endblock %}

{% block content %}

<style>
    .owner-login-hero {
        position: relative;
        min-height: 100vh;
        padding: 6rem 0;
        background:
            radial-gradient(circle at top left, rgba(20, 184, 166, 0.18), transparent 34%),
            radial-gradient(circle at bottom right, rgba(250, 204, 21, 0.13), transparent 32%),
            linear-gradient(135deg, #052e25 0%, #0f766e 55%, #064e3b 100%);
        color: #fff;
        overflow: hidden;
    }

    .owner-login-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;
    }

    .owner-login-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;
    }

    .owner-login-hero .container {
        position: relative;
        z-index: 2;
    }

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

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

    .owner-login-hero .section-mini-title {
        display: inline-block;
        background: rgba(255, 255, 255, 0.16);
        color: #ccfbf1;
        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;
    }

    .owner-login-hero .login-info-list {
        margin: 24px 0 20px;
    }

    .owner-login-hero .login-info-item {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 14px;
        font-size: 1rem;
        color: rgba(255, 255, 255, 0.92);
        font-weight: 600;
    }

    .owner-login-hero .login-info-item i {
        color: #99f6e4;
        font-size: 1.2rem;
    }

    .owner-login-hero .login-note-box {
        background: rgba(255, 251, 235, 0.14);
        border-left: 4px solid #fde68a;
        color: rgba(255, 255, 255, 0.92);
        padding: 16px 20px;
        border-radius: 16px;
        display: flex;
        gap: 12px;
        align-items: flex-start;
        line-height: 1.65;
    }

    .owner-login-hero .login-note-box i {
        color: #fde68a;
        font-size: 1.3rem;
        margin-top: 2px;
    }

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

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

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

    .login-form-header p {
        color: #64748b !important;
        font-size: 0.9rem;
        margin-top: 8px;
    }

    .login-form-body {
        padding: 32px;
    }

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

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

    .login-form-body .form-control:focus {
        border-color: #0f766e;
        box-shadow: 0 0 0 0.22rem rgba(15, 118, 110, 0.13);
    }

    .forgot-password-link {
        color: #0f766e;
        text-decoration: none;
        font-weight: 700;
        font-size: 0.85rem;
    }

    .forgot-password-link:hover {
        color: #064e3b;
        text-decoration: underline;
    }

    .login-form-body .btn-dark {
        background: linear-gradient(135deg, #0f766e, #064e3b);
        border: none;
        border-radius: 48px;
        padding: 0.85rem 1rem;
        font-weight: 800;
        box-shadow: 0 16px 32px rgba(15, 118, 110, 0.24);
    }

    .login-form-body .btn-dark:hover {
        background: linear-gradient(135deg, #0d9488, #065f46);
    }

    .login-form-footer {
        border-top: 1px solid #e9ecef;
        padding-top: 24px;
        margin-top: 8px;
    }

    .login-form-footer .text-muted {
        color: #64748b !important;
    }

    .login-form-footer .btn-outline-primary {
        border: 2px solid #0f766e;
        color: #0f766e;
        font-weight: 700;
        border-radius: 48px;
        padding: 10px;
    }

    .login-form-footer .btn-outline-primary:hover {
        background: #0f766e;
        color: #fff;
        border-color: #0f766e;
    }

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

        .login-form-body {
            padding: 24px;
        }

        .login-form-header {
            padding: 22px 20px;
        }

        .login-form-card {
            border-radius: 26px;
        }
    }
</style>

<section class="owner-login-hero">
    <div class="container">
        <div class="row align-items-center g-5 justify-content-center">
            <div class="col-lg-5">
                <span class="section-mini-title">Owner Access</span>
                <h1 class="fw-bold mb-3">Rental Owner Sign In</h1>
                <p class="lead text-muted mb-4">
                    Sign in to manage your rental owner dashboard, submit property listings, and monitor approval status.
                </p>

                <div class="login-info-list">
                    <div class="login-info-item">
                        <i class="bi bi-check-circle-fill"></i>
                        <span>Access your rental owner dashboard</span>
                    </div>
                    <div class="login-info-item">
                        <i class="bi bi-check-circle-fill"></i>
                        <span>Submit and manage rental property listings</span>
                    </div>
                    <div class="login-info-item">
                        <i class="bi bi-check-circle-fill"></i>
                        <span>Track listing approval and visibility status</span>
                    </div>
                </div>

                <div class="login-note-box mt-4">
                    <i class="bi bi-info-circle-fill"></i>
                    <div>
                        This sign-in area is for approved rental owners who already have a registered account in the system.
                    </div>
                </div>
            </div>

            <div class="col-lg-5">
                <div class="login-form-card shadow-lg">
                    <div class="login-form-header">
                        <h3 class="fw-bold mb-2">Owner Sign In</h3>
                        <p class="text-muted mb-0">
                            Enter your username and password to continue.
                        </p>
                    </div>

                    <form method="post" action="{% url 'rental_app:rental_owner_login' %}" class="login-form-body">
                        {% csrf_token %}

                        {% if messages %}
                            {% for message in messages %}
                                <div class="alert alert-{{ message.tags|default:'info' }} rounded-4 mb-3">
                                    {{ message }}
                                </div>
                            {% endfor %}
                        {% endif %}

                        {% if form.errors %}
                        <div class="alert alert-danger rounded-4 mb-3">
                            Invalid username or password. Please try again.
                        </div>
                        {% endif %}

                        <div class="mb-3">
                            <label for="id_username" class="form-label">Username</label>
                            <input
                                type="text"
                                name="username"
                                autofocus
                                required
                                id="id_username"
                                class="form-control"
                                autocomplete="username"
                                value="{{ form.username.value|default_if_none:'' }}"
                            >
                        </div>

                        <div class="mb-3">
                            <label for="id_password" class="form-label">Password</label>
                            <input
                                type="password"
                                name="password"
                                required
                                id="id_password"
                                class="form-control"
                                autocomplete="current-password"
                            >
                        </div>

                        <div class="d-flex justify-content-end mb-4">
                            <a href="{% url 'rental_app:rental_password_reset' %}"
                            class="forgot-password-link">
                                <i class="bi bi-key-fill me-1"></i>
                                Forgot your password?
                            </a>
                        </div>

                        {% if next %}
                        <input type="hidden" name="next" value="{{ next }}">
                        {% endif %}

                        <button type="submit" class="btn btn-dark btn-lg w-100">
                            Sign In as Rental Owner
                        </button>
                    </form>

                    <div class="login-form-footer text-center mt-3 px-4 pb-4">
                        <p class="small text-muted mb-2">
                            Do not have an owner account yet?
                        </p>
                        <a href="{% url 'rental_app:rental_owner_signup' %}" class="btn btn-outline-primary w-100">
                            Rental Owner Signup
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

{% endblock %}