<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title|default("Annotation Platform") }} - Reset Password</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body class="potato-page-center">
    <div style="width: 100%; max-width: 420px;">
        <div style="text-align: center; margin-bottom: 2rem;">
            <h1 class="potato-page-title">{{ title|default("Annotation Platform") }}</h1>
            <p class="potato-page-subtitle" style="margin-bottom: 0;">
                {% if success %}Password Updated{% elif token_invalid %}Invalid Link{% else %}Set New Password{% endif %}
            </p>
        </div>

        <div class="potato-page-card">
            {% if error %}
            <div class="potato-alert potato-alert-error">
                <i class="fas fa-exclamation-circle me-1"></i> {{ error }}
            </div>
            {% endif %}

            {% if success %}
            <div class="potato-alert" style="background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; border-radius: 0.375rem; padding: 0.75rem 1rem; margin-bottom: 1rem;">
                <i class="fas fa-check-circle me-1"></i>
                Your password has been updated successfully.
            </div>
            <div style="text-align: center;">
                <a href="/" class="potato-form-submit" style="display: inline-block; text-decoration: none; text-align: center;">
                    Sign In
                </a>
            </div>

            {% elif token_invalid %}
            <p style="text-align: center; color: #6c757d;">
                This password reset link is invalid or has expired.
                Please request a new one.
            </p>
            <div style="text-align: center; margin-top: 1rem;">
                <a href="/forgot-password" class="potato-form-submit" style="display: inline-block; text-decoration: none; text-align: center;">
                    Request New Link
                </a>
            </div>

            {% else %}
            {% if username %}
            <p style="color: #6c757d; font-size: 0.9rem; margin-bottom: 1rem;">
                Resetting password for <strong>{{ username }}</strong>
            </p>
            {% endif %}
            <form method="POST" action="/reset/{{ token }}">
                <div class="potato-form-group">
                    <label for="password" class="potato-form-label">New Password</label>
                    <input id="password" name="password" type="password" class="potato-form-input"
                           placeholder="Enter new password" required>
                </div>
                <div class="potato-form-group">
                    <label for="confirm_password" class="potato-form-label">Confirm Password</label>
                    <input id="confirm_password" name="confirm_password" type="password" class="potato-form-input"
                           placeholder="Confirm new password" required>
                </div>
                <button type="submit" class="potato-form-submit">Reset Password</button>
            </form>
            {% endif %}

            <div style="text-align: center; margin-top: 1rem;">
                <a href="/" style="color: #6c757d; font-size: 0.875rem; text-decoration: none;">
                    <i class="fas fa-arrow-left me-1"></i> Back to Sign In
                </a>
            </div>
        </div>
    </div>
</body>
</html>
