<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Accept Invitation</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <style>
        body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #0d1117; }
        .invite-card { width: 100%; max-width: 460px; }
    </style>
</head>
<body>
<div class="invite-card p-4">
    <div class="text-center mb-4">
        <i class="bi bi-envelope-open-heart-fill fs-1 text-success"></i>
        <h3 class="fw-bold mt-2">Accept Invitation</h3>
        <p class="text-muted small mb-0">Join {{ invite.group_name }} on MCLogger</p>
    </div>

    <div class="card border-secondary">
        <div class="card-body">
            <div class="mb-3 small text-muted">
                <div><strong>Username:</strong> {{ invite.invited_username }}</div>
                <div><strong>Email:</strong> {{ invite.invited_email }}</div>
                <div><strong>Role:</strong> {{ invite.role|capitalize }}</div>
                <div><strong>Expires:</strong> {{ invite.expires_at | fmt_dt }}</div>
            </div>

            {% if error %}
            <div class="alert alert-danger py-2">{{ error }}</div>
            {% endif %}

            {% if is_invalid %}
            <div class="alert alert-warning mb-0">
                {% if is_expired %}
                This invitation has expired.
                {% elif invite.revoked_at %}
                This invitation has been revoked.
                {% else %}
                This invitation has already been used.
                {% endif %}
            </div>
            {% else %}
            <form method="post">
                <input type="hidden" name="_csrf_token" value="{{ csrf_token() }}">
                <div class="mb-3">
                    <label class="form-label">Choose Password</label>
                    <input type="password" name="password" class="form-control" minlength="8" required>
                </div>
                <div class="mb-3">
                    <label class="form-label">Confirm Password</label>
                    <input type="password" name="confirm_password" class="form-control" minlength="8" required>
                </div>
                <button type="submit" class="btn btn-success w-100">
                    <i class="bi bi-check2-circle me-1"></i>Create Account
                </button>
            </form>
            {% endif %}
        </div>
    </div>

    <div class="text-center mt-3">
        <a href="{{ url_for('auth.login') }}" class="text-muted small">
            <i class="bi bi-arrow-left me-1"></i>Back to login
        </a>
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
