<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - Sistem Integrasi Penjualan</title>
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>
        :root {
            --primary-orange: #f59e0b;
            --dark-bg: #1e293b;
        }

        body { 
            background-color: #f8fafc; 
            font-family: 'Plus Jakarta Sans', sans-serif;
            display: flex; 
            align-items: center; 
            justify-content: center;
            min-height: 100vh; 
            margin: 0;
        }

        .login-wrapper {
            width: 100%;
            max-width: 420px;
            padding: 20px;
        }

        .system-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .system-header h2 {
            font-weight: 800;
            color: var(--dark-bg);
            font-size: 1.4rem;
            margin: 0;
            line-height: 1.2;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .login-card {
            background: #ffffff;
            border-radius: 0;
            padding: 40px;
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
            border: 1px solid #e2e8f0;
            margin-bottom: 25px;
        }

        .alert-error {
            background-color: #fef2f2;
            border: 1px solid #fca5a5;
            border-left: 4px solid #ef4444;
            padding: 12px 16px;
            margin-bottom: 24px;
            font-size: 0.875rem;
            color: #b91c1c;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-label {
            font-weight: 700;
            font-size: 0.8rem;
            color: #475569;
            margin-bottom: 8px;
            display: block;
            text-transform: uppercase;
        }

        .input-container {
            position: relative;
            display: flex;
            align-items: center;
        }

        .input-container i {
            position: absolute;
            left: 16px;
            color: var(--primary-orange);
        }

        .form-control {
            width: 100%;
            padding: 12px 16px 12px 48px;
            background-color: #f1f5f9;
            border: 2px solid transparent;
            border-radius: 0;
            font-family: 'Plus Jakarta Sans', sans-serif;
            font-size: 0.95rem;
            transition: all 0.2s;
            box-sizing: border-box;
        }

        .form-control:focus {
            outline: none;
            border-color: var(--primary-orange);
            background-color: #ffffff;
        }

        .form-control:-webkit-autofill,
        .form-control:-webkit-autofill:hover,
        .form-control:-webkit-autofill:focus {
            -webkit-box-shadow: 0 0 0px 1000px #f1f5f9 inset !important;
            box-shadow: 0 0 0px 1000px #f1f5f9 inset !important;
            -webkit-text-fill-color: #1e293b !important;
            transition: background-color 5000s ease-in-out 0s;
        }

        .btn-login {
            width: 100%;
            background-color: var(--primary-orange);
            color: white;
            border: none;
            padding: 14px;
            border-radius: 0;
            font-family: 'Plus Jakarta Sans', sans-serif;
            font-weight: 700;
            font-size: 0.95rem;
            cursor: pointer;
            margin-top: 10px;
            transition: opacity 0.2s;
        }

        .btn-login:hover {
            opacity: 0.9;
        }

        .system-footer {
            text-align: center;
            padding: 0 10px;
        }

        .footer-desc {
            color: #64748b;
            font-size: 0.85rem;
            line-height: 1.5;
            margin: 0;
        }

        .footer-roles {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-top: 10px;
        }

        .role-text {
            color: #475569;
            font-size: 0.75rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
    </style>
</head>
<body>

    <div class="login-wrapper">
        <div class="system-header">
            <h2>Sistem Integrasi<br>Manajemen Penjualan</h2>
        </div>

        <div class="login-card">

            {{-- Error Message --}}
            @if ($errors->any())
                <div class="alert-error">
                    <i class="fa-solid fa-circle-exclamation"></i>
                    {{ $errors->first() }}
                </div>
            @endif

            <form action="/login" method="POST" autocomplete="off">
                @csrf

                <input type="text" style="display:none;">
                <input type="password" style="display:none;">

                <div class="form-group">
                    <label class="form-label">Email Akses</label>
                    <div class="input-container">
                        <i class="fa-solid fa-envelope"></i>
                        <input 
                            type="text" 
                            name="email" 
                            id="email"
                            class="form-control" 
                            placeholder="Masukkan email akses Anda"
                            data-old="{{ old('email') }}"
                            autocomplete="new-password"
                            required
                        >
                    </div>
                </div>

                <div class="form-group">
                    <label class="form-label">Kata Sandi</label>
                    <div class="input-container">
                        <i class="fa-solid fa-lock"></i>
                        <input 
                            type="password" 
                            name="password" 
                            id="password"
                            class="form-control" 
                            placeholder="Masukkan kata sandi"
                            autocomplete="new-password"
                            required
                        >
                    </div>
                </div>

                <button type="submit" class="btn-login">LOGIN KE SISTEM</button>
            </form>
        </div>

        <div class="system-footer">
            <p class="footer-desc">Manajemen operasional untuk:</p>
            <div class="footer-roles">
                <span class="role-text">Admin</span>
                <span class="role-text">CS</span>
                <span class="role-text">Gudang</span>
            </div>
        </div>
    </div>

    <script>
        // Set email dari Laravel old() via data-attribute,
        // dilakukan setelah load supaya override autofill Chrome
        window.addEventListener('load', function () {
            setTimeout(function () {
                const emailInput = document.getElementById('email');
                const oldEmail = emailInput.getAttribute('data-old');
                if (oldEmail) {
                    emailInput.value = oldEmail;
                } else {
                    emailInput.value = '';
                }

                // Kosongkan password — jangan biarkan autofill browser mengisi
                document.getElementById('password').value = '';
            }, 100);
        });
    </script>

</body>
</html>