@extends('layout')

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

@section('content')
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-lg-8">
            <h1 class="mb-3">{{ __('store.contracts_pending_title') }}</h1>
            <p class="text-muted">{{ __('store.contracts_pending_subtitle') }}</p>

            <div class="card border-0 shadow-sm">
                <div class="list-group list-group-flush">
                    @foreach ($pending as $contract)
                        <div class="list-group-item d-flex flex-wrap justify-content-between align-items-center gap-2 py-3">
                            <div class="me-auto">
                                <span class="fw-semibold">{{ $contract->getTranslation('title') }}</span>
                                <small class="text-muted ms-1">v{{ $contract->version }}</small>
                                @if ($contract->grace_until && $contract->grace_until->isFuture())
                                    <div class="text-muted small mt-1">
                                        {{ __('store.contracts_pending_grace_until', ['date' => $contract->grace_until->format('Y-m-d')]) }}
                                    </div>
                                @endif
                            </div>
                            <div class="d-flex align-items-center gap-2">
                                <a href="{{ route('store.auth.contracts.detail', $contract->slug) }}?gate=1"
                                   class="btn btn-primary btn-sm">
                                    <i class="fas fa-eye me-1"></i>{{ __('store.contracts_pending_view_button') }}
                                </a>
                                @if ($contract->grace_until && $contract->grace_until->isFuture())
                                    <form method="POST" action="{{ route('store.auth.contracts.pending.skip', $contract->slug) }}">
                                        @csrf
                                        <button type="submit" class="btn btn-outline-secondary btn-sm">
                                            {{ __('store.contracts_pending_skip_button') }}
                                        </button>
                                    </form>
                                @endif
                            </div>
                        </div>
                    @endforeach
                </div>
            </div>

            <div class="text-center mt-4">
                <form method="POST" action="{{ route('store.auth.logout') }}" class="d-inline">
                    @csrf
                    <button type="submit" class="btn btn-link text-muted small p-0">
                        {{ __('store.contracts_pending_logout') }}
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
