<div class="row">
    <div class="col-md-6">
        <label class="form-label">{{ __('Championship') }}</label>
        <select class="form-select" name="championship_id" {{ isset($team) ? 'disabled' : '' }} required>
            <option value="">{{ __('Select Championship') }}</option>
            @foreach($championships as $championship)
                <option value="{{ $championship->id }}" {{ (isset($team) ? $team->championship_id : old('championship_id')) == $championship->id ? 'selected' : '' }}>
                    {{ $championship->name }} ({{ __('Players') }}: {{ $championship->players_count }})
                </option>
            @endforeach
        </select>
        @if(isset($team))
            <input type="hidden" name="championship_id" value="{{ $team->championship_id }}">
        @endif
    </div>
    <x-forms col="6" label="{{ __('dashboard.name') }}" name="name" :value="$team->name ?? ''" required />
</div>

<div class="row">
    <div class="col-md-6">
        <label class="form-label">{{ __('Group') }}</label>
        <select class="form-select" name="group_id">
            <option value="">{{ __('No Group') }}</option>
            @foreach($groups as $group)
                <option value="{{ $group->id }}" {{ (isset($team) ? $team->group_id : old('group_id')) == $group->id ? 'selected' : '' }}>
                    {{ $group->name }}
                </option>
            @endforeach
        </select>
    </div>
    <div class="col-md-6">
        <label class="form-label">{{ __('Created By Member') }}</label>
        <select class="form-select" name="created_by_member_id">
            <option value="">{{ __('Auto From Members') }}</option>
            @foreach($members as $member)
                <option value="{{ $member->id }}" {{ (isset($team) ? $team->created_by_member_id : old('created_by_member_id')) == $member->id ? 'selected' : '' }}>
                    {{ $member->name }}
                </option>
            @endforeach
        </select>
    </div>
</div>

<div class="row">
    <x-image label="{{ __('Logo') }}" name="logo" :value="$team->logo ?? null" />
    <div class="col-md-6">
        <label class="form-label">{{ __('Member Phones') }}</label>
        <select class="form-select select2" name="member_phones[]" multiple {{ isset($team) ? '' : 'required' }}>
            @php $selectedPhones = old('member_phones', []); @endphp
            @foreach($members as $member)
                <option value="{{ $member->phone }}" {{ in_array($member->phone, $selectedPhones) ? 'selected' : '' }}>
                    {{ $member->name }} ({{ $member->phone }})
                </option>
            @endforeach
        </select>
        <small class="text-muted">{{ __('Members are invited by phone and must approve to confirm team.') }}</small>
    </div>
</div>
