@extends('layout')

@section('title', __('store.auth_reset_password_title'))

@push('scripts')
@vite('resources/js/common/password-toggle.js')
@endpush

@section('content')
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-6 col-lg-5">
            <div class="card shadow">
                <div class="card-body p-4">
                    <h2 class="text-center mb-4">{{ __('store.auth_reset_password_title') }}</h2>

                    @if(session('success'))
                        <div class="alert alert-success">
                            {{ session('success') }}
                        </div>
                    @endif

                    @if(session('error'))
                        <div class="alert alert-danger">
                            {{ session('error') }}
                        </div>
                    @endif

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

                    <form method="POST" action="{{ route('store.auth.reset-password.store') }}">
                        @csrf

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

                        <div class="mb-3">
                            <label for="new_password" class="form-label">{{ __('store.auth_reset_password_new') }}</label>
                            <div class="input-group">
                                <input type="password" class="form-control @error('new_password') is-invalid @enderror"
                                       id="new_password" name="new_password" required autofocus>
                                <button class="btn btn-outline-secondary js-password-toggle" type="button" tabindex="-1"
                                        aria-label="{{ __('auth.password_show') }}"
                                        data-show-label="{{ __('auth.password_show') }}"
                                        data-hide-label="{{ __('auth.password_hide') }}">
                                    <i class="fas fa-eye"></i>
                                </button>
                                @error('new_password')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="form-text">{{ __('store.auth_password_requirements') }}</div>
                        </div>

                        <div class="mb-3">
                            <label for="new_password_confirmation" class="form-label">{{ __('store.auth_reset_password_confirm') }}</label>
                            <div class="input-group">
                                <input type="password" class="form-control"
                                       id="new_password_confirmation" name="new_password_confirmation" required>
                                <button class="btn btn-outline-secondary js-password-toggle" type="button" tabindex="-1"
                                        aria-label="{{ __('auth.password_show') }}"
                                        data-show-label="{{ __('auth.password_show') }}"
                                        data-hide-label="{{ __('auth.password_hide') }}">
                                    <i class="fas fa-eye"></i>
                                </button>
                            </div>
                        </div>

                        <div class="d-grid mb-3">
                            <button type="submit" class="btn btn-primary btn-lg">
                                <i class="fas fa-lock me-2"></i>
                                {{ __('store.auth_reset_password_submit') }}
                            </button>
                        </div>

                        <div class="text-center">
                            <p class="mb-0">
                                <a href="{{ route('store.auth.login') }}" class="text-decoration-none">
                                    <i class="fas fa-arrow-left me-1"></i>
                                    {{ __('store.auth_forgot_password_back_to_login') }}
                                </a>
                            </p>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
