@extends('layouts.admin.theme')
@section('title', env('APP_NAME') . ' :: ' . __('Nova linha do tempo'))
@push('scripts')
    <link rel="stylesheet" href="{{ asset('pmar/css/linhas-do-tempo.css') }}">
@endpush
@section('content')

<div class="card shadow-sm border-0" id="lt-form-page"
     data-msg-draft="{{ __('Rascunho salvo às') }}"
     data-lt-page="create"
     data-draft-get-url="{{ route('admin.contaAngra.linhasDoTempo.draft.createTimeline.show') }}"
     data-draft-post-url="{{ route('admin.contaAngra.linhasDoTempo.draft.createTimeline') }}"
     data-draft-delete-url="{{ route('admin.contaAngra.linhasDoTempo.draft.createTimeline.destroy') }}">

    @php $headLine = "<i class='fa-solid fa-plus'></i> " . e(__('Nova linha do tempo')); @endphp

    @include('components.buttons._headLineButtonsBackAdd', [
        'headLine' => $headLine,
        'routeBack' => 'admin.contaAngra.linhasDoTempo.index',
        'routeBackParams' => request()->only(['q', 'status', 'date_from', 'date_to', 'tag', 'sort', 'dir', 'view']),
        'nameBack' => __('Voltar'),
        'permission' => 'GERENCIADOR_DE_LINHAS_DO_TEMPO',
    ])

    <div class="card-body">
        @include('errors.messageFlash')

        <div class="modal fade" id="ltModalDraftResume" tabindex="-1" aria-labelledby="ltModalDraftResumeLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h2 class="modal-title h5" id="ltModalDraftResumeLabel">{{ __('Rascunho encontrado') }}</h2>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{ __('Fechar') }}"></button>
                    </div>
                    <div class="modal-body">
                        <p id="ltModalDraftResumeText">{{ __('Existe um rascunho não finalizado. Deseja continuar de onde parou?') }}</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id="ltDraftDiscard">{{ __('Não, descartar') }}</button>
                        <button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="ltDraftResume">{{ __('Sim, continuar') }}</button>
                    </div>
                </div>
            </div>
        </div>

        <form action="{{ route('admin.contaAngra.linhasDoTempo.store') }}" method="post" enctype="multipart/form-data" id="ltFormCreate">
            @csrf
            <div class="mb-3">
                <label for="name" class="form-label">{{ __('Nome') }} <span class="text-danger">*</span></label>
                <input type="text" class="form-control" name="name" id="name" maxlength="150" value="{{ old('name') }}" required>
            </div>
            <div class="mb-3">
                <label for="event_date" class="form-label">{{ __('Data de acontecimento (marco zero)') }} <span class="text-danger">*</span></label>
                <input type="date" class="form-control" name="event_date" id="event_date" value="{{ old('event_date') }}" required>
            </div>
            <div class="mb-3">
                <label for="process_text" class="form-label">{{ __('Processo') }} <span class="text-danger">*</span></label>
                <textarea class="form-control" name="process_text" id="process_text" rows="12" aria-required="true">{{ old('process_text') }}</textarea>
                <span class="form-text">{{ __('Texto principal do processo ou serviço (obrigatório), com formatação básica.') }}</span>
            </div>
            <div class="mb-3">
                <label for="description" class="form-label">{{ __('Descrição / resumo') }}</label>
                <input type="text" class="form-control" name="description" id="description" maxlength="300" value="{{ old('description') }}" placeholder="{{ __('Resumo opcional (até 300 caracteres)') }}">
                <span class="form-text">{{ __('Opcional. Até 300 caracteres.') }}</span>
            </div>
            <div class="mb-3">
                <label for="tags_input" class="form-label">{{ __('Tags (separadas por vírgula)') }}</label>
                <input type="text" class="form-control" name="tags_input" id="tags_input" value="{{ old('tags_input') }}" placeholder="{{ __('Ex.: contrato, fiscalização') }}">
            </div>
            <div class="mb-3">
                <label for="attachments" class="form-label">{{ __('Anexos') }}</label>
                <input type="file" class="form-control" name="attachments[]" id="attachments" multiple accept=".pdf,.png,.jpg,.jpeg,.gif,.webp,.xlsx,.xls,.ods,.csv,.docx,.doc">
            </div>
            <div class="d-flex justify-content-between align-items-center">
                <span class="small text-muted" id="ltAutosaveStatus" aria-live="polite"></span>
                @if (auth()->user()->getPermissaoDetalhes('GERENCIADOR_DE_LINHAS_DO_TEMPO')['adicionar'])
                    <button type="submit" class="btn btn-primary">{{ __('Criar linha do tempo') }}</button>
                @endif
            </div>
        </form>
    </div>
</div>
@endsection

@push('after-scripts')
    <script src="{{ asset('pmar/js/linhas-do-tempo.js') }}"></script>
@endpush
