@php
    /** @var \App\Models\ParqueTecnologico\Startup|null $startup */
    $startup = $startup ?? null;
@endphp

<div class="row">

    {{-- COLUNA ESQUERDA --}}
    <div class="col-lg-8">

        {{-- INFORMAÇÕES --}}
        <div class="card mb-4 border-0 shadow-sm">
            <div class="card-header bg-light fw-bold">
                <i class="fa-solid fa-circle-info me-2"></i> Informações Gerais
            </div>
            <div class="card-body">

                @include('components.inputs._inputType', [
                    'label' => __('Nome'),
                    'name' => 'nome',
                    'required' => true,
                    'old' => $startup?->nome,
                ])

                @include('components.inputs._textarea', [
                    'label' => __('Descrição') . ' (' . __('opcional') . ')',
                    'name' => 'descricao',
                    'value' => $startup?->descricao ?? '',
                    'rows' => 4,
                ])

                <div class="mb-3">
                    <label class="form-label fw-bold">
                        <i class="fa-solid fa-layer-group me-1"></i>
                        {{ __('Segmento da Startup') }}
                    </label>

                    <select class="form-select shadow-sm @error('segmento') is-invalid @enderror" name="segmento" required>
                        <option value="">{{ __('Selecione') }}</option>
                        <option value="tecnologia" {{ old('segmento', $startup?->segmento) === 'tecnologia' ? 'selected' : '' }}>Tecnologia</option>
                        <option value="energia" {{ old('segmento', $startup?->segmento) === 'energia' ? 'selected' : '' }}>Energia</option>
                        <option value="logistica" {{ old('segmento', $startup?->segmento) === 'logistica' ? 'selected' : '' }}>Logística</option>
                        <option value="sustentabilidade" {{ old('segmento', $startup?->segmento) === 'sustentabilidade' ? 'selected' : '' }}>Sustentabilidade</option>
                        <option value="nautica_naval" {{ old('segmento', $startup?->segmento) === 'nautica_naval' ? 'selected' : '' }}>Náutica e Naval</option>
                    </select>

                    @error('segmento')
                        <small class="text-danger">{{ $message }}</small>
                    @enderror
                </div>

            </div>
        </div>

        {{-- IMAGENS --}}
        <div class="card mb-4 border-0 shadow-sm">
            <div class="card-header bg-light fw-bold">
                <i class="fa-solid fa-image me-2"></i> Imagens
            </div>
            <div class="card-body">

                {{-- LOGO --}}
                <div class="mb-4">
                    <label class="form-label fw-bold">{{ __('Logo') }}</label>

                    <input type="file" class="form-control @error('logo') is-invalid @enderror" name="logo" id="logo" accept="image/*">

                    <div class="mt-3 text-center">
                        <img id="previewLogo"
                             src="{{ $startup?->logo ?? 'https://via.placeholder.com/150' }}"
                             class="img-fluid rounded shadow-sm"
                             style="max-height: 120px;">
                    </div>

                    @error('logo')
                        <small class="text-danger">{{ $message }}</small>
                    @enderror
                </div>

                {{-- BACKGROUND --}}
                <div class="mb-3">
                    <label class="form-label fw-bold">{{ __('Imagem de fundo') }}</label>

                    <input type="file" class="form-control @error('background') is-invalid @enderror" name="background" id="background" accept="image/*">

                    <div class="mt-3 text-center">
                        <img id="previewBg"
                             src="{{ $startup?->background ?? 'https://via.placeholder.com/300x120' }}"
                             class="img-fluid rounded shadow-sm"
                             style="max-height: 120px;">
                    </div>

                    @error('background')
                        <small class="text-danger">{{ $message }}</small>
                    @enderror
                </div>

            </div>
        </div>

    </div>

    {{-- COLUNA DIREITA --}}
    <div class="col-lg-4">

        {{-- CONTATO --}}
        <div class="card mb-4 border-0 shadow-sm">
            <div class="card-header bg-light fw-bold">
                <i class="fa-solid fa-address-card me-2"></i> Contato
            </div>
            <div class="card-body">

                <div class="mb-3">
                    <label class="form-label fw-bold">{{ __('E-mail comercial') }}</label>
                    <div class="input-group">
                        <span class="input-group-text"><i class="fa-solid fa-envelope"></i></span>
                        <input type="email" name="email" class="form-control"
                               value="{{ old('email', $startup?->email) }}" required>
                    </div>
                </div>

                <div class="mb-3">
                    <label class="form-label fw-bold">{{ __('Telefone') }}</label>
                    <div class="input-group">
                        <span class="input-group-text"><i class="fa-solid fa-phone"></i></span>
                        <input type="text" name="telefone" class="form-control"
                               value="{{ old('telefone', $startup?->telefone) }}">
                    </div>
                </div>

                <div class="mb-3">
                    <label class="form-label fw-bold">{{ __('Rede Social') }}</label>
                    <div class="input-group">
                        <span class="input-group-text"><i class="fa-solid fa-globe"></i></span>
                        <input type="url" name="rede_social" class="form-control"
                               placeholder="{{ __('https://...') }}"
                               value="{{ old('rede_social', $startup?->rede_social) }}">
                    </div>
                </div>

                <div class="mb-3">
                    <label class="form-label fw-bold">{{ __('Link do site') }}</label>
                    <div class="input-group">
                        <span class="input-group-text"><i class="fa-solid fa-link"></i></span>
                        <input type="url" name="link_site" class="form-control"
                               placeholder="{{ __('https://...') }}"
                               value="{{ old('link_site', $startup?->link_site) }}">
                    </div>
                </div>

            </div>
        </div>

        {{-- CONFIGURAÇÕES --}}
        <div class="card mb-4 border-0 shadow-sm">
            <div class="card-header bg-light fw-bold">
                <i class="fa-solid fa-gear me-2"></i> Configurações
            </div>
            <div class="card-body">

                <div class="mb-3">
                    <label class="form-label fw-bold">{{ __('Status') }}</label>
                    <select class="form-select" name="status">
                        @foreach(\App\Enums\StatusEnum::cases() as $status)
                            <option value="{{ $status->name }}"
                                {{ old('status', $startup?->status ?? 'ATIVADO') === $status->name ? 'selected' : '' }}>
                                {{ $status->value }}
                            </option>
                        @endforeach
                    </select>
                </div>

                @include('components.inputs._inputType', [
                    'label' => __('Ordem de exibição'),
                    'name' => 'ordem',
                    'type' => 'number',
                    'old' => (string) ($startup?->ordem ?? 0),
                ])

            </div>
        </div>

    </div>

</div>

@push('scripts')
    <script src="{{ asset('pmar/js/parqueTecnologico/startups/form.js') }}"></script>
@endpush