<div class="md:grid md:grid-cols-3 md:gap-6">
    <div class="md:col-span-1 flex justify-between">
        <div class="px-4 sm:px-0">
            <h3 class="text-lg font-medium text-gray-900 dark:text-gray-100">{{ __('Team Name') }}</h3>
            <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">{{ __('The team\'s name and owner information.') }}</p>
        </div>
    </div>

    <div class="mt-5 md:mt-0 md:col-span-2">
        <form wire:submit="updateTeamName">
            <div class="px-4 py-5 bg-white dark:bg-gray-800 sm:p-6 shadow {{ Gate::check('update', $team) ? 'sm:rounded-tl-md sm:rounded-tr-md' : 'sm:rounded-md' }}">
                <div class="grid grid-cols-6 gap-6">
                    <!-- Team Owner Information -->
                    <div class="col-span-6">
                        <x-aura::label value="{{ __('Team Owner') }}" />

                        <div class="flex items-center mt-2">
                            <img class="w-12 h-12 rounded-full object-cover" src="{{ $team->owner->profile_photo_url }}" alt="{{ $team->owner->name }}">

                            <div class="ml-4 leading-tight">
                                <div class="dark:text-gray-200">{{ $team->owner->name }}</div>
                                <div class="text-gray-700 dark:text-gray-400 text-sm">{{ $team->owner->email }}</div>
                            </div>
                        </div>
                    </div>

                    <!-- Team Name -->
                    <div class="col-span-6 sm:col-span-4">
                        <x-aura::label for="name" value="{{ __('Team Name') }}" />

                        <x-aura::text-input id="name"
                                    type="text"
                                    class="mt-1 block w-full"
                                    wire:model="state.name"
                                    :disabled="! Gate::check('update', $team)" />

                        <x-aura::input-error :messages="$errors->get('state.name')" class="mt-2" />
                    </div>
                </div>
            </div>

            @if (Gate::check('update', $team))
                <div class="flex items-center justify-end px-4 py-3 bg-gray-50 dark:bg-gray-800 text-end sm:px-6 shadow sm:rounded-bl-md sm:rounded-br-md">
                    <div x-data="{ shown: false, timeout: null }"
                         x-init="@this.on('saved', () => { clearTimeout(timeout); shown = true; timeout = setTimeout(() => { shown = false }, 2000); })"
                         x-show.transition.out.opacity.duration.1500ms="shown"
                         x-transition:leave.opacity.duration.1500ms
                         style="display: none;"
                         class="text-sm text-gray-600 dark:text-gray-400 mr-3">
                        {{ __('Saved.') }}
                    </div>

                    <x-aura::primary-button>
                        {{ __('Save') }}
                    </x-aura::primary-button>
                </div>
            @endif
        </form>
    </div>
</div>
