<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="{{ url_for('static', filename='brighterStyles.css') }}">
    <title>{{ title }} | BrighterTrades</title>
    <link rel="icon" href="{{ url_for('static', filename='brightertrades_favicon.ico') }}" type="image/x-icon">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/aos/2.3.4/aos.css" rel="stylesheet">
</head>
<body class="bg-dark text-light">
    <div class="bg-animation"></div>

    <div class="container py-5">
        <div class="row justify-content-center">
            <div class="col-lg-5 col-md-7">
                <div class="card bg-transparent border-0" data-aos="fade-up" data-aos-duration="1000">
                    <div class="card-body p-4">
                        <!-- BrighterTrades Logo -->
                        <div class="text-center mb-4">
                            <img src="{{ url_for('static', filename='logo_BrighterTrades.webp') }}" alt="BrighterTrades Logo" class="img-fluid logo" style="max-width: 150px; margin-top: 20px;">
                        </div>

                        <h2 class="card-title text-center mb-4">Sign In</h2>

                        <!-- Flash Messages - Only show login-related messages -->
                        {% with messages = get_flashed_messages(with_categories=true) %}
                            {% if messages %}
                                {% for category, message in messages %}
                                    {% if category in ['login_error', 'error'] %}
                                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                            <i class="fas fa-exclamation-circle me-2"></i>{{ message }}
                                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                                        </div>
                                    {% elif category == 'success' %}
                                        <div class="alert alert-success alert-dismissible fade show" role="alert">
                                            <i class="fas fa-check-circle me-2"></i>{{ message }}
                                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                                        </div>
                                    {% endif %}
                                {% endfor %}
                            {% endif %}
                        {% endwith %}

                        <!-- Login Form -->
                        <form id="login_form" action="/login" method="POST">
                            <!-- Username Field -->
                            <div class="mb-3">
                                <label for="username" class="form-label">Username</label>
                                <div class="input-group">
                                    <span class="input-group-text"><i class="fas fa-user"></i></span>
                                    <input type="text" class="form-control" id="username" name="username" placeholder="Enter your username" required autofocus>
                                </div>
                            </div>

                            <!-- Password Field -->
                            <div class="mb-4">
                                <label for="password" class="form-label">Password</label>
                                <div class="input-group">
                                    <span class="input-group-text"><i class="fas fa-lock"></i></span>
                                    <input type="password" class="form-control" id="password" name="password" placeholder="Enter your password" required>
                                </div>
                            </div>

                            <!-- Submit Button -->
                            <button type="submit" class="btn btn-primary w-100 py-2">
                                <i class="fas fa-sign-in-alt me-2"></i> Sign In
                            </button>
                        </form>

                        <hr class="my-4 text-light">

                        <!-- Link to Signup Page -->
                        <p class="text-center mb-2">
                            Don't have an account? <a href="/signup" class="text-primary">Sign up here</a>
                        </p>

                        <!-- Link back to Welcome -->
                        <p class="text-center">
                            <a href="/" class="text-muted"><i class="fas fa-arrow-left me-1"></i> Back to Welcome</a>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/aos/2.3.4/aos.js"></script>
    <script>
        AOS.init({
            offset: 100,
            duration: 600,
            easing: 'ease-out-cubic',
            anchorPlacement: 'top-center',
        });
    </script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

    <style>
        body {
            font-family: 'Roboto', sans-serif;
            background-color: #121212;
            color: #e0e0e0;
            position: relative;
            overflow-x: hidden;
            padding-top: 80px;
        }

        .bg-animation {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
            z-index: -1;
        }

        .card {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 15px;
        }

        .input-group-text {
            background-color: #1f1f1f;
            border: none;
            color: #e0e0e0;
        }

        .form-control {
            background-color: #2a2a2a;
            border: 1px solid #444;
            color: #e0e0e0;
        }

        .form-control:focus {
            background-color: #333;
            border-color: #0d6efd;
            color: #fff;
            box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
        }

        .form-control::placeholder {
            color: #888;
        }

        .btn-primary {
            background-color: #0d6efd;
            border: none;
            transition: background-color 0.3s ease;
        }

        .btn-primary:hover {
            background-color: #0b5ed7;
        }

        .logo {
            display: block;
            margin: 0 auto;
            max-height: 100px;
        }

        a.text-primary {
            color: #0d6efd !important;
        }

        a.text-muted {
            color: #888 !important;
            text-decoration: none;
        }

        a.text-muted:hover {
            color: #aaa !important;
        }
    </style>
</body>
</html>
