@extends('layouts.auth')

@section('title', 'Reset Password')

@section('content')
    <h2 class="auth-title">RESET PASSWORD</h2>

    @if ($errors->any())
        <div class="alert alert-danger">
            @foreach ($errors->all() as $error)
                <div>{{ $error }}</div>
            @endforeach
        </div>
    @endif

    <form method="POST" action="{{ route('password.update') }}">
        @csrf

        <input type="hidden" name="token" value="{{ $token }}">

        <div class="mb-3">
            <input type="email" class="form-control @error('email') is-invalid @enderror" 
                placeholder="E-mail Anda" name="email" value="{{ $email ?? old('email') }}" required readonly>
            @error('email')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="mb-3 position-relative">
            <input type="password" class="form-control @error('password') is-invalid @enderror" 
                placeholder="Password Baru" name="password" id="password" required>
            <span class="position-absolute top-50 end-0 translate-middle-y me-2 password-toggle" 
                  onclick="togglePassword('password')" style="cursor: pointer;">
                <i class="bi bi-eye-slash" id="password-icon"></i>
            </span>
            @error('password')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="mb-3 position-relative">
            <input type="password" class="form-control @error('password_confirmation') is-invalid @enderror" 
                placeholder="Konfirmasi Password Baru" name="password_confirmation" id="password_confirmation" required>
            <span class="position-absolute top-50 end-0 translate-middle-y me-2 password-toggle" 
                  onclick="togglePassword('password_confirmation')" style="cursor: pointer;">
                <i class="bi bi-eye-slash" id="password_confirmation-icon"></i>
            </span>
            @error('password_confirmation')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <button type="submit" class="btn btn-auth">RESET PASSWORD</button>
    </form>

    <div class="auth-footer">
        Ingat password Anda? <a href="{{ route('login') }}">Login</a>
    </div>
@endsection 