<!DOCTYPE html>
<html lang="id">
 <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Admin/Atasan - Absensi</title>
    <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=Inter:wght@400;600;700&display=swap" rel="stylesheet">
    <style>
        :root { --bg: #0f172a; --card: #111827; --muted: #9ca3af; --text: #e5e7eb; --primary: #3b82f6; }
        * { box-sizing: border-box; }
        body {
            margin: 0;
            font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
            color: var(--text);
            min-height: 100vh;
            display: grid;
            place-items: center;
            background: linear-gradient(180deg, #0b1220, #0f172a);
        }
        .topbar { position: fixed; top: 20px; left: 20px; display: flex; gap: 10px; }
        .link-btn { padding: 10px 14px; border-radius: 10px; background: rgba(17, 24, 39, 0.85); color: #e5e7eb; border: 1px solid rgba(148, 163, 184, 0.25); text-decoration: none; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
        .link-btn:hover { filter: brightness(1.05); }
        .container { width: 100%; max-width: 460px; padding: 24px; }
        .card { width: 100%; background: rgba(17, 24, 39, 0.85); border: 1px solid rgba(148, 163, 184, 0.1); border-radius: 16px; padding: 28px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); backdrop-filter: blur(6px); }
        h1 { margin: 0 0 8px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
        p.sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
        .field { margin-bottom: 14px; }
        label { display: block; font-size: 13px; margin-bottom: 6px; color: #cbd5e1; }
        input[type=text], input[type=password] { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(148, 163, 184, 0.22); background: rgba(2,6,23,0.4); color: var(--text); outline: none; transition: border 0.2s, box-shadow 0.2s; }
        input[type=text]:focus, input[type=password]:focus { border-color: rgba(59,130,246,0.6); box-shadow: 0 0 0 4px rgba(59,130,246,0.15); }
        .actions { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
        .remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #cbd5e1; }
        button { width: 100%; margin-top: 12px; padding: 12px 16px; background: linear-gradient(135deg, #2563eb, #06b6d4); border: none; border-radius: 10px; color: white; font-weight: 600; cursor: pointer; box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35); transition: transform 0.08s ease, filter 0.2s ease; }
        button:hover { filter: brightness(1.05); }
        button:active { transform: translateY(1px); }
        .errors { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.35); color: #fecaca; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 13px; }
        .footer { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

        /* Password toggle */
        .input-wrap { position: relative; }
        .view-pass { font-size: 13px; color: #93c5fd; cursor: pointer; user-select: none; }
        .view-pass:hover { text-decoration: underline; }
    </style>
</head>
<body>
    <div class="topbar">
        <a class="link-btn" href="{{ route('login') }}">Kembali</a>
    </div>

    <div class="container">
        <form class="card" method="POST" action="{{ route('login.post') }}">
            @csrf
            <h1>Masuk Admin / Atasan</h1>
            <p class="sub">Silakan masukkan kredensial Anda.</p>

            @if (session('status'))
                <div style="background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.35); color: #bbf7d0; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 13px;">
                    {{ session('status') }}
                </div>
            @endif

            @if ($errors->any())
                <div class="errors">
                    <ul style="margin:0; padding-left: 18px;">
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif

            <div class="field">
                <label for="username">Username</label>
                <input id="username" type="text" name="username" value="{{ old('username', request('prefill')) }}" required autofocus />
            </div>

            <div class="field">
                <label for="password">Password</label>
                <div class="input-wrap">
                    <input id="password" type="password" name="password" required />
                </div>
            </div>

            <div class="actions">
                <label class="remember">
                    <input type="checkbox" name="remember" value="1" /> Ingat saya
                </label>
                <span class="view-pass" data-target="password">Lihat password</span>
            </div>

            <button type="submit">Login</button>

            <div class="footer">
                <div style="margin-top:6px; display:flex; justify-content:center; align-items:center; gap:8px;">
                    <a href="{{ route('password.request') }}">Lupa password?</a>
                    <span>•</span>
                    <a href="{{ route('register') }}">Daftar</a>
                </div>
            </div>
        </form>
    </div>
    <script>
        document.querySelectorAll('.view-pass').forEach(el => {
            el.addEventListener('click', () => {
                const id = el.getAttribute('data-target');
                const input = document.getElementById(id);
                if (!input) return;
                const isPass = input.type === 'password';
                input.type = isPass ? 'text' : 'password';
                el.textContent = isPass ? 'Sembunyikan password' : 'Lihat password';
            });
        });
    </script>
</body>
</html>
