<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Admin - PilahPintar</title>
    
    <!-- Bootstrap 5 CSS & FontAwesome -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
    
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    
    <style>
        body {
            background: linear-gradient(135deg, #064e3b 0%, #0f172a 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Plus Jakarta Sans', sans-serif;
            color: #0f172a;
        }
        .login-card {
            width: 100%;
            max-width: 440px;
            background: white;
            border-radius: 1.5rem;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
            overflow: hidden;
            border-top: 5px solid #10b981;
        }
        .font-heading {
            font-family: 'Fredoka', cursive, sans-serif;
        }
        .form-control:focus {
            border-color: #10b981;
            box-shadow: 0 0 0 0.25rem rgba(16, 185, 129, 0.25);
        }
        .btn-success {
            background-color: #10b981;
            border-color: #10b981;
            transition: all 0.25s ease;
        }
        .btn-success:hover {
            background-color: #059669;
            border-color: #059669;
            transform: translateY(-1px);
            box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
        }
    </style>
</head>
<body>

    <div class="login-card p-4 p-md-5">
        <div class="text-center mb-4">
            <span class="fs-1">♻️🔐</span>
            <h4 class="fw-bold font-heading text-dark mt-2 mb-1">Login Admin PilahPintar</h4>
            <p class="text-muted small mb-0">Masukkan kredensial admin untuk mengelola konten</p>
        </div>

        @if(session('success'))
            <div class="alert alert-success alert-dismissible fade show small mb-3" role="alert">
                <i class="fa-solid fa-circle-check me-1"></i> {{ session('success') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        @endif

        @if(session('error'))
            <div class="alert alert-danger small mb-3">
                <i class="fa-solid fa-circle-exclamation me-1"></i> {{ session('error') }}
            </div>
        @endif

        <form action="{{ route('admin.login.submit') }}" method="POST">
            @csrf
            
            <!-- NAME OR EMAIL -->
            <div class="mb-3">
                <label class="form-label fw-bold small text-dark">Nama Lengkap / Alamat Email</label>
                <div class="input-group">
                    <span class="input-group-text"><i class="fa-solid fa-user text-muted"></i></span>
                    <input type="text" name="login" class="form-control @error('login') is-invalid @enderror" 
                           placeholder="Nama lengkap atau alamat email..." 
                           value="{{ old('login') }}" required autofocus>
                </div>
                @error('login')
                    <span class="invalid-feedback d-block small mt-1">{{ $message }}</span>
                @enderror
            </div>

            <!-- PASSWORD -->
            <div class="mb-4">
                <label class="form-label fw-bold small text-dark">Password</label>
                <div class="input-group">
                    <span class="input-group-text"><i class="fa-solid fa-lock text-muted"></i></span>
                    <input type="password" id="passwordInput" name="password" class="form-control" 
                           placeholder="Password..." required>
                    <button class="btn btn-outline-secondary" type="button" id="togglePasswordBtn" style="border-top-right-radius: 0.375rem; border-bottom-right-radius: 0.375rem;">
                        <i class="fa-solid fa-eye-slash" id="togglePasswordIcon"></i>
                    </button>
                </div>
            </div>

            <!-- SUBMIT BUTTON -->
            <button type="submit" class="btn btn-success btn-lg w-100 rounded-pill fw-bold shadow-sm mb-3">
                <i class="fa-solid fa-right-to-bracket me-1"></i> Masuk Admin
            </button>
        </form>

        <!-- REGISTER LINK -->
        <div class="text-center mt-2">
            <span class="small text-muted">Belum punya akun admin? </span>
            <a href="{{ route('admin.register') }}" class="text-success fw-bold small text-decoration-none">Daftar Akun Baru</a>
        </div>

        <div class="text-center mt-4 pt-3 border-top">
            <a href="{{ route('home') }}" class="text-decoration-none text-muted small">
                &larr; Kembali ke Website Utama Siswa
            </a>
        </div>
    </div>

    <!-- Script to toggle password visibility -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const passwordInput = document.getElementById('passwordInput');
            const togglePasswordBtn = document.getElementById('togglePasswordBtn');
            const togglePasswordIcon = document.getElementById('togglePasswordIcon');

            togglePasswordBtn.addEventListener('click', function() {
                const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
                passwordInput.setAttribute('type', type);
                
                if (type === 'text') {
                    togglePasswordIcon.classList.remove('fa-eye-slash');
                    togglePasswordIcon.classList.add('fa-eye');
                } else {
                    togglePasswordIcon.classList.remove('fa-eye');
                    togglePasswordIcon.classList.add('fa-eye-slash');
                }
            });
        });
    </script>

    <!-- Bootstrap 5 JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
