{% load static i18n %}
{% load crispy_forms_tags %}  <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% trans "Set New Password" %} - KAAUH ATS</title>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" crossorigin="anonymous">

    {% get_current_language as LANGUAGE_CODE %}

    <style>
        /* -------------------------------------------------------------------------- */
        /* CUSTOM TEAL THEME OVERRIDES FOR BOOTSTRAP (Consistent with your UI)        */
        /* -------------------------------------------------------------------------- */
        :root {
            --bs-primary: #00636e; /* Dark Teal */
            --bs-primary-rgb: 0, 99, 110;
            --bs-primary-light: #007a88; /* Lighter Teal for hover */
            --bs-body-bg: #f8f9fa;
            --bs-body-color: #212529;
            --bs-border-color: #dee2e6;
        }

        body { font-family: 'Inter', sans-serif; background-color: var(--bs-body-bg); }
        .left-panel { flex: 1; background: url("{% static 'image/kaauh_banner.png' %}") no-repeat center center; background-size: cover; position: relative; display: flex; align-items: flex-end; padding: 3rem; color: white; z-index: 1; }
        .left-panel::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 50%); z-index: 0; }
        .left-panel-content { position: relative; z-index: 2; }
        .right-panel { background-color: white; padding: 3rem; }
        .form-fields { max-height: 100%; overflow-y: auto; }
        .btn-primary { background-color: var(--bs-primary); border-color: var(--bs-primary); font-weight: 600; border-radius: 0.5rem; box-shadow: 0 4px 8px rgba(0, 99, 110, 0.2); transition: all 0.2s ease; }
        .btn-primary:hover { background-color: var(--bs-primary-light); border-color: var(--bs-primary-light); box-shadow: 0 6px 10px rgba(0, 99, 110, 0.3); }
        .form-control:focus { border-color: var(--bs-primary); box-shadow: 0 0 0 0.25rem rgba(0, 99, 110, 0.25); }
        .text-accent { color: var(--bs-primary) !important; }
        .text-accent:hover { color: var(--bs-primary-light) !important; text-decoration: underline; }
        .alert-info-custom { background-color: #f0f8ff; border-left: 5px solid var(--bs-primary); color: var(--bs-primary); }
        @media (min-width: 992px) {
            .right-panel-col { flex: 0 0 450px; }
            .right-panel-col > .d-flex { height: 100%; justify-content: center; align-items: center; padding-top: 0; padding-bottom: 0; }
            .right-panel-content-wrapper { max-width: 350px; width: 100%; }
        }
    </style>
</head>
<body>

    <div class="d-flex vh-100 w-100">

        <div class="left-panel d-none d-lg-flex flex-grow-1">
            <div class="left-panel-content">
                <h1 class="text-4xl font-weight-bold mb-4" style="font-size: 1.5rem;">
                    <span class="text-white">
                        <div class="hospital-text text-center text-md-start me-3">
                            <div class="ar small">{% trans "جامعة الأميرة نورة بنت عبدالرحمن الأكاديمية" %}</div>
                            <div class="ar small">{% trans "ومستشفى الملك عبدالله بن عبدالعزيز التخصصي" %}</div>
                            <div class="en small">{% trans "Princess Nourah bint Abdulrahman University" %}</div>
                            <div class="en small">{% trans "King Abdullah bin Abdulaziz University Hospital" %}</div>
                        </div>
                    </span>
                </h1>
                <small>Powered By TENHAL | تنحل</small>
            </div>
        </div>

        <div class="d-flex flex-column right-panel right-panel-col flex-grow-1 align-items-center justify-content-center">

            <div class="right-panel-content-wrapper">

                <h2 id="form-title" class="h3 fw-bold mb-4 text-center text-accent">{% trans "Set New Password" %}</h2>

                <div class="form-fields">
                    
                    {% if form %}
                    <p class="text-muted small mb-1 text-center">
                        {% trans 'Please enter your new password below.' %}
                    </p>
                    <p class="text-muted small mb-4 text-center">
                        {% trans 'You can then log in.' %}
                    </p>

                    <form method="post" action="."> 
                        {% csrf_token %}
                        
                        {# RENDER THE FORM USING CRISPY FORMS #}
                        {{ form|crispy }}
                        
                        {# Submit Button #}
                        <button type="submit" class="btn btn-primary w-100 mt-4">
                            {% trans "Change Password" %}
                        </button>
                    </form>
                    
                    {% else %}
                        {# Message when the reset key is invalid or expired #}
                        <h4 class="text-danger text-center mb-3">{% trans "Password Reset Failed" %}</h4>
                        <p class="text-muted text-center mb-4">
                            {% trans "The password reset link is invalid or has expired." %}
                        </p>
                        <div class="d-grid mt-4">
                            <a href="{% url 'account_reset_password' %}" class="btn btn-primary">
                                <i class="fas fa-redo me-2"></i> {% trans "Request New Reset Link" %}
                            </a>
                        </div>
                    {% endif %}
                    
                    <div class="text-center mt-3">
                        <a href="{% url 'account_login' %}" class="small text-accent fw-medium">
                            <i class="fas fa-sign-in-alt me-1"></i> {% trans "Return to Sign In" %}
                        </a>
                    </div>
                </div>
            </div>

            </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js" crossorigin="anonymous"></script>
</body>
</html>