@extends('layouts.guest')

@section('title', 'Aceptar Invitación')

@section('content')
<div class="card">
    <div class="card-header bg-primary text-white">
        <h4 class="mb-0">Bienvenido a Ticketera</h4>
    </div>
    <div class="card-body">
        <div class="alert alert-info">
            <i class="bi bi-info-circle me-2"></i>
            Has sido invitado a unirte a <strong>{{ $company->name }}</strong> para el proyecto <strong>{{ $project->name }}</strong>
        </div>

        <form method="POST" action="{{ route('invitation.accept', $token) }}">
            @csrf

            <div class="mb-3">
                <label for="email" class="form-label">Correo Electrónico</label>
                <input type="email" class="form-control" id="email" value="{{ $user->email }}" disabled>
            </div>

            <div class="mb-3">
                <label for="name" class="form-label">Nombre Completo <span class="text-danger">*</span></label>
                <input type="text" class="form-control @error('name') is-invalid @enderror" 
                       id="name" name="name" value="{{ old('name') }}" required autofocus>
                @error('name')
                <div class="invalid-feedback">{{ $message }}</div>
                @enderror
            </div>

            <div class="mb-3">
                <label for="phone" class="form-label">Teléfono</label>
                <input type="text" class="form-control @error('phone') is-invalid @enderror" 
                       id="phone" name="phone" value="{{ old('phone') }}">
                @error('phone')
                <div class="invalid-feedback">{{ $message }}</div>
                @enderror
            </div>

            <div class="mb-3">
                <label for="position" class="form-label">Cargo</label>
                <input type="text" class="form-control @error('position') is-invalid @enderror" 
                       id="position" name="position" value="{{ old('position') }}">
                @error('position')
                <div class="invalid-feedback">{{ $message }}</div>
                @enderror
            </div>

            <div class="mb-3">
                <label for="password" class="form-label">Contraseña <span class="text-danger">*</span></label>
                <input type="password" class="form-control @error('password') is-invalid @enderror" 
                       id="password" name="password" required>
                @error('password')
                <div class="invalid-feedback">{{ $message }}</div>
                @enderror
                <div class="form-text">Mínimo 8 caracteres</div>
            </div>

            <div class="mb-4">
                <label for="password_confirmation" class="form-label">Confirmar Contraseña <span class="text-danger">*</span></label>
                <input type="password" class="form-control" 
                       id="password_confirmation" name="password_confirmation" required>
            </div>

            <div class="d-grid">
                <button type="submit" class="btn btn-primary">
                    <i class="bi bi-check-circle me-2"></i>Aceptar y Crear Cuenta
                </button>
            </div>
        </form>

        <div class="mt-3 text-center">
            <small class="text-muted">
                Al aceptar esta invitación, podrás crear y dar seguimiento a tickets para el proyecto {{ $project->name }}
            </small>
        </div>
    </div>
</div>
@endsection
