<!DOCTYPE html>
<html lang="id">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Space Casual Store - Login Admin</title>
    <link rel="icon" href="{{ asset('images/logo.png') }}?v=1" type="image/png">

    {{-- Google Fonts: Poppins --}}
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">

    {{-- Font Awesome (Untuk ikon User-Shield) & Bootstrap Icons (Untuk arrow) --}}
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">

    <style>
        /* Reset & Base Styles */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body,
        html {
            font-family: 'Poppins', sans-serif;
            background-color: #121A25;
            /* Warna background dark navy sesuai UI */
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        /* Card Container */
        .login-card {
            background-color: #ffffff;
            width: 460px;
            /* width: 100%;
            max-width: 900px; */
            border-radius: 12px;
            padding: 48px 40px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
        }

        /* Header Section */
        .login-header {
            text-align: center;
            margin-bottom: 32px;
        }

        .login-icon {
            font-size: 64px;
            color: #2DA5DF;
            /* Warna biru muda sesuai UI */
            margin-bottom: 12px;
        }

        .login-title {
            font-size: 26px;
            font-weight: 700;
            color: #000000;
            margin-bottom: 6px;
        }

        .login-subtitle {
            font-size: 15px;
            color: #6B7280;
            /* Warna teks abu-abu */
        }

        /* Alert Pesan Error */
        .alert-error {
            background-color: #FEE2E2;
            color: #B91C1C;
            padding: 12px;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 500;
            margin-bottom: 20px;
            text-align: center;
            border: 1px solid #FECACA;
        }

        /* Form Section */
        .login-form {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .input-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .input-group label {
            font-size: 14px;
            font-weight: 500;
            color: #1F2937;
        }

        .input-group input {
            width: 100%;
            padding: 14px 16px;
            border: 1px solid #9CA3AF;
            border-radius: 8px;
            font-family: 'Poppins', sans-serif;
            font-size: 14px;
            color: #111827;
            outline: none;
            transition: border-color 0.3s ease;
        }

        .input-group input::placeholder {
            color: #9CA3AF;
        }

        .input-group input:focus {
            border-color: #2DA5DF;
            box-shadow: 0 0 0 3px rgba(45, 165, 223, 0.1);
        }

        /* Pembungkus input password agar ikon bisa absolute */
        .password-wrapper {
            position: relative;
            width: 100%;
        }

        /* Mengubah padding kanan agar teks tidak tertutup ikon */
        .password-wrapper input {
            padding-right: 45px;
        }

        /* Tombol ikon mata */
        .btn-eye {
            position: absolute;
            top: 50%;
            right: 14px;
            transform: translateY(-50%);
            background: none;
            border: none;
            color: #9CA3AF;
            font-size: 18px;
            cursor: pointer;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: color 0.3s;
        }

        .btn-eye:hover {
            color: #2DA5DF;
            /* Berubah biru saat dihover */
        }

        .btn-eye:focus {
            outline: none;
        }

        /* Login Button */
        .btn-login {
            background-color: #2DA5DF;
            color: #ffffff;
            border: none;
            border-radius: 8px;
            padding: 14px;
            font-size: 16px;
            font-weight: 600;
            font-family: 'Poppins', sans-serif;
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 8px;
            transition: background-color 0.3s;
            margin-top: 8px;
        }

        .btn-login:hover {
            background-color: #2488B8;
        }

        .btn-login i {
            font-size: 18px;
        }

        /* Footer Section */
        .login-footer {
            text-align: center;
            margin-top: 24px;
        }

        .back-link {
            color: #2DA5DF;
            text-decoration: none;
            font-size: 13px;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            transition: color 0.3s;
        }

        .back-link:hover {
            color: #2488B8;
        }

        /* Responsive HP */
        @media (max-width: 480px) {
            .login-card {
                margin: 20px;
                padding: 40px 24px;
            }
        }
    </style>
</head>

<body>

    <div class="login-card">
        {{-- Bagian Header Login --}}
        <div class="login-header">
            <i class="fa-solid fa-user-shield login-icon"></i>
            <h1 class="login-title">Login Admin</h1>
            <p class="login-subtitle">Space Casual Store Management</p>
        </div>

        {{-- Menangkap Pesan Error dari Controller jika Username/Password Salah --}}
        @if(session('error'))
            <div class="alert-error">
                <i class="bi bi-exclamation-circle-fill" style="margin-right: 4px;"></i>
                {{ session('error') }}
            </div>
        @endif

        {{-- Form Login --}}
        <form action="{{ url('/login') }}" method="POST" class="login-form">
            @csrf

            <div class="input-group">
                <label for="username">Username</label>
                <input type="text" id="username" name="username" placeholder="Masukkan username" required autofocus>
            </div>

            <div class="input-group">
                <label for="password">Password</label>
                <div class="password-wrapper">
                    <input type="password" id="password" name="password" placeholder="Masukkan password" required>
                    <button type="button" id="togglePassword" class="btn-eye" tabindex="-1">
                        <i class="bi bi-eye"></i>
                    </button>
                </div>
            </div>

            <button type="submit" class="btn-login">
                <i class="bi bi-box-arrow-in-right"></i> Login
            </button>
        </form>

        {{-- Bagian Link Kembali --}}
        <div class="login-footer">
            <a href="{{ url('/') }}" class="back-link">
                &larr; Kembali ke Beranda
            </a>
        </div>
    </div>
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const togglePassword = document.getElementById('togglePassword');
        const passwordInput = document.getElementById('password');
        const eyeIcon = togglePassword.querySelector('i');

        togglePassword.addEventListener('click', function () {
            // Cek apakah tipe input saat ini password atau text
            const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
            passwordInput.setAttribute('type', type);

            // Ubah ikon mata
            if (type === 'text') {
                eyeIcon.classList.remove('bi-eye');
                eyeIcon.classList.add('bi-eye-slash'); // Ikon mata dicoret
            } else {
                eyeIcon.classList.remove('bi-eye-slash');
                eyeIcon.classList.add('bi-eye'); // Ikon mata terbuka
            }
        });
    });
</script>
</body>

</html>