<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    @php
        $title = $title ?? 'Login - AKRSera MLM';
        $heading = $heading ?? 'AKRSera Login';
        $subheading = $subheading ?? 'Sign in using email, mobile, or member ID.';
        $formAction = $formAction ?? route('auth.login.submit');
        $registerLink = $registerLink ?? route('register.user');
        $expectedRole = $expectedRole ?? null;
    @endphp
    <title>{{ $title }}</title>
    <style>
        body { margin:0; min-height:100vh; display:grid; place-items:center; font-family:"Segoe UI",Tahoma,sans-serif; background: linear-gradient(135deg,#ecfeff,#eff6ff,#f0fdf4); }
        .card { width:min(420px,94vw); background:#fff; border:1px solid #e2e8f0; border-radius:20px; padding:22px; box-shadow:0 14px 36px rgba(15,23,42,.12); }
        h1 { margin:0 0 6px; }
        p { margin:0 0 16px; color:#64748b; }
        label { display:block; font-size:13px; margin:10px 0 6px; font-weight:600; }
        input { width:100%; border:1px solid #cbd5e1; border-radius:10px; padding:10px; }
        button { margin-top:14px; width:100%; border:0; border-radius:10px; padding:11px; background:#16A34A; color:#fff; font-weight:700; cursor:pointer; }
        .error { font-size:12px; color:#b91c1c; margin-top:3px; }
    </style>
</head>
<body>
    <div class="card">
        <h1>{{ $heading }}</h1>
        <p>{{ $subheading }}</p>

        <form method="post" action="{{ $formAction }}">
            @csrf
            @if($expectedRole)
                <input type="hidden" name="expected_role" value="{{ $expectedRole }}">
            @endif
            <label for="login">Email / Mobile / Member ID</label>
            <input id="login" name="login" value="{{ old('login') }}" required>
            @error('login')<div class="error">{{ $message }}</div>@enderror

            <label for="password">Password</label>
            <input id="password" name="password" type="password" required>
            @error('password')<div class="error">{{ $message }}</div>@enderror

            <button type="submit">Login</button>
        </form>
        @if($registerLink)
            <p style="margin-top:12px;font-size:13px;">New distributor? <a href="{{ $registerLink }}">Create account</a></p>
        @endif
    </div>
</body>
</html>
