@if(count($combinations) > 0)
    <table class="table table-borderless table--vertical-middle">
        <thead class="thead-light __bg-7">
        <tr>
            <th class="text-center border-0">
                <span class="control-label m-0">{{translate('messages.Variant')}}</span>
            </th>
            <th class="text-center border-0">
                <span class="control-label">{{translate('messages.Variant Price')}}</span>
            </th>
            @if ($stock)
                <th class="text-center border-0">
                    <span class="control-label text-capitalize">{{translate('messages.stock')}}</span>
                </th>
            @endif
            <th class="text-center border-0">
                <span class="control-label">{{ translate('Variant Image') }}</span>
            </th>
        </tr>
        </thead>
        <tbody>

        @foreach ($combinations as $key => $combination)
            @php($variationKey = str_replace('.', '_', $combination['type']))
            <tr>
                <td class="text-center error-wrapper">
                    <label class="control-label m-0">{{ $combination['type'] }}</label>
                    <input value="{{ $combination['type'] }}" name="type[]" type="hidden">
                </td>
                <td class="error-wrapper">
                    <input type="number" name="price_{{ $variationKey }}"
                           value="{{$combination['price']}}" min="0"
                           step="0.01"
                           class="form-control" required>
                </td>
                @if ($stock)
                    <td class="error-wrapper">
                        <input type="number" name="stock_{{ $variationKey }}" value="{{$combination['stock']??0}}" min="0"
                                class="form-control update_qty" required>
                    </td>
                @endif
                <td class="error-wrapper">
                    <input type="hidden" name="existing_variation_image_{{ $variationKey }}" value="{{ $combination['image'] ?? '' }}">
                    <input type="hidden" name="existing_variation_storage_{{ $variationKey }}" value="{{ $combination['storage'] ?? 'public' }}">
                    <div class="d-flex flex-column align-items-center gap-2">
                        @if(!empty($combination['image']))
                            <img
                                src="{{ \App\CentralLogics\Helpers::get_full_url('product', $combination['image'], $combination['storage'] ?? 'public') }}"
                                alt="{{ $combination['type'] }}"
                                style="width: 42px; height: 42px; object-fit: cover; border-radius: 6px;"
                            >
                        @endif
                        <input type="file" name="variation_image_{{ $variationKey }}" class="form-control" accept="image/*">
                    </div>
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
@endif
