@extends('layout')

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

@section('content')
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="card shadow">
                <div class="card-body p-4">
                    <div class="text-center mb-4">
                        <i class="fas fa-file-contract fa-4x text-warning mb-3"></i>
                        <h2>{{ __('store.auth_accept_terms_title') }}</h2>
                    </div>

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

                    <div class="mb-4">
                        <p class="text-muted">
                            {{ __('store.auth_terms_acceptance_description') }}
                        </p>
                    </div>

                    @if($tosUrl)
                    <div class="mb-4">
                        <div class="card ">
                            <div class="card-body">
                                <h5 class="card-title">
                                    <i class="fas fa-external-link-alt me-2"></i>
                                    {{ __('store.auth_terms_of_service') }}
                                </h5>
                                <p class="card-text">
                                    {{ __('store.auth_please_read_terms') }}
                                </p>
                                <a href="{{ $tosUrl }}" target="_blank" class="btn btn-outline-primary">
                                    <i class="fas fa-book-open me-2"></i>
                                    {{ __('store.auth_read_terms') }}
                                </a>
                            </div>
                        </div>
                    </div>
                    @endif

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

                        <div class="mb-4">
                            <div class="form-check">
                                <input class="form-check-input @error('terms') is-invalid @enderror" type="checkbox"
                                       id="terms" name="terms" required>
                                <label class="form-check-label" for="terms">
                                    <strong>
                                        {{ __('store.auth_terms_agreement_start') }}
                                        @if($tosUrl)
                                            <a href="{{ $tosUrl }}" target="_blank" class="text-decoration-none">
                                                {{ __('store.auth_terms_of_service') }}
                                            </a>
                                        @else
                                            {{ __('store.auth_terms_of_service') }}
                                        @endif
                                        {{ __('store.auth_terms_agreement_end') }}
                                    </strong>
                                </label>
                                @error('terms')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-6">
                                <div class="d-grid">
                                    <button type="submit" class="btn btn-success btn-lg">
                                        <i class="fas fa-check-circle me-2"></i>
                                        {{ __('store.auth_accept_and_continue') }}
                                    </button>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="d-grid">
                                    <form method="POST" action="{{ route('store.auth.logout') }}" class="d-grid">
                                        @csrf
                                        <button type="submit" class="btn btn-outline-secondary btn-lg">
                                            <i class="fas fa-sign-out-alt me-2"></i>
                                            {{ __('store.auth_logout') }}
                                        </button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </form>

                    <hr class="my-4">

                    <div class="text-center">
                        <small class="text-muted">
                            <i class="fas fa-info-circle me-1"></i>
                            {{ __('store.auth_terms_required_notice') }}
                        </small>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
