@extends('layouts.app')

@section('title', __('app.two_factor_auth'))
@section('page_title', __('app.two_factor_auth'))

@section('content')
<div class="container-fluid">
    <div class="row">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">{{ __('app.two_factor_auth') }}</h3>
                </div>
                <div class="card-body">
                    @if($user->isTwoFactorEnabled())
                        <div class="alert alert-success">
                            <i class="fas fa-check-circle"></i> {{ __('auth.2fa_enabled') }}
                        </div>
                        
                        <p>{{ __('app.save_recovery_codes') }}</p>
                        
                        <form action="{{ route('2fa.disable') }}" method="POST">
                            @csrf
                            <div class="form-group">
                                <label>{{ __('app.password') }}</label>
                                <input type="password" name="password" class="form-control @error('password') is-invalid @enderror" required>
                                @error('password')
                                    <span class="invalid-feedback">{{ $message }}</span>
                                @enderror
                            </div>
                            <div class="form-group">
                                <label>{{ __('app.verify_code') }} ({{ __('app.optional') }})</label>
                                <input type="text" name="code" class="form-control @error('code') is-invalid @enderror" placeholder="000000">
                                @error('code')
                                    <span class="invalid-feedback">{{ $message }}</span>
                                @enderror
                            </div>
                            <button type="submit" class="btn btn-danger">{{ __('app.disable_2fa') }}</button>
                        </form>
                        
                        <hr>
                        
                        <a href="{{ route('2fa.recovery-codes') }}" class="btn btn-info">
                            {{ __('app.regenerate_recovery_codes') }}
                        </a>
                    @else
                        <div class="alert alert-info">
                            <i class="fas fa-info-circle"></i> {{ __('auth.2fa_not_enabled') }}
                        </div>
                        
                        <p>{{ __('app.two_factor_auth_info') ?? 'Two-factor authentication adds an extra layer of security to your account. Once enabled, you will need to enter a code from your authenticator app in addition to your password when logging in.' }}</p>
                        
                        <a href="{{ route('2fa.enable') }}" class="btn btn-primary">{{ __('app.enable_2fa') }}</a>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
