@extends('layouts.yellow')

@section('content')
<nav class="page-breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="{{route('dashboard')}}">Dashboard</a></li>
        <li class="breadcrumb-item"><a href="{{route('routes.index')}}">{{ __('common.route-permissions') }}</a></li>
        <li class="breadcrumb-item active" aria-current="page">{{ __('common.create-route') }}</li>
    </ol>
</nav>

<div class="row">
    <div class="col-md-12 grid-margin stretch-card">
        <div class="card">
            <div class="card-body">
                <h6 class="card-title">{{ __('common.create-route') }}</h6>
                
                @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 class="forms-sample" method="POST" action="{{ route('routes.store') }}">
                    @csrf
                    
                    <div class="mb-3">
                        <label for="path" class="form-label">{{ __('common.path') }} <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" id="path" name="path" placeholder="{{ __('common.enter-path') }}" value="{{ old('path') }}" required>
                        <small class="form-text text-muted">{{ __('common.path-description') }}</small>
                    </div>
                    
                    <div class="mb-3">
                        <label for="description" class="form-label">{{ __('common.description') }}</label>
                        <input type="text" class="form-control" id="description" name="description" placeholder="{{ __('common.enter-description') }}" value="{{ old('description') }}">
                    </div>
                    
                    <div class="form-check form-switch mb-3">
                        <input type="checkbox" class="form-check-input" id="is_public" name="is_public" value="1" {{ old('is_public') ? 'checked' : '' }}>
                        <label class="form-check-label" for="is_public">{{ __('common.is-public-route') }}</label>
                        <div><small class="text-muted">{{ __('common.public-route-description') }}</small></div>
                    </div>
                    
                    <div class="mb-3">
                        <label class="form-label">{{ __('common.roles-with-access') }}</label>
                        <div>
                            @foreach($roles as $role)
                            <div class="form-check form-check-inline">
                                <input type="checkbox" class="form-check-input" id="role_{{ $role->id }}" name="roles[]" value="{{ $role->id }}" {{ in_array($role->id, old('roles', [])) ? 'checked' : '' }}>
                                <label class="form-check-label" for="role_{{ $role->id }}">{{ $role->display_name }}</label>
                            </div>
                            @endforeach
                        </div>
                        <small class="form-text text-muted">{{ __('common.roles-access-description') }}</small>
                    </div>
                    
                    <button type="submit" class="btn btn-primary me-2">{{ __('common.submit') }}</button>
                    <a href="{{ route('routes.index') }}" class="btn btn-secondary">{{ __('common.cancel') }}</a>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
