<div class="row">
    <div class="col-md-12 mb-3">
        @if($member?->qr_code ?? null)
            <p class="small text-muted mb-2">{{ __('dashboard.qr_code_membership_auto') }}: <code>{{ $member->qr_code }}</code></p>
        @else
            <p class="small text-muted mb-2">{{ __('dashboard.qr_code_membership_after_save') }}</p>
        @endif

        <label class="form-label" for="member_qr_code_static_input">{{ __('dashboard.qr_code_static') }}</label>
        <input type="text" name="qr_code_static" id="member_qr_code_static_input" class="form-control @error('qr_code_static') is-invalid @enderror"
            value="{{ old('qr_code_static', $member?->qr_code_static ?? '') }}" maxlength="50" autocomplete="off"
            placeholder="{{ __('dashboard.qr_code_static_optional_placeholder') }}">
        <p class="text-muted small mb-0">{{ __('dashboard.qr_code_static_auto_enable_help') }}</p>
        @error('qr_code_static')
            <div class="invalid-feedback d-block">{{ $message }}</div>
        @enderror
    </div>
</div>

<div class="row">
    <x-forms col="6" label="{{ __('dashboard.name') }}" name="name" :value="$member->name ?? ''" required />
    <x-forms col="6" label="{{ __('dashboard.phone') }}" name="phone" :value="$member->phone ?? ''" required />
</div>

<div class="row">
    <x-forms col="6" label="{{ __('dashboard.email') }}" name="email" type="email" :value="$member->email ?? ''" />
    <x-forms col="6" label="{{ __('dashboard.date_of_birth') }}" name="dob" type="date" :value="$member?->dob ? $member->dob->format('Y-m-d') : ''" />
</div>

<div class="row">
    <x-forms col="12" label="{{ __('dashboard.address') }}" name="address" :value="$member->address ?? ''" />
</div>

<div class="row">
    <div class="col-md-6">
        <label class="form-label">{{ __('dashboard.member_type') }}</label>
        <select name="member_type" class="form-select" required>
            @foreach(\App\Enums\MemberTypeEnum::options() as $opt)
                <option value="{{ $opt['value'] }}" {{ (int) old('member_type', $member?->member_type ?? \App\Enums\MemberTypeEnum::ALL_INCLUSIVE->value) === (int) $opt['value'] ? 'selected' : '' }}>{{ $opt['label'] }}</option>
            @endforeach
        </select>
    </div>
</div>

<div class="row">
    <x-forms col="4" label="{{ __('dashboard.start_date_subscription') }}" name="start_date_subscription" type="date" :value="$member?->start_date_subscription ? $member->start_date_subscription->format('Y-m-d') : ''" />
    <x-forms col="4" label="{{ __('dashboard.end_date_subscription') }}" name="end_date_subscription" type="date" :value="$member?->end_date_subscription ? $member->end_date_subscription->format('Y-m-d') : ''" />
    <div class="col-md-4">
        <x-image label="{{ __('dashboard.image') }}" name="image" :value="$member?->image ?? null" />
    </div>
</div>
