{% extends "layout.html.twig" %}

{% block title %}Login | LocalLendables{% endblock %}

{% block content %}
<main class="container-fluid py-4">
    
    <div class="row justify-content-center">
        <div class="col-12 col-md-6 col-lg-4">
            
            <div class="text-center mb-4">
                <i class="fas fa-handshake text-primary mb-3" style="font-size: 3rem;"></i>
                <h2 class="h4 fw-bold mb-2">Welcome to LocalLendables</h2>
                <p class="text-muted">Sign in to your community sharing account</p>
            </div>

            {% if error %}
            <div class="alert alert-danger" role="alert">
                {{ error == 'invalid_credentials' ? 'Invalid email or password. Please try again.' : (error == 'server_error' ? 'Server error occurred. Please try again later.' : 'An error occurred. Please try again.') }}
            </div>
            {% endif %}

            <div class="bg-white rounded-3 p-4 shadow-sm">
                <form method="POST" action="/login">
                    <div class="mb-3">
                        <label for="email" class="form-label fw-medium">Email Address</label>
                        <input type="email" class="form-control form-control-lg" id="email" name="email" 
                               placeholder="Enter your email" value="{{ demoEmail }}" required>
                    </div>
                    
                    <div class="mb-4">
                        <label for="password" class="form-label fw-medium">Password</label>
                        <input type="password" class="form-control form-control-lg" id="password" name="password" 
                               placeholder="Enter your password" value="{{ demoPassword }}" required>
                    </div>
                    
                    {% if isDemoUser %}
                    <div class="alert alert-info mb-3">
                        <i class="fas fa-info-circle me-2"></i>Demo login pre-filled - just click "Sign In"
                    </div>
                    {% endif %}
                    
                    <button type="submit" class="btn btn-primary-custom w-100 mb-3">
                        <i class="fas fa-sign-in-alt me-2"></i>Sign In
                    </button>
                </form>

                <div class="text-center">
                    <div class="mb-2">
                        <small class="text-muted">
                            <a href="#" class="text-decoration-none">Forgot your password?</a>
                        </small>
                    </div>
                    <div>
                        <small class="text-muted">
                            <a href="/" class="text-decoration-none">Go to Home for development</a>
                        </small>
                    </div>
                    </small>
                </div>
            </div>

            <!-- Demo Accounts -->
            <div class="bg-light rounded-3 p-4 mt-4">
                <h3 class="h6 fw-bold mb-3 text-center">Try Demo Accounts</h3>
                <div class="d-grid gap-2">
                    <a href="/login?demo=kiley.ford" class="btn btn-outline-primary">
                        <i class="fas fa-user me-2"></i>Demo as Kiley Ford
                        <small class="d-block text-muted">2 items shared</small>
                    </a>
                    <a href="/login?demo=morgan.gilbert" class="btn btn-outline-secondary">
                        <i class="fas fa-user me-2"></i>Demo as Morgan Gilbert
                        <small class="d-block text-muted">3 items shared</small>
                    </a>
                </div>
                <div class="text-center mt-3">
                    <small class="text-muted">
                        Demo accounts showcase the platform features
                    </small>
                </div>
            </div>

            <div class="text-center mt-4">
                <p class="text-muted small mb-2">Don't have an account?</p>
                <a href="#" class="btn btn-link text-decoration-none">
                    Join the Community
                </a>
            </div>

        </div>
    </div>

</main>
{% endblock %}
