<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - SSWSEEP</title>

    <!-- Bootstrap 5 -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">

    <style>
        body {
            background: #f8f9fa;
        }
        .login-card {
            max-width: 420px;
            border: none;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0,0,0,.08);
        }
        .login-header {
            background: #28a745;
            color: white;
            padding: 1rem 0;
            border-top-left-radius: 12px;
            border-top-right-radius: 12px;
            text-align: center;
        }
        .logo-container img {
            height: 70px;
            margin: 0 10px;
        }
        .btn-login {
            background: #28a745;
            border: none;
            font-weight: 600;
            border-radius: 8px;
            padding: .6rem 0;
        }
        .btn-login:hover {
            background: #218838;
        }
        .form-control {
            border-radius: 8px;
            padding: .6rem .75rem;
        }
        .form-check-label {
            font-size: .9rem;
        }
        .alert {
            border-radius: 8px;
        }
        .password-wrapper {
            position: relative;
        }
        .password-toggle {
            position: absolute;
            top: 50%;
            right: 0.85rem;
            transform: translateY(-50%);
            cursor: pointer;
            color: #6c757d;
        }
        .password-toggle:hover {
            color: #495057;
        }
    </style>
</head>
<body class="d-flex align-items-center min-vh-100 py-4">

<div class="container">
    <div class="row justify-content-center">
        <div class="col-12 col-md-5">

            <!-- Card -->
            <div class="card login-card">

                <!-- Header with Logos -->
                <div class="login-header">
                    <div class="d-flex justify-content-center align-items-center logo-container">
                        <img src="{{ asset('images/ministry-logo.png') }}" alt="Ministry Logo">
                        <!-- <img src="{{ asset('images/sswseep-logo-fin.png') }}" alt="SSWSEEP Logo"> -->
                    </div>
                    <h5 class="mt-2 mb-0 fw-bold">MGCSW</h5>
                </div>

                <!-- Body -->
                <div class="card-body p-4">

                    <h4 class="text-center mb-4 text-success fw-bold">
                        South Sudan Women’s Social and Economic Empowerment Project (SSWSEEP)
                    </h4>

                    <form method="POST" action="{{ route('login') }}">
                        @csrf

                        <!-- Username -->
                        <div class="mb-3">
                            <label for="email" class="form-label fw-medium">Username</label>
                            <input id="email"
                                   type="text"
                                   name="email"
                                   class="form-control @error('email') is-invalid @enderror"
                                   value="{{ old('email') }}"
                                   required autofocus>
                            @error('email')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <!-- Password -->
                        <div class="mb-3">
                            <label for="password" class="form-label fw-medium">Password</label>
                            <div class="password-wrapper">
                                <input id="password"
                                       type="password"
                                       name="password"
                                       class="form-control @error('password') is-invalid @enderror"
                                       required>
                                <span class="password-toggle" id="togglePassword" aria-label="Show password">
                                    👁
                                </span>
                            </div>
                            @error('password')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <!-- Remember & Login -->
                        <div class="d-flex justify-content-between align-items-center mb-3">
                            <div class="form-check">
                                <input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
                                <label class="form-check-label" for="remember">Remember me</label>
                            </div>
                        </div>

                        <button type="submit" class="btn btn-success btn-login w4 w-100">
                            Login
                        </button>
                    </form>

                    <!-- Error Alert -->
                    @if ($errors->any())
                        <div class="alert alert-danger mt-3 mb-0">
                            {{ $errors->first() }}
                        </div>
                    @endif

                </div>
            </div>

        </div>
    </div>
</div>

<!-- Bootstrap JS (optional) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
    (function () {
        const passwordInput = document.getElementById('password');
        const toggle = document.getElementById('togglePassword');

        if (passwordInput && toggle) {
            toggle.addEventListener('click', function () {
                const isPassword = passwordInput.getAttribute('type') === 'password';
                passwordInput.setAttribute('type', isPassword ? 'text' : 'password');
                toggle.setAttribute('aria-label', isPassword ? 'Hide password' : 'Show password');
            });
        }
    })();
</script>
</body>
</html>